mirror of
https://github.com/Nan1t/NanoLimbo.git
synced 2026-02-11 03:16:14 +01:00
Added join message and bossbar
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package ru.nanit.limbo.protocol.packets.play;
|
||||
|
||||
import ru.nanit.limbo.protocol.ByteMessage;
|
||||
import ru.nanit.limbo.protocol.PacketOut;
|
||||
import ru.nanit.limbo.protocol.registry.Version;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketBossBar implements PacketOut {
|
||||
|
||||
private UUID uuid;
|
||||
private String title;
|
||||
private float health;
|
||||
private Color color;
|
||||
private Division division;
|
||||
private int flags;
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void setDivision(Division division) {
|
||||
this.division = division;
|
||||
}
|
||||
|
||||
public void setFlags(int flags) {
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteMessage msg, Version version) {
|
||||
msg.writeUuid(uuid);
|
||||
msg.writeVarInt(0); // Create bossbar
|
||||
msg.writeString(title);
|
||||
msg.writeFloat(health);
|
||||
msg.writeVarInt(color.index);
|
||||
msg.writeVarInt(division.index);
|
||||
msg.writeByte(flags);
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
|
||||
PINK(0),
|
||||
BLUE(1),
|
||||
RED(2),
|
||||
GREEN(3),
|
||||
YELLOW(4),
|
||||
PURPLE(5),
|
||||
WHITE(6);
|
||||
|
||||
private final int index;
|
||||
|
||||
Color(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Division {
|
||||
|
||||
SOLID(0),
|
||||
DASHES_6(1),
|
||||
DASHES_10(2),
|
||||
DASHES_12(3),
|
||||
DASHES_20(4);
|
||||
|
||||
private final int index;
|
||||
|
||||
Division(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package ru.nanit.limbo.protocol.packets.play;
|
||||
|
||||
import ru.nanit.limbo.protocol.ByteMessage;
|
||||
import ru.nanit.limbo.protocol.PacketOut;
|
||||
import ru.nanit.limbo.protocol.registry.Version;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketChatMessage implements PacketOut {
|
||||
|
||||
private String jsonData;
|
||||
private Position position;
|
||||
private UUID sender;
|
||||
|
||||
public void setJsonData(String jsonData) {
|
||||
this.jsonData = jsonData;
|
||||
}
|
||||
|
||||
public void setPosition(Position position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setSender(UUID sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteMessage msg, Version version) {
|
||||
msg.writeString(jsonData);
|
||||
msg.writeByte(position.index);
|
||||
msg.writeUuid(sender);
|
||||
}
|
||||
|
||||
public enum Position {
|
||||
|
||||
CHAT(0),
|
||||
SYSTEM_MESSAGE(1),
|
||||
ACTION_BAR(2);
|
||||
|
||||
private final int index;
|
||||
|
||||
Position(int index){
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,31 +17,31 @@ public enum State {
|
||||
HANDSHAKING(0){
|
||||
{
|
||||
serverBound.register(Version.getMinimal(), 0x00, PacketHandshake::new);
|
||||
|
||||
int[] i = new int[16 * 16 * 16];
|
||||
}
|
||||
},
|
||||
STATUS(1){
|
||||
{
|
||||
clientBound.register(Version.getMinimal(), 0x00, PacketStatusResponse::new);
|
||||
clientBound.register(Version.getMinimal(), 0x01, PacketStatusPing::new);
|
||||
serverBound.register(Version.getMinimal(), 0x01, PacketStatusPing::new);
|
||||
serverBound.register(Version.getMinimal(), 0x00, PacketStatusRequest::new);
|
||||
clientBound.register(Version.getMinimal(), 0x00, PacketStatusResponse::new);
|
||||
clientBound.register(Version.getMinimal(), 0x01, PacketStatusPing::new);
|
||||
}
|
||||
},
|
||||
LOGIN(2){
|
||||
{
|
||||
serverBound.register(Version.getMinimal(), 0x00, PacketLoginStart::new);
|
||||
clientBound.register(Version.getMinimal(), 0x00, PacketDisconnect::new);
|
||||
clientBound.register(Version.getMinimal(), 0x02, PacketLoginSuccess::new);
|
||||
serverBound.register(Version.getMinimal(), 0x00, PacketLoginStart::new);
|
||||
}
|
||||
},
|
||||
PLAY(3){
|
||||
{
|
||||
serverBound.register(Version.V1_16_4, 0x10, PacketKeepAlive::new);
|
||||
clientBound.register(Version.V1_16_4, 0x24, PacketJoinGame::new);
|
||||
clientBound.register(Version.V1_16_4, 0x34, PacketPlayerPositionAndLook::new);
|
||||
clientBound.register(Version.V1_16_4, 0x1F, PacketKeepAlive::new);
|
||||
serverBound.register(Version.V1_16_4, 0x10, PacketKeepAlive::new);
|
||||
clientBound.register(Version.V1_16_4, 0x0E, PacketChatMessage::new);
|
||||
clientBound.register(Version.V1_16_4, 0x0C, PacketBossBar::new);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user