From 1c57135e6c493bb3b6985e5cd108ba2dcac76068 Mon Sep 17 00:00:00 2001 From: basaigh <53559772+basaigh@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:04:10 +0100 Subject: [PATCH] 1.20.2-pre1 --- .../protocol/test/MinecraftProtocolTest.java | 20 +++++++++++-------- .../mc/protocol/codec/MinecraftCodec.java | 17 ++++++++-------- .../data/game/level/map/MapIconType.java | 9 ++++++++- .../data/game/level/notify/GameEvent.java | 3 ++- .../level/notify/LimitedCraftingValue.java | 12 +++++++++++ .../ServerboundClientInformationPacket.java | 2 +- .../clientbound/ClientboundLoginPacket.java | 3 +++ .../level/ClientboundGameEventPacket.java | 2 ++ .../mc/protocol/MinecraftProtocolTest.java | 3 ++- 9 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/LimitedCraftingValue.java rename src/main/java/com/github/steveice10/mc/protocol/packet/{ingame => common}/serverbound/ServerboundClientInformationPacket.java (97%) diff --git a/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java b/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java index ed91f1dd..a28c03b4 100644 --- a/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java +++ b/example/src/main/java/com/github/steveice10/mc/protocol/test/MinecraftProtocolTest.java @@ -11,6 +11,7 @@ import com.github.steveice10.mc.protocol.ServerLoginHandler; import com.github.steveice10.mc.protocol.codec.MinecraftCodec; import com.github.steveice10.mc.protocol.data.ProtocolState; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; +import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerSpawnInfo; import com.github.steveice10.mc.protocol.data.status.PlayerInfo; import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; import com.github.steveice10.mc.protocol.data.status.VersionInfo; @@ -87,15 +88,18 @@ public class MinecraftProtocolTest { 16, false, false, - "minecraft:overworld", - "minecraft:world", - 100, - GameMode.SURVIVAL, - GameMode.SURVIVAL, false, - false, - null, - 100 + new PlayerSpawnInfo( + "minecraft:overworld", + "minecraft:world", + 100, + GameMode.SURVIVAL, + GameMode.SURVIVAL, + false, + false, + null, + 100 + ) )) ); diff --git a/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodec.java b/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodec.java index ca9156bb..68fb1626 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodec.java +++ b/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodec.java @@ -127,7 +127,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCh import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatSessionUpdatePacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundClientInformationPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket; import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket; import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket; @@ -208,9 +208,9 @@ public class MinecraftCodec { } public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion((1 << 30) | 147) + .protocolVersion((1 << 30) | 148) .helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES)) - .minecraftVersion("23w35a") + .minecraftVersion("1.20.2-pre1") .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) ) @@ -239,11 +239,12 @@ public class MinecraftCodec { .registerClientboundPacket(0x06, ClientboundResourcePackPacket.class, ClientboundResourcePackPacket::new) .registerClientboundPacket(0x07, ClientboundUpdateEnabledFeaturesPacket.class, ClientboundUpdateEnabledFeaturesPacket::new) .registerClientboundPacket(0x08, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new) - .registerServerboundPacket(0x00, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new) - .registerServerboundPacket(0x01, ServerboundFinishConfigurationPacket.class, ServerboundFinishConfigurationPacket::new) - .registerServerboundPacket(0x02, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new) - .registerServerboundPacket(0x03, ServerboundPongPacket.class, ServerboundPongPacket::new) - .registerClientboundPacket(0x04, ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new) + .registerServerboundPacket(0x00, ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new) + .registerServerboundPacket(0x01, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new) + .registerServerboundPacket(0x02, ServerboundFinishConfigurationPacket.class, ServerboundFinishConfigurationPacket::new) + .registerServerboundPacket(0x03, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new) + .registerServerboundPacket(0x04, ServerboundPongPacket.class, ServerboundPongPacket::new) + .registerClientboundPacket(0x05, ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new) ).state(ProtocolState.GAME, PacketStateCodec.builder() .registerClientboundPacket(0x00, ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new) .registerClientboundPacket(0x01, ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapIconType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapIconType.java index 698d0a83..cf60edaf 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapIconType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/map/MapIconType.java @@ -27,7 +27,14 @@ public enum MapIconType { GREEN_BANNER, RED_BANNER, BLACK_BANNER, - TREASURE_MARKER; + TREASURE_MARKER, + DESERT_VILLAGE, + PLAINS_VILLAGE, + SAVANNA_VILLAGE, + SNOWY_VILLAGE, + TAIGA_VILLAGE, + JUNGLE_TEMPLE, + SWAMP_HUT; private static final MapIconType[] VALUES = values(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/GameEvent.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/GameEvent.java index dabdf326..60653ad5 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/GameEvent.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/GameEvent.java @@ -12,7 +12,8 @@ public enum GameEvent { THUNDER_STRENGTH, PUFFERFISH_STING_SOUND, AFFECTED_BY_ELDER_GUARDIAN, - ENABLE_RESPAWN_SCREEN; + ENABLE_RESPAWN_SCREEN, + LIMITED_CRAFTING; private static final GameEvent[] VALUES = values(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/LimitedCraftingValue.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/LimitedCraftingValue.java new file mode 100644 index 00000000..e706873a --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/notify/LimitedCraftingValue.java @@ -0,0 +1,12 @@ +package com.github.steveice10.mc.protocol.data.game.level.notify; + +public enum LimitedCraftingValue implements GameEventValue { + UNLIMITED_CRAFTING, + LIMITED_CRAFTING; + + private static final LimitedCraftingValue[] VALUES = values(); + + public static LimitedCraftingValue from(int id) { + return VALUES[id]; + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientInformationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java similarity index 97% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientInformationPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java index aef313e0..3255fd7c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundClientInformationPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundClientInformationPacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.serverbound; +package com.github.steveice10.mc.protocol.packet.common.serverbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java index bc9a41ba..e3d05bc8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java @@ -27,6 +27,7 @@ public class ClientboundLoginPacket implements MinecraftPacket { private final int simulationDistance; private final boolean reducedDebugInfo; private final boolean enableRespawnScreen; + private final boolean doLimitedCrafting; private final PlayerSpawnInfo commonPlayerSpawnInfo; public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { @@ -42,6 +43,7 @@ public class ClientboundLoginPacket implements MinecraftPacket { this.simulationDistance = helper.readVarInt(in); this.reducedDebugInfo = in.readBoolean(); this.enableRespawnScreen = in.readBoolean(); + this.doLimitedCrafting = in.readBoolean(); this.commonPlayerSpawnInfo = helper.readPlayerSpawnInfo(in); } @@ -58,6 +60,7 @@ public class ClientboundLoginPacket implements MinecraftPacket { helper.writeVarInt(out, this.simulationDistance); out.writeBoolean(this.reducedDebugInfo); out.writeBoolean(this.enableRespawnScreen); + out.writeBoolean(this.doLimitedCrafting); helper.writePlayerSpawnInfo(out, this.commonPlayerSpawnInfo); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundGameEventPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundGameEventPacket.java index abb059b8..35001442 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundGameEventPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundGameEventPacket.java @@ -31,6 +31,8 @@ public class ClientboundGameEventPacket implements MinecraftPacket { this.value = EnterCreditsValue.from((int) value); } else if (this.notification == GameEvent.ENABLE_RESPAWN_SCREEN) { this.value = RespawnScreenValue.from((int) value); + } else if (this.notification == GameEvent.LIMITED_CRAFTING) { + this.value = LimitedCraftingValue.from((int) value); } else if (this.notification == GameEvent.RAIN_STRENGTH) { this.value = new RainStrengthValue(value); } else if (this.notification == GameEvent.THUNDER_STRENGTH) { 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 e8d8eb68..d10abc93 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -2,6 +2,7 @@ package com.github.steveice10.mc.protocol; import com.github.steveice10.mc.protocol.codec.MinecraftCodec; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; +import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerSpawnInfo; import com.github.steveice10.mc.protocol.data.status.PlayerInfo; import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; import com.github.steveice10.mc.protocol.data.status.VersionInfo; @@ -51,7 +52,7 @@ public class MinecraftProtocolTest { null, false ); - private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, new String[]{"minecraft:world"}, 0, 16, 16, false, false, "overworld", "minecraft:world", 100, GameMode.SURVIVAL, GameMode.SURVIVAL, false, false, null, 100); + private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, new String[]{"minecraft:world"}, 0, 16, 16, false, false, false, new PlayerSpawnInfo("overworld", "minecraft:world", 100, GameMode.SURVIVAL, GameMode.SURVIVAL, false, false, null, 100)); private static Server server;