diff --git a/pom.xml b/pom.xml index d5a31597..51b72c1e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.steveice10 mcprotocollib - 20w20b-SNAPSHOT + 20w21a-SNAPSHOT jar MCProtocolLib diff --git a/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java b/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java index cc1e40eb..752a53fd 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java +++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java @@ -2,8 +2,8 @@ package com.github.steveice10.mc.protocol; public class MinecraftConstants { // General Constants - public static final String GAME_VERSION = "20w20b"; - public static final int PROTOCOL_VERSION = 717; + public static final String GAME_VERSION = "20w21a"; + public static final int PROTOCOL_VERSION = 718; // General Key Constants public static final String PROFILE_KEY = "profile"; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerChatPacket.java index df4c1b11..f825c4a0 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerChatPacket.java @@ -14,6 +14,7 @@ import lombok.NonNull; import lombok.Setter; import java.io.IOException; +import java.util.UUID; @Data @Setter(AccessLevel.NONE) @@ -22,6 +23,7 @@ import java.io.IOException; public class ServerChatPacket implements Packet { private @NonNull Message message; private @NonNull MessageType type; + private @NonNull UUID senderUuid; public ServerChatPacket(@NonNull String text) { this(Message.fromString(text)); @@ -32,19 +34,29 @@ public class ServerChatPacket implements Packet { } public ServerChatPacket(@NonNull String text, @NonNull MessageType type) { - this(Message.fromString(text), type); + this(Message.fromString(text), type, new UUID(0, 0)); + } + + public ServerChatPacket(@NonNull Message message, @NonNull MessageType type) { + this(message, type, new UUID(0, 0)); + } + + public ServerChatPacket(@NonNull String text, @NonNull MessageType type, UUID uuid) { + this(Message.fromString(text), type, uuid); } @Override public void read(NetInput in) throws IOException { this.message = Message.fromString(in.readString()); this.type = MagicValues.key(MessageType.class, in.readByte()); + this.senderUuid = in.readUUID(); } @Override public void write(NetOutput out) throws IOException { out.writeString(this.message.toJsonString()); out.writeByte(MagicValues.value(Integer.class, this.type)); + out.writeUUID(this.senderUuid); } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java index e251b12c..98a51eed 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerJoinGamePacket.java @@ -1,7 +1,9 @@ package com.github.steveice10.mc.protocol.packet.ingame.server; import com.github.steveice10.mc.protocol.data.MagicValues; +import com.github.steveice10.mc.protocol.data.game.NBT; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -25,7 +27,8 @@ public class ServerJoinGamePacket implements Packet { private int entityId; private boolean hardcore; private @NonNull GameMode gameMode; - private int dimension; + private @NonNull CompoundTag dimensionCodec; + private @NonNull String dimension; private long hashedSeed; private int maxPlayers; private int viewDistance; @@ -41,8 +44,8 @@ public class ServerJoinGamePacket implements Packet { int gameMode = in.readUnsignedByte(); this.hardcore = (gameMode & GAMEMODE_FLAG_HARDCORE) != 0; this.gameMode = MagicValues.key(GameMode.class, gameMode & GAMEMODE_MASK); - - this.dimension = in.readInt(); + this.dimensionCodec = NBT.read(in); + this.dimension = in.readString(); this.hashedSeed = in.readLong(); this.maxPlayers = in.readUnsignedByte(); this.viewDistance = in.readVarInt(); @@ -62,8 +65,8 @@ public class ServerJoinGamePacket implements Packet { } out.writeByte(gameMode); - - out.writeInt(this.dimension); + NBT.write(out, this.dimensionCodec); + out.writeString(this.dimension); out.writeLong(this.hashedSeed); out.writeByte(this.maxPlayers); out.writeVarInt(this.viewDistance); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java index 4b15ab07..9c10d269 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerRespawnPacket.java @@ -19,7 +19,7 @@ import java.io.IOException; @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor public class ServerRespawnPacket implements Packet { - private int dimension; + private String dimension; private long hashedSeed; private @NonNull GameMode gamemode; private boolean debug; @@ -28,7 +28,7 @@ public class ServerRespawnPacket implements Packet { @Override public void read(NetInput in) throws IOException { - this.dimension = in.readInt(); + this.dimension = in.readString(); this.hashedSeed = in.readLong(); this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte()); this.debug = in.readBoolean(); @@ -38,7 +38,7 @@ public class ServerRespawnPacket implements Packet { @Override public void write(NetOutput out) throws IOException { - out.writeInt(this.dimension); + out.writeString(this.dimension); out.writeLong(this.hashedSeed); out.writeByte(MagicValues.value(Integer.class, this.gamemode)); out.writeBoolean(this.debug); diff --git a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java index 8e0f298f..97392696 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -9,6 +9,9 @@ import com.github.steveice10.mc.protocol.data.status.VersionInfo; import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder; import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.ListTag; +import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.packetlib.Client; import com.github.steveice10.packetlib.Server; import com.github.steveice10.packetlib.Session; @@ -44,7 +47,7 @@ public class MinecraftProtocolTest { new TextMessage("Hello world!"), null ); - private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 0, 100, 0, 16, false, false, false, false); + private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, getDimensionTag(), "minecraft:overworld", 100, 0, 16, false, false, false, false); private static Server server; @@ -139,4 +142,15 @@ public class MinecraftProtocolTest { } } } + + private static CompoundTag getDimensionTag() { + CompoundTag tag = new CompoundTag(""); + ListTag dimensionTag = new ListTag("dimension"); + CompoundTag overworldTag = new CompoundTag(""); + overworldTag.put(new StringTag("key", "minecraft:overworld")); + overworldTag.put(new StringTag("element", "minecraft:overworld")); + dimensionTag.add(overworldTag); + tag.put(tag); + return tag; + } }