diff --git a/pom.xml b/pom.xml index d24c4ce08..8fbb78a10 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.steveice10 mcprotocollib - 1.20-1 + 1.20.2-SNAPSHOT jar MCProtocolLib diff --git a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java index 48b85d8f1..f9fdee834 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java @@ -11,10 +11,12 @@ import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler; import com.github.steveice10.mc.protocol.data.status.handler.ServerPingTimeHandler; +import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundFinishConfigurationPacket; import com.github.steveice10.mc.protocol.packet.handshake.serverbound.ClientIntentionPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisconnectPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundDisconnectPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundStartConfigurationPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundHelloPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginCompressionPacket; @@ -35,7 +37,6 @@ import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import java.security.NoSuchAlgorithmException; -import java.util.UUID; /** * Handles making initial login and status requests for clients. @@ -84,7 +85,7 @@ public void packetReceived(Session session, Packet packet) { session.send(new ServerboundKeyPacket(helloPacket.getPublicKey(), key, helloPacket.getChallenge())); session.enableEncryption(protocol.enableEncryption(key)); } else if (packet instanceof ClientboundGameProfilePacket) { - protocol.setState(ProtocolState.GAME); + protocol.setState(ProtocolState.CONFIGURATION); } else if (packet instanceof ClientboundLoginDisconnectPacket) { session.disconnect(((ClientboundLoginDisconnectPacket) packet).getReason()); } else if (packet instanceof ClientboundLoginCompressionPacket) { @@ -113,6 +114,12 @@ public void packetReceived(Session session, Packet packet) { session.send(new ServerboundKeepAlivePacket(((ClientboundKeepAlivePacket) packet).getPingId())); } else if (packet instanceof ClientboundDisconnectPacket) { session.disconnect(((ClientboundDisconnectPacket) packet).getReason()); + } else if (packet instanceof ClientboundStartConfigurationPacket) { + protocol.setState(ProtocolState.CONFIGURATION); + } + } else if (protocol.getState() == ProtocolState.CONFIGURATION) { + if (packet instanceof ClientboundFinishConfigurationPacket) { + protocol.setState(ProtocolState.GAME); } } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java b/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java index 9adaab0b6..d24e64ee9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java @@ -8,10 +8,13 @@ import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo; 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.packet.configuration.clientbound.ClientboundFinishConfigurationPacket; +import com.github.steveice10.mc.protocol.packet.configuration.serverbound.ServerboundFinishConfigurationPacket; import com.github.steveice10.mc.protocol.packet.handshake.serverbound.ClientIntentionPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisconnectPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundDisconnectPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundConfigurationAcknowledgedPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundHelloPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginCompressionPacket; @@ -97,9 +100,7 @@ public void packetReceived(Session session, Packet packet) { throw new UnsupportedOperationException("Invalid client intent: " + intentionPacket.getIntent()); } } - } - - if (protocol.getState() == ProtocolState.LOGIN) { + } else if (protocol.getState() == ProtocolState.LOGIN) { if (packet instanceof ServerboundHelloPacket) { this.username = ((ServerboundHelloPacket) packet).getUsername(); @@ -121,9 +122,7 @@ public void packetReceived(Session session, Packet packet) { session.enableEncryption(protocol.enableEncryption(key)); new Thread(new UserAuthTask(session, key)).start(); } - } - - if (protocol.getState() == ProtocolState.STATUS) { + } else if (protocol.getState() == ProtocolState.STATUS) { if (packet instanceof ServerboundStatusRequestPacket) { ServerInfoBuilder builder = session.getFlag(MinecraftConstants.SERVER_INFO_BUILDER_KEY); if (builder == null) { @@ -141,14 +140,18 @@ public void packetReceived(Session session, Packet packet) { } else if (packet instanceof ServerboundPingRequestPacket) { session.send(new ClientboundPongResponsePacket(((ServerboundPingRequestPacket) packet).getPingTime())); } - } - - if (protocol.getState() == ProtocolState.GAME) { + } else if (protocol.getState() == ProtocolState.GAME) { if (packet instanceof ServerboundKeepAlivePacket) { if (((ServerboundKeepAlivePacket) packet).getPingId() == this.lastPingId) { long time = System.currentTimeMillis() - this.lastPingTime; session.setFlag(MinecraftConstants.PING_KEY, time); } + } else if (packet instanceof ServerboundConfigurationAcknowledgedPacket) { + protocol.setState(ProtocolState.CONFIGURATION); + } + } else if (protocol.getState() == ProtocolState.CONFIGURATION) { + if (packet instanceof ServerboundFinishConfigurationPacket) { + protocol.setState(ProtocolState.GAME); } } } 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 4628b85df..9dc5791ac 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 @@ -3,6 +3,10 @@ import com.github.steveice10.mc.protocol.data.ProtocolState; import com.github.steveice10.mc.protocol.data.game.level.event.LevelEventType; import com.github.steveice10.mc.protocol.data.game.level.sound.BuiltinSound; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket; +import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundFinishConfigurationPacket; +import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket; +import com.github.steveice10.mc.protocol.packet.configuration.serverbound.ServerboundFinishConfigurationPacket; import com.github.steveice10.mc.protocol.packet.handshake.serverbound.ClientIntentionPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundAwardStatsPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundBossEventPacket; @@ -11,31 +15,31 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandsPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCooldownPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomChatCompletionsPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDeleteChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDelimiterPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisconnectPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundDisconnectPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundKeepAlivePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPingPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundPingPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoRemovePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRecipePacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundResourcePackPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundResourcePackPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRespawnPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSelectAdvancementsTabPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundServerDataPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSetCameraPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSoundEntityPacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundStartConfigurationPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundStopSoundPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundTabListPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateAdvancementsPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateEnabledFeaturesPacket; +import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundUpdateEnabledFeaturesPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateTagsPacket; +import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundUpdateTagsPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundDamageEventPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket; @@ -82,6 +86,8 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEntityDataPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEventPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundChunkBatchFinishedPacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundChunkBatchStartPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundChunksBiomesPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundExplodePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundForgetLevelChunkPacket; @@ -123,11 +129,12 @@ 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.ingame.serverbound.ServerboundCommandSuggestionPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundKeepAlivePacket; +import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundConfigurationAcknowledgedPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundLockDifficultyPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundPongPacket; -import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundResourcePackPacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundPongPacket; +import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundResourcePackPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerButtonClickPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClickPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket; @@ -147,6 +154,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetStructureBlockPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundBlockEntityTagQuery; +import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundChunkBatchReceivedPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundEntityTagQuery; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundJigsawGeneratePacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundMoveVehiclePacket; @@ -171,9 +179,10 @@ import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundHelloPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginCompressionPacket; import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginDisconnectPacket; -import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundCustomQueryPacket; +import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundCustomQueryAnswerPacket; import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundHelloPacket; import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundKeyPacket; +import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundLoginAcknowledgedPacket; import com.github.steveice10.mc.protocol.packet.status.clientbound.ClientboundPongResponsePacket; import com.github.steveice10.mc.protocol.packet.status.clientbound.ClientboundStatusResponsePacket; import com.github.steveice10.mc.protocol.packet.status.serverbound.ServerboundPingRequestPacket; @@ -199,9 +208,9 @@ public class MinecraftCodec { } public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion(763) + .protocolVersion((1 << 30) | 144) .helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES)) - .minecraftVersion("1.20") + .minecraftVersion("23w31a") .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) ) @@ -213,12 +222,28 @@ public class MinecraftCodec { .registerClientboundPacket(0x04, ClientboundCustomQueryPacket.class, ClientboundCustomQueryPacket::new) .registerServerboundPacket(0x00, ServerboundHelloPacket.class, ServerboundHelloPacket::new) .registerServerboundPacket(0x01, ServerboundKeyPacket.class, ServerboundKeyPacket::new) - .registerServerboundPacket(0x02, ServerboundCustomQueryPacket.class, ServerboundCustomQueryPacket::new) + .registerServerboundPacket(0x02, ServerboundCustomQueryAnswerPacket.class, ServerboundCustomQueryAnswerPacket::new) + .registerServerboundPacket(0x03, ServerboundLoginAcknowledgedPacket.class, ServerboundLoginAcknowledgedPacket::new) ).state(ProtocolState.STATUS, PacketStateCodec.builder() .registerClientboundPacket(0x00, ClientboundStatusResponsePacket.class, ClientboundStatusResponsePacket::new) .registerClientboundPacket(0x01, ClientboundPongResponsePacket.class, ClientboundPongResponsePacket::new) .registerServerboundPacket(0x00, ServerboundStatusRequestPacket.class, ServerboundStatusRequestPacket::new) .registerServerboundPacket(0x01, ServerboundPingRequestPacket.class, ServerboundPingRequestPacket::new) + ).state(ProtocolState.CONFIGURATION, PacketStateCodec.builder() + .registerClientboundPacket(0x00, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new) + .registerClientboundPacket(0x01, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new) + .registerClientboundPacket(0x02, ClientboundFinishConfigurationPacket.class, ClientboundFinishConfigurationPacket::new) + .registerClientboundPacket(0x03, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new) + .registerClientboundPacket(0x04, ClientboundPingPacket.class, ClientboundPingPacket::new) + .registerClientboundPacket(0x05, ClientboundRegistryDataPacket.class, ClientboundRegistryDataPacket::new) + .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) ).state(ProtocolState.GAME, PacketStateCodec.builder() .registerClientboundPacket(0x00, ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new) .registerClientboundPacket(0x01, ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new) @@ -233,104 +258,106 @@ public class MinecraftCodec { .registerClientboundPacket(0x0A, ClientboundBlockUpdatePacket.class, ClientboundBlockUpdatePacket::new) .registerClientboundPacket(0x0B, ClientboundBossEventPacket.class, ClientboundBossEventPacket::new) .registerClientboundPacket(0x0C, ClientboundChangeDifficultyPacket.class, ClientboundChangeDifficultyPacket::new) - .registerClientboundPacket(0x0D, ClientboundChunksBiomesPacket.class, ClientboundChunksBiomesPacket::new) - .registerClientboundPacket(0x0E, ClientboundClearTitlesPacket.class, ClientboundClearTitlesPacket::new) - .registerClientboundPacket(0x0F, ClientboundCommandSuggestionsPacket.class, ClientboundCommandSuggestionsPacket::new) - .registerClientboundPacket(0x10, ClientboundCommandsPacket.class, ClientboundCommandsPacket::new) - .registerClientboundPacket(0x11, ClientboundContainerClosePacket.class, ClientboundContainerClosePacket::new) - .registerClientboundPacket(0x12, ClientboundContainerSetContentPacket.class, ClientboundContainerSetContentPacket::new) - .registerClientboundPacket(0x13, ClientboundContainerSetDataPacket.class, ClientboundContainerSetDataPacket::new) - .registerClientboundPacket(0x14, ClientboundContainerSetSlotPacket.class, ClientboundContainerSetSlotPacket::new) - .registerClientboundPacket(0x15, ClientboundCooldownPacket.class, ClientboundCooldownPacket::new) - .registerClientboundPacket(0x16, ClientboundCustomChatCompletionsPacket.class, ClientboundCustomChatCompletionsPacket::new) - .registerClientboundPacket(0x17, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new) - .registerClientboundPacket(0x18, ClientboundDamageEventPacket.class, ClientboundDamageEventPacket::new) - .registerClientboundPacket(0x19, ClientboundDeleteChatPacket.class, ClientboundDeleteChatPacket::new) - .registerClientboundPacket(0x1A, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new) - .registerClientboundPacket(0x1B, ClientboundDisguisedChatPacket.class, ClientboundDisguisedChatPacket::new) - .registerClientboundPacket(0x1C, ClientboundEntityEventPacket.class, ClientboundEntityEventPacket::new) - .registerClientboundPacket(0x1D, ClientboundExplodePacket.class, ClientboundExplodePacket::new) - .registerClientboundPacket(0x1E, ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new) - .registerClientboundPacket(0x1F, ClientboundGameEventPacket.class, ClientboundGameEventPacket::new) - .registerClientboundPacket(0x20, ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new) - .registerClientboundPacket(0x21, ClientboundHurtAnimationPacket.class, ClientboundHurtAnimationPacket::new) - .registerClientboundPacket(0x22, ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new) - .registerClientboundPacket(0x23, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new) - .registerClientboundPacket(0x24, ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkWithLightPacket::new) - .registerClientboundPacket(0x25, ClientboundLevelEventPacket.class, ClientboundLevelEventPacket::new) - .registerClientboundPacket(0x26, ClientboundLevelParticlesPacket.class, ClientboundLevelParticlesPacket::new) - .registerClientboundPacket(0x27, ClientboundLightUpdatePacket.class, ClientboundLightUpdatePacket::new) - .registerClientboundPacket(0x28, ClientboundLoginPacket.class, ClientboundLoginPacket::new) - .registerClientboundPacket(0x29, ClientboundMapItemDataPacket.class, ClientboundMapItemDataPacket::new) - .registerClientboundPacket(0x2A, ClientboundMerchantOffersPacket.class, ClientboundMerchantOffersPacket::new) - .registerClientboundPacket(0x2B, ClientboundMoveEntityPosPacket.class, ClientboundMoveEntityPosPacket::new) - .registerClientboundPacket(0x2C, ClientboundMoveEntityPosRotPacket.class, ClientboundMoveEntityPosRotPacket::new) - .registerClientboundPacket(0x2D, ClientboundMoveEntityRotPacket.class, ClientboundMoveEntityRotPacket::new) - .registerClientboundPacket(0x2E, ClientboundMoveVehiclePacket.class, ClientboundMoveVehiclePacket::new) - .registerClientboundPacket(0x2F, ClientboundOpenBookPacket.class, ClientboundOpenBookPacket::new) - .registerClientboundPacket(0x30, ClientboundOpenScreenPacket.class, ClientboundOpenScreenPacket::new) - .registerClientboundPacket(0x31, ClientboundOpenSignEditorPacket.class, ClientboundOpenSignEditorPacket::new) - .registerClientboundPacket(0x32, ClientboundPingPacket.class, ClientboundPingPacket::new) - .registerClientboundPacket(0x33, ClientboundPlaceGhostRecipePacket.class, ClientboundPlaceGhostRecipePacket::new) - .registerClientboundPacket(0x34, ClientboundPlayerAbilitiesPacket.class, ClientboundPlayerAbilitiesPacket::new) - .registerClientboundPacket(0x35, ClientboundPlayerChatPacket.class, ClientboundPlayerChatPacket::new) - .registerClientboundPacket(0x36, ClientboundPlayerCombatEndPacket.class, ClientboundPlayerCombatEndPacket::new) - .registerClientboundPacket(0x37, ClientboundPlayerCombatEnterPacket.class, ClientboundPlayerCombatEnterPacket::new) - .registerClientboundPacket(0x38, ClientboundPlayerCombatKillPacket.class, ClientboundPlayerCombatKillPacket::new) - .registerClientboundPacket(0x39, ClientboundPlayerInfoRemovePacket.class, ClientboundPlayerInfoRemovePacket::new) - .registerClientboundPacket(0x3A, ClientboundPlayerInfoUpdatePacket.class, ClientboundPlayerInfoUpdatePacket::new) - .registerClientboundPacket(0x3B, ClientboundPlayerLookAtPacket.class, ClientboundPlayerLookAtPacket::new) - .registerClientboundPacket(0x3C, ClientboundPlayerPositionPacket.class, ClientboundPlayerPositionPacket::new) - .registerClientboundPacket(0x3D, ClientboundRecipePacket.class, ClientboundRecipePacket::new) - .registerClientboundPacket(0x3E, ClientboundRemoveEntitiesPacket.class, ClientboundRemoveEntitiesPacket::new) - .registerClientboundPacket(0x3F, ClientboundRemoveMobEffectPacket.class, ClientboundRemoveMobEffectPacket::new) - .registerClientboundPacket(0x40, ClientboundResourcePackPacket.class, ClientboundResourcePackPacket::new) - .registerClientboundPacket(0x41, ClientboundRespawnPacket.class, ClientboundRespawnPacket::new) - .registerClientboundPacket(0x42, ClientboundRotateHeadPacket.class, ClientboundRotateHeadPacket::new) - .registerClientboundPacket(0x43, ClientboundSectionBlocksUpdatePacket.class, ClientboundSectionBlocksUpdatePacket::new) - .registerClientboundPacket(0x44, ClientboundSelectAdvancementsTabPacket.class, ClientboundSelectAdvancementsTabPacket::new) - .registerClientboundPacket(0x45, ClientboundServerDataPacket.class, ClientboundServerDataPacket::new) - .registerClientboundPacket(0x46, ClientboundSetActionBarTextPacket.class, ClientboundSetActionBarTextPacket::new) - .registerClientboundPacket(0x47, ClientboundSetBorderCenterPacket.class, ClientboundSetBorderCenterPacket::new) - .registerClientboundPacket(0x48, ClientboundSetBorderLerpSizePacket.class, ClientboundSetBorderLerpSizePacket::new) - .registerClientboundPacket(0x49, ClientboundSetBorderSizePacket.class, ClientboundSetBorderSizePacket::new) - .registerClientboundPacket(0x4A, ClientboundSetBorderWarningDelayPacket.class, ClientboundSetBorderWarningDelayPacket::new) - .registerClientboundPacket(0x4B, ClientboundSetBorderWarningDistancePacket.class, ClientboundSetBorderWarningDistancePacket::new) - .registerClientboundPacket(0x4C, ClientboundSetCameraPacket.class, ClientboundSetCameraPacket::new) - .registerClientboundPacket(0x4D, ClientboundSetCarriedItemPacket.class, ClientboundSetCarriedItemPacket::new) - .registerClientboundPacket(0x4E, ClientboundSetChunkCacheCenterPacket.class, ClientboundSetChunkCacheCenterPacket::new) - .registerClientboundPacket(0x4F, ClientboundSetChunkCacheRadiusPacket.class, ClientboundSetChunkCacheRadiusPacket::new) - .registerClientboundPacket(0x50, ClientboundSetDefaultSpawnPositionPacket.class, ClientboundSetDefaultSpawnPositionPacket::new) - .registerClientboundPacket(0x51, ClientboundSetDisplayObjectivePacket.class, ClientboundSetDisplayObjectivePacket::new) - .registerClientboundPacket(0x52, ClientboundSetEntityDataPacket.class, ClientboundSetEntityDataPacket::new) - .registerClientboundPacket(0x53, ClientboundSetEntityLinkPacket.class, ClientboundSetEntityLinkPacket::new) - .registerClientboundPacket(0x54, ClientboundSetEntityMotionPacket.class, ClientboundSetEntityMotionPacket::new) - .registerClientboundPacket(0x55, ClientboundSetEquipmentPacket.class, ClientboundSetEquipmentPacket::new) - .registerClientboundPacket(0x56, ClientboundSetExperiencePacket.class, ClientboundSetExperiencePacket::new) - .registerClientboundPacket(0x57, ClientboundSetHealthPacket.class, ClientboundSetHealthPacket::new) - .registerClientboundPacket(0x58, ClientboundSetObjectivePacket.class, ClientboundSetObjectivePacket::new) - .registerClientboundPacket(0x59, ClientboundSetPassengersPacket.class, ClientboundSetPassengersPacket::new) - .registerClientboundPacket(0x5A, ClientboundSetPlayerTeamPacket.class, ClientboundSetPlayerTeamPacket::new) - .registerClientboundPacket(0x5B, ClientboundSetScorePacket.class, ClientboundSetScorePacket::new) - .registerClientboundPacket(0x5C, ClientboundSetSimulationDistancePacket.class, ClientboundSetSimulationDistancePacket::new) - .registerClientboundPacket(0x5D, ClientboundSetSubtitleTextPacket.class, ClientboundSetSubtitleTextPacket::new) - .registerClientboundPacket(0x5E, ClientboundSetTimePacket.class, ClientboundSetTimePacket::new) - .registerClientboundPacket(0x5F, ClientboundSetTitleTextPacket.class, ClientboundSetTitleTextPacket::new) - .registerClientboundPacket(0x60, ClientboundSetTitlesAnimationPacket.class, ClientboundSetTitlesAnimationPacket::new) - .registerClientboundPacket(0x61, ClientboundSoundEntityPacket.class, ClientboundSoundEntityPacket::new) - .registerClientboundPacket(0x62, ClientboundSoundPacket.class, ClientboundSoundPacket::new) - .registerClientboundPacket(0x63, ClientboundStopSoundPacket.class, ClientboundStopSoundPacket::new) - .registerClientboundPacket(0x64, ClientboundSystemChatPacket.class, ClientboundSystemChatPacket::new) - .registerClientboundPacket(0x65, ClientboundTabListPacket.class, ClientboundTabListPacket::new) - .registerClientboundPacket(0x66, ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new) - .registerClientboundPacket(0x67, ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new) - .registerClientboundPacket(0x68, ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new) - .registerClientboundPacket(0x69, ClientboundUpdateAdvancementsPacket.class, ClientboundUpdateAdvancementsPacket::new) - .registerClientboundPacket(0x6A, ClientboundUpdateAttributesPacket.class, ClientboundUpdateAttributesPacket::new) - .registerClientboundPacket(0x6B, ClientboundUpdateEnabledFeaturesPacket.class, ClientboundUpdateEnabledFeaturesPacket::new) - .registerClientboundPacket(0x6C, ClientboundUpdateMobEffectPacket.class, ClientboundUpdateMobEffectPacket::new) - .registerClientboundPacket(0x6D, ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new) - .registerClientboundPacket(0x6E, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new) + .registerClientboundPacket(0x0D, ClientboundChunkBatchFinishedPacket.class, ClientboundChunkBatchFinishedPacket::new) + .registerClientboundPacket(0x0E, ClientboundChunkBatchStartPacket.class, ClientboundChunkBatchStartPacket::new) + .registerClientboundPacket(0x0F, ClientboundChunksBiomesPacket.class, ClientboundChunksBiomesPacket::new) + .registerClientboundPacket(0x10, ClientboundClearTitlesPacket.class, ClientboundClearTitlesPacket::new) + .registerClientboundPacket(0x11, ClientboundCommandSuggestionsPacket.class, ClientboundCommandSuggestionsPacket::new) + .registerClientboundPacket(0x12, ClientboundCommandsPacket.class, ClientboundCommandsPacket::new) + .registerClientboundPacket(0x13, ClientboundContainerClosePacket.class, ClientboundContainerClosePacket::new) + .registerClientboundPacket(0x14, ClientboundContainerSetContentPacket.class, ClientboundContainerSetContentPacket::new) + .registerClientboundPacket(0x15, ClientboundContainerSetDataPacket.class, ClientboundContainerSetDataPacket::new) + .registerClientboundPacket(0x16, ClientboundContainerSetSlotPacket.class, ClientboundContainerSetSlotPacket::new) + .registerClientboundPacket(0x17, ClientboundCooldownPacket.class, ClientboundCooldownPacket::new) + .registerClientboundPacket(0x18, ClientboundCustomChatCompletionsPacket.class, ClientboundCustomChatCompletionsPacket::new) + .registerClientboundPacket(0x19, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new) + .registerClientboundPacket(0x1A, ClientboundDamageEventPacket.class, ClientboundDamageEventPacket::new) + .registerClientboundPacket(0x1B, ClientboundDeleteChatPacket.class, ClientboundDeleteChatPacket::new) + .registerClientboundPacket(0x1C, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new) + .registerClientboundPacket(0x1D, ClientboundDisguisedChatPacket.class, ClientboundDisguisedChatPacket::new) + .registerClientboundPacket(0x1E, ClientboundEntityEventPacket.class, ClientboundEntityEventPacket::new) + .registerClientboundPacket(0x1F, ClientboundExplodePacket.class, ClientboundExplodePacket::new) + .registerClientboundPacket(0x20, ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new) + .registerClientboundPacket(0x21, ClientboundGameEventPacket.class, ClientboundGameEventPacket::new) + .registerClientboundPacket(0x22, ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new) + .registerClientboundPacket(0x23, ClientboundHurtAnimationPacket.class, ClientboundHurtAnimationPacket::new) + .registerClientboundPacket(0x24, ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new) + .registerClientboundPacket(0x25, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new) + .registerClientboundPacket(0x26, ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkWithLightPacket::new) + .registerClientboundPacket(0x27, ClientboundLevelEventPacket.class, ClientboundLevelEventPacket::new) + .registerClientboundPacket(0x28, ClientboundLevelParticlesPacket.class, ClientboundLevelParticlesPacket::new) + .registerClientboundPacket(0x29, ClientboundLightUpdatePacket.class, ClientboundLightUpdatePacket::new) + .registerClientboundPacket(0x2A, ClientboundLoginPacket.class, ClientboundLoginPacket::new) + .registerClientboundPacket(0x2B, ClientboundMapItemDataPacket.class, ClientboundMapItemDataPacket::new) + .registerClientboundPacket(0x2C, ClientboundMerchantOffersPacket.class, ClientboundMerchantOffersPacket::new) + .registerClientboundPacket(0x2D, ClientboundMoveEntityPosPacket.class, ClientboundMoveEntityPosPacket::new) + .registerClientboundPacket(0x2E, ClientboundMoveEntityPosRotPacket.class, ClientboundMoveEntityPosRotPacket::new) + .registerClientboundPacket(0x2F, ClientboundMoveEntityRotPacket.class, ClientboundMoveEntityRotPacket::new) + .registerClientboundPacket(0x30, ClientboundMoveVehiclePacket.class, ClientboundMoveVehiclePacket::new) + .registerClientboundPacket(0x31, ClientboundOpenBookPacket.class, ClientboundOpenBookPacket::new) + .registerClientboundPacket(0x32, ClientboundOpenScreenPacket.class, ClientboundOpenScreenPacket::new) + .registerClientboundPacket(0x33, ClientboundOpenSignEditorPacket.class, ClientboundOpenSignEditorPacket::new) + .registerClientboundPacket(0x34, ClientboundPingPacket.class, ClientboundPingPacket::new) + .registerClientboundPacket(0x35, ClientboundPlaceGhostRecipePacket.class, ClientboundPlaceGhostRecipePacket::new) + .registerClientboundPacket(0x36, ClientboundPlayerAbilitiesPacket.class, ClientboundPlayerAbilitiesPacket::new) + .registerClientboundPacket(0x37, ClientboundPlayerChatPacket.class, ClientboundPlayerChatPacket::new) + .registerClientboundPacket(0x38, ClientboundPlayerCombatEndPacket.class, ClientboundPlayerCombatEndPacket::new) + .registerClientboundPacket(0x39, ClientboundPlayerCombatEnterPacket.class, ClientboundPlayerCombatEnterPacket::new) + .registerClientboundPacket(0x3A, ClientboundPlayerCombatKillPacket.class, ClientboundPlayerCombatKillPacket::new) + .registerClientboundPacket(0x3B, ClientboundPlayerInfoRemovePacket.class, ClientboundPlayerInfoRemovePacket::new) + .registerClientboundPacket(0x3C, ClientboundPlayerInfoUpdatePacket.class, ClientboundPlayerInfoUpdatePacket::new) + .registerClientboundPacket(0x3D, ClientboundPlayerLookAtPacket.class, ClientboundPlayerLookAtPacket::new) + .registerClientboundPacket(0x3E, ClientboundPlayerPositionPacket.class, ClientboundPlayerPositionPacket::new) + .registerClientboundPacket(0x3F, ClientboundRecipePacket.class, ClientboundRecipePacket::new) + .registerClientboundPacket(0x40, ClientboundRemoveEntitiesPacket.class, ClientboundRemoveEntitiesPacket::new) + .registerClientboundPacket(0x41, ClientboundRemoveMobEffectPacket.class, ClientboundRemoveMobEffectPacket::new) + .registerClientboundPacket(0x42, ClientboundResourcePackPacket.class, ClientboundResourcePackPacket::new) + .registerClientboundPacket(0x43, ClientboundRespawnPacket.class, ClientboundRespawnPacket::new) + .registerClientboundPacket(0x44, ClientboundRotateHeadPacket.class, ClientboundRotateHeadPacket::new) + .registerClientboundPacket(0x45, ClientboundSectionBlocksUpdatePacket.class, ClientboundSectionBlocksUpdatePacket::new) + .registerClientboundPacket(0x46, ClientboundSelectAdvancementsTabPacket.class, ClientboundSelectAdvancementsTabPacket::new) + .registerClientboundPacket(0x47, ClientboundServerDataPacket.class, ClientboundServerDataPacket::new) + .registerClientboundPacket(0x48, ClientboundSetActionBarTextPacket.class, ClientboundSetActionBarTextPacket::new) + .registerClientboundPacket(0x49, ClientboundSetBorderCenterPacket.class, ClientboundSetBorderCenterPacket::new) + .registerClientboundPacket(0x4A, ClientboundSetBorderLerpSizePacket.class, ClientboundSetBorderLerpSizePacket::new) + .registerClientboundPacket(0x4B, ClientboundSetBorderSizePacket.class, ClientboundSetBorderSizePacket::new) + .registerClientboundPacket(0x4C, ClientboundSetBorderWarningDelayPacket.class, ClientboundSetBorderWarningDelayPacket::new) + .registerClientboundPacket(0x4D, ClientboundSetBorderWarningDistancePacket.class, ClientboundSetBorderWarningDistancePacket::new) + .registerClientboundPacket(0x4E, ClientboundSetCameraPacket.class, ClientboundSetCameraPacket::new) + .registerClientboundPacket(0x4F, ClientboundSetCarriedItemPacket.class, ClientboundSetCarriedItemPacket::new) + .registerClientboundPacket(0x50, ClientboundSetChunkCacheCenterPacket.class, ClientboundSetChunkCacheCenterPacket::new) + .registerClientboundPacket(0x51, ClientboundSetChunkCacheRadiusPacket.class, ClientboundSetChunkCacheRadiusPacket::new) + .registerClientboundPacket(0x52, ClientboundSetDefaultSpawnPositionPacket.class, ClientboundSetDefaultSpawnPositionPacket::new) + .registerClientboundPacket(0x53, ClientboundSetDisplayObjectivePacket.class, ClientboundSetDisplayObjectivePacket::new) + .registerClientboundPacket(0x54, ClientboundSetEntityDataPacket.class, ClientboundSetEntityDataPacket::new) + .registerClientboundPacket(0x55, ClientboundSetEntityLinkPacket.class, ClientboundSetEntityLinkPacket::new) + .registerClientboundPacket(0x56, ClientboundSetEntityMotionPacket.class, ClientboundSetEntityMotionPacket::new) + .registerClientboundPacket(0x57, ClientboundSetEquipmentPacket.class, ClientboundSetEquipmentPacket::new) + .registerClientboundPacket(0x58, ClientboundSetExperiencePacket.class, ClientboundSetExperiencePacket::new) + .registerClientboundPacket(0x59, ClientboundSetHealthPacket.class, ClientboundSetHealthPacket::new) + .registerClientboundPacket(0x5A, ClientboundSetObjectivePacket.class, ClientboundSetObjectivePacket::new) + .registerClientboundPacket(0x5B, ClientboundSetPassengersPacket.class, ClientboundSetPassengersPacket::new) + .registerClientboundPacket(0x5C, ClientboundSetPlayerTeamPacket.class, ClientboundSetPlayerTeamPacket::new) + .registerClientboundPacket(0x5D, ClientboundSetScorePacket.class, ClientboundSetScorePacket::new) + .registerClientboundPacket(0x5E, ClientboundSetSimulationDistancePacket.class, ClientboundSetSimulationDistancePacket::new) + .registerClientboundPacket(0x5F, ClientboundSetSubtitleTextPacket.class, ClientboundSetSubtitleTextPacket::new) + .registerClientboundPacket(0x60, ClientboundSetTimePacket.class, ClientboundSetTimePacket::new) + .registerClientboundPacket(0x61, ClientboundSetTitleTextPacket.class, ClientboundSetTitleTextPacket::new) + .registerClientboundPacket(0x62, ClientboundSetTitlesAnimationPacket.class, ClientboundSetTitlesAnimationPacket::new) + .registerClientboundPacket(0x63, ClientboundSoundEntityPacket.class, ClientboundSoundEntityPacket::new) + .registerClientboundPacket(0x64, ClientboundSoundPacket.class, ClientboundSoundPacket::new) + .registerClientboundPacket(0x65, ClientboundStartConfigurationPacket.class, ClientboundStartConfigurationPacket::new) + .registerClientboundPacket(0x66, ClientboundStopSoundPacket.class, ClientboundStopSoundPacket::new) + .registerClientboundPacket(0x67, ClientboundSystemChatPacket.class, ClientboundSystemChatPacket::new) + .registerClientboundPacket(0x68, ClientboundTabListPacket.class, ClientboundTabListPacket::new) + .registerClientboundPacket(0x69, ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new) + .registerClientboundPacket(0x6A, ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new) + .registerClientboundPacket(0x6B, ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new) + .registerClientboundPacket(0x6C, ClientboundUpdateAdvancementsPacket.class, ClientboundUpdateAdvancementsPacket::new) + .registerClientboundPacket(0x6D, ClientboundUpdateAttributesPacket.class, ClientboundUpdateAttributesPacket::new) + .registerClientboundPacket(0x6E, ClientboundUpdateMobEffectPacket.class, ClientboundUpdateMobEffectPacket::new) + .registerClientboundPacket(0x6F, ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new) + .registerClientboundPacket(0x70, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new) .registerServerboundPacket(0x00, ServerboundAcceptTeleportationPacket.class, ServerboundAcceptTeleportationPacket::new) .registerServerboundPacket(0x01, ServerboundBlockEntityTagQuery.class, ServerboundBlockEntityTagQuery::new) .registerServerboundPacket(0x02, ServerboundChangeDifficultyPacket.class, ServerboundChangeDifficultyPacket::new) @@ -338,50 +365,52 @@ public class MinecraftCodec { .registerServerboundPacket(0x04, ServerboundChatCommandPacket.class, ServerboundChatCommandPacket::new) .registerServerboundPacket(0x05, ServerboundChatPacket.class, ServerboundChatPacket::new) .registerServerboundPacket(0x06, ServerboundChatSessionUpdatePacket.class, ServerboundChatSessionUpdatePacket::new) - .registerServerboundPacket(0x07, ServerboundClientCommandPacket.class, ServerboundClientCommandPacket::new) - .registerServerboundPacket(0x08, ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new) - .registerServerboundPacket(0x09, ServerboundCommandSuggestionPacket.class, ServerboundCommandSuggestionPacket::new) - .registerServerboundPacket(0x0A, ServerboundContainerButtonClickPacket.class, ServerboundContainerButtonClickPacket::new) - .registerServerboundPacket(0x0B, ServerboundContainerClickPacket.class, ServerboundContainerClickPacket::new) - .registerServerboundPacket(0x0C, ServerboundContainerClosePacket.class, ServerboundContainerClosePacket::new) - .registerServerboundPacket(0x0D, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new) - .registerServerboundPacket(0x0E, ServerboundEditBookPacket.class, ServerboundEditBookPacket::new) - .registerServerboundPacket(0x0F, ServerboundEntityTagQuery.class, ServerboundEntityTagQuery::new) - .registerServerboundPacket(0x10, ServerboundInteractPacket.class, ServerboundInteractPacket::new) - .registerServerboundPacket(0x11, ServerboundJigsawGeneratePacket.class, ServerboundJigsawGeneratePacket::new) - .registerServerboundPacket(0x12, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new) - .registerServerboundPacket(0x13, ServerboundLockDifficultyPacket.class, ServerboundLockDifficultyPacket::new) - .registerServerboundPacket(0x14, ServerboundMovePlayerPosPacket.class, ServerboundMovePlayerPosPacket::new) - .registerServerboundPacket(0x15, ServerboundMovePlayerPosRotPacket.class, ServerboundMovePlayerPosRotPacket::new) - .registerServerboundPacket(0x16, ServerboundMovePlayerRotPacket.class, ServerboundMovePlayerRotPacket::new) - .registerServerboundPacket(0x17, ServerboundMovePlayerStatusOnlyPacket.class, ServerboundMovePlayerStatusOnlyPacket::new) - .registerServerboundPacket(0x18, ServerboundMoveVehiclePacket.class, ServerboundMoveVehiclePacket::new) - .registerServerboundPacket(0x19, ServerboundPaddleBoatPacket.class, ServerboundPaddleBoatPacket::new) - .registerServerboundPacket(0x1A, ServerboundPickItemPacket.class, ServerboundPickItemPacket::new) - .registerServerboundPacket(0x1B, ServerboundPlaceRecipePacket.class, ServerboundPlaceRecipePacket::new) - .registerServerboundPacket(0x1C, ServerboundPlayerAbilitiesPacket.class, ServerboundPlayerAbilitiesPacket::new) - .registerServerboundPacket(0x1D, ServerboundPlayerActionPacket.class, ServerboundPlayerActionPacket::new) - .registerServerboundPacket(0x1E, ServerboundPlayerCommandPacket.class, ServerboundPlayerCommandPacket::new) - .registerServerboundPacket(0x1F, ServerboundPlayerInputPacket.class, ServerboundPlayerInputPacket::new) - .registerServerboundPacket(0x20, ServerboundPongPacket.class, ServerboundPongPacket::new) - .registerServerboundPacket(0x21, ServerboundRecipeBookChangeSettingsPacket.class, ServerboundRecipeBookChangeSettingsPacket::new) - .registerServerboundPacket(0x22, ServerboundRecipeBookSeenRecipePacket.class, ServerboundRecipeBookSeenRecipePacket::new) - .registerServerboundPacket(0x23, ServerboundRenameItemPacket.class, ServerboundRenameItemPacket::new) - .registerServerboundPacket(0x24, ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new) - .registerServerboundPacket(0x25, ServerboundSeenAdvancementsPacket.class, ServerboundSeenAdvancementsPacket::new) - .registerServerboundPacket(0x26, ServerboundSelectTradePacket.class, ServerboundSelectTradePacket::new) - .registerServerboundPacket(0x27, ServerboundSetBeaconPacket.class, ServerboundSetBeaconPacket::new) - .registerServerboundPacket(0x28, ServerboundSetCarriedItemPacket.class, ServerboundSetCarriedItemPacket::new) - .registerServerboundPacket(0x29, ServerboundSetCommandBlockPacket.class, ServerboundSetCommandBlockPacket::new) - .registerServerboundPacket(0x2A, ServerboundSetCommandMinecartPacket.class, ServerboundSetCommandMinecartPacket::new) - .registerServerboundPacket(0x2B, ServerboundSetCreativeModeSlotPacket.class, ServerboundSetCreativeModeSlotPacket::new) - .registerServerboundPacket(0x2C, ServerboundSetJigsawBlockPacket.class, ServerboundSetJigsawBlockPacket::new) - .registerServerboundPacket(0x2D, ServerboundSetStructureBlockPacket.class, ServerboundSetStructureBlockPacket::new) - .registerServerboundPacket(0x2E, ServerboundSignUpdatePacket.class, ServerboundSignUpdatePacket::new) - .registerServerboundPacket(0x2F, ServerboundSwingPacket.class, ServerboundSwingPacket::new) - .registerServerboundPacket(0x30, ServerboundTeleportToEntityPacket.class, ServerboundTeleportToEntityPacket::new) - .registerServerboundPacket(0x31, ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new) - .registerServerboundPacket(0x32, ServerboundUseItemPacket.class, ServerboundUseItemPacket::new) + .registerServerboundPacket(0x07, ServerboundChunkBatchReceivedPacket.class, ServerboundChunkBatchReceivedPacket::new) + .registerServerboundPacket(0x08, ServerboundClientCommandPacket.class, ServerboundClientCommandPacket::new) + .registerServerboundPacket(0x09, ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new) + .registerServerboundPacket(0x0A, ServerboundCommandSuggestionPacket.class, ServerboundCommandSuggestionPacket::new) + .registerServerboundPacket(0x0B, ServerboundConfigurationAcknowledgedPacket.class, ServerboundConfigurationAcknowledgedPacket::new) + .registerServerboundPacket(0x0C, ServerboundContainerButtonClickPacket.class, ServerboundContainerButtonClickPacket::new) + .registerServerboundPacket(0x0D, ServerboundContainerClickPacket.class, ServerboundContainerClickPacket::new) + .registerServerboundPacket(0x0E, ServerboundContainerClosePacket.class, ServerboundContainerClosePacket::new) + .registerServerboundPacket(0x0F, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new) + .registerServerboundPacket(0x10, ServerboundEditBookPacket.class, ServerboundEditBookPacket::new) + .registerServerboundPacket(0x11, ServerboundEntityTagQuery.class, ServerboundEntityTagQuery::new) + .registerServerboundPacket(0x12, ServerboundInteractPacket.class, ServerboundInteractPacket::new) + .registerServerboundPacket(0x13, ServerboundJigsawGeneratePacket.class, ServerboundJigsawGeneratePacket::new) + .registerServerboundPacket(0x14, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new) + .registerServerboundPacket(0x15, ServerboundLockDifficultyPacket.class, ServerboundLockDifficultyPacket::new) + .registerServerboundPacket(0x16, ServerboundMovePlayerPosPacket.class, ServerboundMovePlayerPosPacket::new) + .registerServerboundPacket(0x17, ServerboundMovePlayerPosRotPacket.class, ServerboundMovePlayerPosRotPacket::new) + .registerServerboundPacket(0x18, ServerboundMovePlayerRotPacket.class, ServerboundMovePlayerRotPacket::new) + .registerServerboundPacket(0x19, ServerboundMovePlayerStatusOnlyPacket.class, ServerboundMovePlayerStatusOnlyPacket::new) + .registerServerboundPacket(0x1A, ServerboundMoveVehiclePacket.class, ServerboundMoveVehiclePacket::new) + .registerServerboundPacket(0x1B, ServerboundPaddleBoatPacket.class, ServerboundPaddleBoatPacket::new) + .registerServerboundPacket(0x1C, ServerboundPickItemPacket.class, ServerboundPickItemPacket::new) + .registerServerboundPacket(0x1D, ServerboundPlaceRecipePacket.class, ServerboundPlaceRecipePacket::new) + .registerServerboundPacket(0x1E, ServerboundPlayerAbilitiesPacket.class, ServerboundPlayerAbilitiesPacket::new) + .registerServerboundPacket(0x1F, ServerboundPlayerActionPacket.class, ServerboundPlayerActionPacket::new) + .registerServerboundPacket(0x20, ServerboundPlayerCommandPacket.class, ServerboundPlayerCommandPacket::new) + .registerServerboundPacket(0x21, ServerboundPlayerInputPacket.class, ServerboundPlayerInputPacket::new) + .registerServerboundPacket(0x22, ServerboundPongPacket.class, ServerboundPongPacket::new) + .registerServerboundPacket(0x23, ServerboundRecipeBookChangeSettingsPacket.class, ServerboundRecipeBookChangeSettingsPacket::new) + .registerServerboundPacket(0x24, ServerboundRecipeBookSeenRecipePacket.class, ServerboundRecipeBookSeenRecipePacket::new) + .registerServerboundPacket(0x25, ServerboundRenameItemPacket.class, ServerboundRenameItemPacket::new) + .registerServerboundPacket(0x26, ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new) + .registerServerboundPacket(0x27, ServerboundSeenAdvancementsPacket.class, ServerboundSeenAdvancementsPacket::new) + .registerServerboundPacket(0x28, ServerboundSelectTradePacket.class, ServerboundSelectTradePacket::new) + .registerServerboundPacket(0x29, ServerboundSetBeaconPacket.class, ServerboundSetBeaconPacket::new) + .registerServerboundPacket(0x2A, ServerboundSetCarriedItemPacket.class, ServerboundSetCarriedItemPacket::new) + .registerServerboundPacket(0x2B, ServerboundSetCommandBlockPacket.class, ServerboundSetCommandBlockPacket::new) + .registerServerboundPacket(0x2C, ServerboundSetCommandMinecartPacket.class, ServerboundSetCommandMinecartPacket::new) + .registerServerboundPacket(0x2D, ServerboundSetCreativeModeSlotPacket.class, ServerboundSetCreativeModeSlotPacket::new) + .registerServerboundPacket(0x2E, ServerboundSetJigsawBlockPacket.class, ServerboundSetJigsawBlockPacket::new) + .registerServerboundPacket(0x2F, ServerboundSetStructureBlockPacket.class, ServerboundSetStructureBlockPacket::new) + .registerServerboundPacket(0x30, ServerboundSignUpdatePacket.class, ServerboundSignUpdatePacket::new) + .registerServerboundPacket(0x31, ServerboundSwingPacket.class, ServerboundSwingPacket::new) + .registerServerboundPacket(0x32, ServerboundTeleportToEntityPacket.class, ServerboundTeleportToEntityPacket::new) + .registerServerboundPacket(0x33, ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new) + .registerServerboundPacket(0x34, ServerboundUseItemPacket.class, ServerboundUseItemPacket::new) ) .build(); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java b/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java index 64066740e..f63f861f3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java +++ b/src/main/java/com/github/steveice10/mc/protocol/codec/MinecraftCodecHelper.java @@ -786,20 +786,14 @@ public void writeFixedBitSet(ByteBuf buf, BitSet bitSet, int length) { public GameProfile.Property readProperty(ByteBuf buf) { String name = this.readString(buf); String value = this.readString(buf); - if (buf.readBoolean()) { - return new GameProfile.Property(name, value, this.readString(buf)); - } else { - return new GameProfile.Property(name, value); - } + String signature = this.readNullable(buf, this::readString); + return new GameProfile.Property(name, value, signature); } public void writeProperty(ByteBuf buf, GameProfile.Property property) { this.writeString(buf, property.getName()); this.writeString(buf, property.getValue()); - buf.writeBoolean(property.hasSignature()); - if (property.hasSignature()) { - this.writeString(buf, property.getSignature()); - } + this.writeNullable(buf, property.getSignature(), this::writeString); } public T readById(ByteBuf buf, IntFunction registry, Function custom) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/ProtocolState.java b/src/main/java/com/github/steveice10/mc/protocol/data/ProtocolState.java index 9f4e18397..e31e1385f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/ProtocolState.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/ProtocolState.java @@ -4,5 +4,6 @@ public enum ProtocolState { HANDSHAKE, LOGIN, GAME, - STATUS; + STATUS, + CONFIGURATION; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java index dbdfeea0f..27a97d395 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/PlayerListEntry.java @@ -15,7 +15,7 @@ @AllArgsConstructor public class PlayerListEntry { private final @NonNull UUID profileId; - private @NonNull GameProfile profile; + private @Nullable GameProfile profile; private boolean listed; private int latency; private GameMode gameMode; @@ -26,6 +26,6 @@ public class PlayerListEntry { private byte @Nullable[] keySignature; public PlayerListEntry(UUID profileId) { - this(profileId, new GameProfile(profileId, null), false, 0, GameMode.SURVIVAL, null, null, 0, null, null); + this(profileId, null, false, 0, GameMode.SURVIVAL, null, null, 0, null, null); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCustomPayloadPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java similarity index 93% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCustomPayloadPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java index 0df956b81..115172e00 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCustomPayloadPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundCustomPayloadPacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.common.clientbound; 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/ClientboundDisconnectPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundDisconnectPacket.java similarity index 94% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDisconnectPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundDisconnectPacket.java index c0366df5d..6e0fb388b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundDisconnectPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundDisconnectPacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.common.clientbound; 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/ClientboundKeepAlivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java similarity index 91% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundKeepAlivePacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java index a31fffb00..1aac03339 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundKeepAlivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundKeepAlivePacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.common.clientbound; 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/ClientboundPingPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java similarity index 91% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPingPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java index d8c60e034..fba16f5ae 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPingPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundPingPacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.common.clientbound; 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/ClientboundResourcePackPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPacket.java similarity index 95% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundResourcePackPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPacket.java index 5f59073ff..2ae7cbb96 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundResourcePackPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundResourcePackPacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.common.clientbound; 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/ClientboundUpdateTagsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundUpdateTagsPacket.java similarity index 92% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateTagsPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundUpdateTagsPacket.java index 050cd7fea..41116ba8d 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateTagsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/clientbound/ClientboundUpdateTagsPacket.java @@ -1,15 +1,13 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.common.clientbound; import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import com.github.steveice10.mc.protocol.data.game.Identifier; import io.netty.buffer.ByteBuf; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NonNull; import lombok.With; -import java.io.IOException; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCustomPayloadPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.java similarity index 93% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCustomPayloadPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.java index e7c7fe21d..aa8a7c9f8 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundCustomPayloadPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundCustomPayloadPacket.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/serverbound/ServerboundKeepAlivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.java similarity index 91% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundKeepAlivePacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.java index d4259cb9b..a73dd6e56 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundKeepAlivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundKeepAlivePacket.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/serverbound/ServerboundPongPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.java similarity index 91% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundPongPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.java index 8ca9cb87c..e81923e4f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundPongPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundPongPacket.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/serverbound/ServerboundResourcePackPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.java similarity index 93% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundResourcePackPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.java index 07341b8e7..563ed0087 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundResourcePackPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/common/serverbound/ServerboundResourcePackPacket.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/configuration/clientbound/ClientboundFinishConfigurationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundFinishConfigurationPacket.java new file mode 100644 index 000000000..14c7e3c22 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundFinishConfigurationPacket.java @@ -0,0 +1,18 @@ +package com.github.steveice10.mc.protocol.packet.configuration.clientbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ClientboundFinishConfigurationPacket implements MinecraftPacket { + public ClientboundFinishConfigurationPacket(ByteBuf in, MinecraftCodecHelper helper) { + } + + @Override + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundRegistryDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundRegistryDataPacket.java new file mode 100644 index 000000000..de99c4288 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundRegistryDataPacket.java @@ -0,0 +1,27 @@ +package com.github.steveice10.mc.protocol.packet.configuration.clientbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundRegistryDataPacket implements MinecraftPacket { + private final CompoundTag registry; + + public ClientboundRegistryDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { + this.registry = helper.readTag(in); + } + + @Override + public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + helper.writeTag(out, this.registry); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateEnabledFeaturesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java similarity index 92% rename from src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateEnabledFeaturesPacket.java rename to src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java index 1aaccc4a0..6b22e834f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundUpdateEnabledFeaturesPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/clientbound/ClientboundUpdateEnabledFeaturesPacket.java @@ -1,4 +1,4 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; +package com.github.steveice10.mc.protocol.packet.configuration.clientbound; 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/configuration/serverbound/ServerboundFinishConfigurationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/serverbound/ServerboundFinishConfigurationPacket.java new file mode 100644 index 000000000..4385dde61 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/configuration/serverbound/ServerboundFinishConfigurationPacket.java @@ -0,0 +1,18 @@ +package com.github.steveice10.mc.protocol.packet.configuration.serverbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ServerboundFinishConfigurationPacket implements MinecraftPacket { + + public ServerboundFinishConfigurationPacket(ByteBuf in, MinecraftCodecHelper helper) { + } + + public void serialize(ByteBuf buf, MinecraftCodecHelper helper) { + } +} 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 2af911ece..c9905f494 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 @@ -20,18 +20,18 @@ public class ClientboundLoginPacket implements MinecraftPacket { private final int entityId; private final boolean hardcore; - private final @NonNull GameMode gameMode; - private final @Nullable GameMode previousGamemode; private final @NonNull String[] worldNames; private final @NonNull CompoundTag registry; - private final @NonNull String dimension; - private final @NonNull String worldName; - private final long hashedSeed; private final int maxPlayers; private final int viewDistance; private final int simulationDistance; private final boolean reducedDebugInfo; private final boolean enableRespawnScreen; + private final @NonNull String dimension; + private final @NonNull String worldName; + private final long hashedSeed; + private final @NonNull GameMode gameMode; + private final @Nullable GameMode previousGamemode; private final boolean debug; private final boolean flat; private final @Nullable GlobalPos lastDeathPos; @@ -40,22 +40,22 @@ public class ClientboundLoginPacket implements MinecraftPacket { public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { this.entityId = in.readInt(); this.hardcore = in.readBoolean(); - this.gameMode = GameMode.byId(in.readByte()); - this.previousGamemode = GameMode.byNullableId(in.readByte()); int worldCount = helper.readVarInt(in); this.worldNames = new String[worldCount]; for (int i = 0; i < worldCount; i++) { this.worldNames[i] = helper.readString(in); } this.registry = helper.readTag(in); - this.dimension = helper.readString(in); - this.worldName = helper.readString(in); - this.hashedSeed = in.readLong(); this.maxPlayers = helper.readVarInt(in); this.viewDistance = helper.readVarInt(in); this.simulationDistance = helper.readVarInt(in); this.reducedDebugInfo = in.readBoolean(); this.enableRespawnScreen = in.readBoolean(); + this.dimension = helper.readString(in); + this.worldName = helper.readString(in); + this.hashedSeed = in.readLong(); + this.gameMode = GameMode.byId(in.readByte()); + this.previousGamemode = GameMode.byNullableId(in.readByte()); this.debug = in.readBoolean(); this.flat = in.readBoolean(); if (in.readBoolean()) { @@ -70,21 +70,21 @@ public ClientboundLoginPacket(ByteBuf in, MinecraftCodecHelper helper) throws IO public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { out.writeInt(this.entityId); out.writeBoolean(this.hardcore); - out.writeByte(this.gameMode.ordinal()); - out.writeByte(GameMode.toNullableId(this.gameMode)); helper.writeVarInt(out, this.worldNames.length); for (String worldName : this.worldNames) { helper.writeString(out, worldName); } helper.writeTag(out, this.registry); - helper.writeString(out, this.dimension); - helper.writeString(out, this.worldName); - out.writeLong(this.hashedSeed); helper.writeVarInt(out, this.maxPlayers); helper.writeVarInt(out, this.viewDistance); helper.writeVarInt(out, this.simulationDistance); out.writeBoolean(this.reducedDebugInfo); out.writeBoolean(this.enableRespawnScreen); + helper.writeString(out, this.dimension); + helper.writeString(out, this.worldName); + out.writeLong(this.hashedSeed); + out.writeByte(this.gameMode.ordinal()); + out.writeByte(GameMode.toNullableId(this.previousGamemode)); out.writeBoolean(this.debug); out.writeBoolean(this.flat); out.writeBoolean(this.lastDeathPos != null); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java index 5a32d2a60..526f09cc6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoUpdatePacket.java @@ -37,7 +37,7 @@ public ClientboundPlayerInfoUpdatePacket(ByteBuf in, MinecraftCodecHelper helper for (PlayerListEntryAction action : this.actions) { switch (action) { case ADD_PLAYER: { - GameProfile profile = new GameProfile(entry.getProfile().getId(), helper.readString(in, 16)); + GameProfile profile = new GameProfile(entry.getProfileId(), helper.readString(in, 16)); int propertyCount = helper.readVarInt(in); List propertyList = new ArrayList<>(); for (int index = 0; index < propertyCount; index++) { diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java index 459553575..730ca51b6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundRespawnPacket.java @@ -25,11 +25,11 @@ public class ClientboundRespawnPacket implements MinecraftPacket { private final @Nullable GameMode previousGamemode; private final boolean debug; private final boolean flat; + private final @Nullable GlobalPos lastDeathPos; + private final int portalCooldown; // The following two are the dataToKeep byte private final boolean keepMetadata; private final boolean keepAttributes; - private final @Nullable GlobalPos lastDeathPos; - private final int portalCooldown; public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) { this.dimension = helper.readString(in); @@ -39,11 +39,11 @@ public ClientboundRespawnPacket(ByteBuf in, MinecraftCodecHelper helper) { this.previousGamemode = GameMode.byNullableId(in.readByte()); this.debug = in.readBoolean(); this.flat = in.readBoolean(); + this.lastDeathPos = helper.readNullable(in, helper::readGlobalPos); + this.portalCooldown = helper.readVarInt(in); byte dataToKeep = in.readByte(); this.keepAttributes = (dataToKeep & KEEP_ATTRIBUTES) != 0; this.keepMetadata = (dataToKeep & KEEP_ENTITY_DATA) != 0; - this.lastDeathPos = helper.readNullable(in, helper::readGlobalPos); - this.portalCooldown = helper.readVarInt(in); } @Override @@ -55,6 +55,8 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) { out.writeByte(GameMode.toNullableId(this.previousGamemode)); out.writeBoolean(this.debug); out.writeBoolean(this.flat); + helper.writeNullable(out, this.lastDeathPos, helper::writeGlobalPos); + helper.writeVarInt(out, this.portalCooldown); byte dataToKeep = 0; if (this.keepMetadata) { dataToKeep += KEEP_ENTITY_DATA; @@ -63,7 +65,5 @@ public void serialize(ByteBuf out, MinecraftCodecHelper helper) { dataToKeep += KEEP_ATTRIBUTES; } out.writeByte(dataToKeep); - helper.writeNullable(out, this.lastDeathPos, helper::writeGlobalPos); - helper.writeVarInt(out, this.portalCooldown); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java new file mode 100644 index 000000000..81b251a54 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundStartConfigurationPacket.java @@ -0,0 +1,20 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.IOException; + +@Data +@NoArgsConstructor +public class ClientboundStartConfigurationPacket implements MinecraftPacket { + + public ClientboundStartConfigurationPacket(ByteBuf in, MinecraftCodecHelper helper) { + } + + public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java new file mode 100644 index 000000000..49d173c7b --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchFinishedPacket.java @@ -0,0 +1,25 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundChunkBatchFinishedPacket implements MinecraftPacket { + private final int batchSize; + + public ClientboundChunkBatchFinishedPacket(ByteBuf in, MinecraftCodecHelper helper) { + this.batchSize = helper.readVarInt(in); + } + + public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + helper.writeVarInt(out, this.batchSize); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java new file mode 100644 index 000000000..24f525847 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundChunkBatchStartPacket.java @@ -0,0 +1,20 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.IOException; + +@Data +@NoArgsConstructor +public class ClientboundChunkBatchStartPacket implements MinecraftPacket { + + public ClientboundChunkBatchStartPacket(ByteBuf in, MinecraftCodecHelper helper) { + } + + public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java index cd54bc1d4..ec0df69be 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundForgetLevelChunkPacket.java @@ -17,13 +17,13 @@ public class ClientboundForgetLevelChunkPacket implements MinecraftPacket { private final int z; public ClientboundForgetLevelChunkPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { - this.x = in.readInt(); - this.z = in.readInt(); + long chunkPosition = in.readLong(); + this.x = (int)chunkPosition; + this.z = (int)(chunkPosition >> 32); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { - out.writeInt(this.x); - out.writeInt(this.z); + out.writeLong(this.x & 0xFFFFFFFFL | (this.z & 0xFFFFFFFFL) << 32); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java index 3311a8732..037b01ad6 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/scoreboard/ClientboundSetDisplayObjectivePacket.java @@ -19,13 +19,13 @@ public class ClientboundSetDisplayObjectivePacket implements MinecraftPacket { private final @NonNull String name; public ClientboundSetDisplayObjectivePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { - this.position = ScoreboardPosition.from(in.readByte()); + this.position = ScoreboardPosition.from(helper.readVarInt(in)); this.name = helper.readString(in); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { - out.writeByte(this.position.ordinal()); + helper.writeVarInt(out, this.position.ordinal()); helper.writeString(out, this.name); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java new file mode 100644 index 000000000..85b2815fb --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundConfigurationAcknowledgedPacket.java @@ -0,0 +1,20 @@ +package com.github.steveice10.mc.protocol.packet.ingame.serverbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.IOException; + +@Data +@NoArgsConstructor +public class ServerboundConfigurationAcknowledgedPacket implements MinecraftPacket { + + public ServerboundConfigurationAcknowledgedPacket(ByteBuf in, MinecraftCodecHelper helper) { + } + + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundChunkBatchReceivedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundChunkBatchReceivedPacket.java new file mode 100644 index 000000000..d2c0edfed --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/level/ServerboundChunkBatchReceivedPacket.java @@ -0,0 +1,23 @@ +package com.github.steveice10.mc.protocol.packet.ingame.serverbound.level; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +@Data +@With +@AllArgsConstructor +public class ServerboundChunkBatchReceivedPacket implements MinecraftPacket { + private final float desiredBatchSize; + + public ServerboundChunkBatchReceivedPacket(ByteBuf in, MinecraftCodecHelper helper) { + this.desiredBatchSize = in.readFloat(); + } + + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + out.writeFloat(this.desiredBatchSize); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java new file mode 100644 index 000000000..e7aa4e343 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacket.java @@ -0,0 +1,31 @@ +package com.github.steveice10.mc.protocol.packet.login.serverbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +@Data +@With +@AllArgsConstructor +public class ServerboundCustomQueryAnswerPacket implements MinecraftPacket { + private final int transactionId; + private final byte[] data; + + public ServerboundCustomQueryAnswerPacket(int transactionId) { + this(transactionId, null); + } + + public ServerboundCustomQueryAnswerPacket(ByteBuf in, MinecraftCodecHelper helper) { + this.transactionId = helper.readVarInt(in); + this.data = helper.readByteArray(in, ByteBuf::readableBytes); + } + + @Override + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + helper.writeVarInt(out, this.transactionId); + out.writeBytes(this.data); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryPacket.java deleted file mode 100644 index ba1625ce7..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryPacket.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.steveice10.mc.protocol.packet.login.serverbound; - -import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; -import com.github.steveice10.mc.protocol.codec.MinecraftPacket; -import io.netty.buffer.ByteBuf; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.With; - -import java.io.IOException; - -@Data -@With -@AllArgsConstructor -public class ServerboundCustomQueryPacket implements MinecraftPacket { - private final int messageId; - private final byte[] data; - - public ServerboundCustomQueryPacket(int messageId) { - this(messageId, null); - } - - public ServerboundCustomQueryPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { - this.messageId = helper.readVarInt(in); - if (in.readBoolean()) { - this.data = helper.readByteArray(in, ByteBuf::readableBytes); - } else { - this.data = null; - } - } - - @Override - public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException { - helper.writeVarInt(out, this.messageId); - if (this.data != null) { - out.writeBoolean(true); - out.writeBytes(this.data); - } else { - out.writeBoolean(false); - } - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java index b711ddc4e..75a1c6e56 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacket.java @@ -7,15 +7,8 @@ import lombok.Data; import lombok.NonNull; import lombok.With; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.Nullable; import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.PublicKey; -import java.security.spec.X509EncodedKeySpec; -import java.time.Instant; import java.util.UUID; @Data @@ -23,17 +16,17 @@ @AllArgsConstructor public class ServerboundHelloPacket implements MinecraftPacket { private final @NonNull String username; - private final @Nullable UUID profileId; + private final @NonNull UUID profileId; public ServerboundHelloPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException { this.username = helper.readString(in); - this.profileId = helper.readNullable(in, helper::readUUID); + this.profileId = helper.readUUID(in); } @Override public void serialize(ByteBuf out, MinecraftCodecHelper helper) { helper.writeString(out, this.username); - helper.writeNullable(out, this.profileId, helper::writeUUID); + helper.writeUUID(out, this.profileId); } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundLoginAcknowledgedPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundLoginAcknowledgedPacket.java new file mode 100644 index 000000000..397aa1c88 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundLoginAcknowledgedPacket.java @@ -0,0 +1,18 @@ +package com.github.steveice10.mc.protocol.packet.login.serverbound; + +import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper; +import com.github.steveice10.mc.protocol.codec.MinecraftPacket; +import io.netty.buffer.ByteBuf; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class ServerboundLoginAcknowledgedPacket implements MinecraftPacket { + public ServerboundLoginAcknowledgedPacket(ByteBuf in, MinecraftCodecHelper helper) { + } + + @Override + public void serialize(ByteBuf out, MinecraftCodecHelper helper) { + } +} diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java index 4d2c2bf49..e2e4b9a8d 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpPacketCompression.java @@ -1,19 +1,20 @@ package com.github.steveice10.packetlib.tcp; import com.github.steveice10.packetlib.Session; -import com.github.steveice10.packetlib.codec.PacketCodecHelper; import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageCodec; import io.netty.handler.codec.DecoderException; +import java.nio.ByteBuffer; import java.util.List; +import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.Inflater; public class TcpPacketCompression extends ByteToMessageCodec { private static final int MAX_COMPRESSED_SIZE = 2097152; + private static final int MAX_UNCOMPRESSED_SIZE = 8388608; private final Session session; private final Deflater deflater = new Deflater(); @@ -57,9 +58,9 @@ public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Ex @Override protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) throws Exception { - if(buf.readableBytes() != 0) { + if (buf.readableBytes() != 0) { int size = this.session.getCodecHelper().readVarInt(buf); - if(size == 0) { + if (size == 0) { out.add(buf.readBytes(buf.readableBytes())); } else { if (validateDecompression) { // This is sectioned off as of at least Java Edition 1.18 @@ -67,19 +68,50 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List out) throw new DecoderException("Badly compressed packet: size of " + size + " is below threshold of " + this.session.getCompressionThreshold() + "."); } - if (size > MAX_COMPRESSED_SIZE) { - throw new DecoderException("Badly compressed packet: size of " + size + " is larger than protocol maximum of " + MAX_COMPRESSED_SIZE + "."); + if (size > MAX_UNCOMPRESSED_SIZE) { + throw new DecoderException("Badly compressed packet: size of " + size + " is larger than protocol maximum of " + MAX_UNCOMPRESSED_SIZE + "."); } } - byte[] bytes = new byte[buf.readableBytes()]; - buf.readBytes(bytes); - this.inflater.setInput(bytes); - byte[] inflated = new byte[size]; - this.inflater.inflate(inflated); - out.add(Unpooled.wrappedBuffer(inflated)); + this.setupInflaterInput(buf); + ByteBuf inflated = this.inflate(ctx, size); this.inflater.reset(); + out.add(inflated); } } } + + private void setupInflaterInput(ByteBuf buf) { + ByteBuffer inputBuffer; + if (buf.nioBufferCount() > 0) { + inputBuffer = buf.nioBuffer(); + buf.skipBytes(buf.readableBytes()); + } else { + inputBuffer = ByteBuffer.allocateDirect(buf.readableBytes()); + buf.readBytes(inputBuffer); + inputBuffer.flip(); + } + + this.inflater.setInput(inputBuffer.array()); + } + + private ByteBuf inflate(ChannelHandlerContext ctx, int size) throws DataFormatException { + ByteBuf buf = ctx.alloc().directBuffer(size); + + try { + ByteBuffer nioBuf = buf.internalNioBuffer(0, size); + int originalPos = nioBuf.position(); + this.inflater.inflate(nioBuf.array()); + int actualSize = nioBuf.position() - originalPos; + if (actualSize != size) { + throw new DecoderException("Badly compressed packet: actual length of uncompressed payload " + actualSize + " does not match declared size " + size); + } else { + buf.writerIndex(buf.writerIndex() + actualSize); + return buf; + } + } catch (Exception e) { + buf.release(); + throw e; + } + } } 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 44edb58de..03af81c61 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -51,7 +51,7 @@ public class MinecraftProtocolTest { null, false ); - private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, new String[]{"minecraft:world"}, loadLoginRegistry(), "overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false, null, 100); + private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, new String[]{"minecraft:world"}, loadLoginRegistry(), 0, 16, 16, false, false, "overworld", "minecraft:world", 100, GameMode.SURVIVAL, GameMode.SURVIVAL, false, false, null, 100); private static Server server; diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryPacketTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacketTest.java similarity index 59% rename from src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryPacketTest.java rename to src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacketTest.java index 5b2d93adc..7c2594a81 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryPacketTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundCustomQueryAnswerPacketTest.java @@ -5,13 +5,13 @@ import java.util.Random; -public class ServerboundCustomQueryPacketTest extends PacketTest { +public class ServerboundCustomQueryAnswerPacketTest extends PacketTest { @Before public void setup() { byte[] data = new byte[1024]; new Random().nextBytes(data); - this.setPackets(new ServerboundCustomQueryPacket(0), - new ServerboundCustomQueryPacket(0, data)); + this.setPackets(new ServerboundCustomQueryAnswerPacket(0), + new ServerboundCustomQueryAnswerPacket(0, data)); } }