From 29c230f71dd6ec4664e5a7edacf2cf5ea05fc493 Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Thu, 19 May 2022 19:51:22 +0100 Subject: [PATCH 1/8] Main packet changes up to 1.19-pre1 --- .../mc/protocol/ServerListener.java | 3 +- .../mc/protocol/codec/MinecraftCodec.java | 276 +++++++++--------- .../mc/protocol/data/MagicValues.java | 103 +++---- .../mc/protocol/data/game/MessageType.java | 7 +- .../protocol/data/game/PlayerListEntry.java | 13 +- .../data/game/command/CommandParser.java | 5 +- .../game/level/block/BlockEntityType.java | 4 +- .../data/status/ServerStatusInfo.java | 1 + .../clientbound/ClientboundChatPacket.java | 58 ---- .../ClientboundChatPreviewPacket.java | 38 +++ .../ClientboundCommandsPacket.java | 14 +- .../clientbound/ClientboundLoginPacket.java | 6 +- .../ClientboundPlayerChatPacket.java | 73 +++++ .../ClientboundPlayerInfoPacket.java | 30 +- .../clientbound/ClientboundRespawnPacket.java | 6 +- .../ClientboundServerDataPacket.java | 53 ++++ ...lientboundSetDisplayChatPreviewPacket.java | 26 ++ .../ClientboundSoundEntityPacket.java | 3 + .../ClientboundSystemChatPacket.java | 33 +++ .../ClientboundUpdateMobEffectPacket.java | 13 + .../ClientboundBlockBreakAckPacket.java | 39 --- .../ClientboundBlockChangedAckPacket.java | 26 ++ .../spawn/ClientboundAddEntityPacket.java | 19 +- .../entity/spawn/ClientboundAddMobPacket.java | 62 ---- .../spawn/ClientboundAddPaintingPacket.java | 44 --- .../ClientboundAddVibrationSignalPacket.java | 54 ---- .../level/ClientboundCustomSoundPacket.java | 3 + .../level/ClientboundSoundPacket.java | 3 + .../ServerboundChatCommandPacket.java | 53 ++++ .../serverbound/ServerboundChatPacket.java | 13 + .../ServerboundChatPreviewPacket.java | 29 ++ .../inventory/ServerboundSetBeaconPacket.java | 29 +- .../player/ServerboundPlayerActionPacket.java | 3 + .../player/ServerboundUseItemOnPacket.java | 3 + .../player/ServerboundUseItemPacket.java | 3 + .../ClientboundGameProfilePacket.java | 28 +- .../serverbound/ServerboundHelloPacket.java | 32 ++ .../serverbound/ServerboundKeyPacket.java | 35 ++- .../ClientboundStatusResponsePacket.java | 4 +- 39 files changed, 760 insertions(+), 487 deletions(-) delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPreviewPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetDisplayChatPreviewPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockBreakAckPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddMobPacket.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddPaintingPacket.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundAddVibrationSignalPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPreviewPacket.java 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 15f9f9298..f2256eb3e 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ServerListener.java @@ -129,7 +129,8 @@ public void packetReceived(Session session, Packet packet) { new VersionInfo(protocol.getCodec().getMinecraftVersion(), protocol.getCodec().getProtocolVersion()), new PlayerInfo(0, 20, new GameProfile[0]), Component.text("A Minecraft Server"), - null + null, + false ); } 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 b3f0d5c87..d9a42065b 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 @@ -5,7 +5,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundAwardStatsPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundBossEventPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChangeDifficultyPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPreviewPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandsPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCooldownPacket; @@ -14,14 +14,18 @@ import com.github.steveice10.mc.protocol.packet.ingame.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.ingame.clientbound.ClientboundPlayerChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoPacket; 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.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.ClientboundSetDisplayChatPreviewPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSoundEntityPacket; 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.ClientboundUpdateRecipesPacket; @@ -44,7 +48,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundUpdateAttributesPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundUpdateMobEffectPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundBlockBreakAckPacket; +import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundBlockChangedAckPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerAbilitiesPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerCombatEndPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerCombatEnterPacket; @@ -56,8 +60,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddExperienceOrbPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddMobPacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPaintingPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPlayerPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundContainerClosePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundContainerSetContentPacket; @@ -68,7 +70,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundOpenBookPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundOpenScreenPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundPlaceGhostRecipePacket; -import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundAddVibrationSignalPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockDestructionPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEntityDataPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEventPacket; @@ -107,7 +108,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.title.ClientboundSetTitleTextPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.title.ClientboundSetTitlesAnimationPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChangeDifficultyPacket; +import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket; +import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPreviewPacket; 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; @@ -169,8 +172,8 @@ public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion(758) - .minecraftVersion("1.18.2") + .protocolVersion((1 << 30) | 85) + .minecraftVersion("1.19-pre1") .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) ) @@ -191,80 +194,80 @@ public class MinecraftCodec { ).state(ProtocolState.GAME, PacketStateCodec.builder() .registerClientboundPacket(0x00, ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new) .registerClientboundPacket(0x01, ClientboundAddExperienceOrbPacket.class, ClientboundAddExperienceOrbPacket::new) - .registerClientboundPacket(0x02, ClientboundAddMobPacket.class, ClientboundAddMobPacket::new) - .registerClientboundPacket(0x03, ClientboundAddPaintingPacket.class, ClientboundAddPaintingPacket::new) - .registerClientboundPacket(0x04, ClientboundAddPlayerPacket.class, ClientboundAddPlayerPacket::new) - .registerClientboundPacket(0x05, ClientboundAddVibrationSignalPacket.class, ClientboundAddVibrationSignalPacket::new) - .registerClientboundPacket(0x06, ClientboundAnimatePacket.class, ClientboundAnimatePacket::new) - .registerClientboundPacket(0x07, ClientboundAwardStatsPacket.class, ClientboundAwardStatsPacket::new) - .registerClientboundPacket(0x08, ClientboundBlockBreakAckPacket.class, ClientboundBlockBreakAckPacket::new) - .registerClientboundPacket(0x09, ClientboundBlockDestructionPacket.class, ClientboundBlockDestructionPacket::new) - .registerClientboundPacket(0x0A, ClientboundBlockEntityDataPacket.class, ClientboundBlockEntityDataPacket::new) - .registerClientboundPacket(0x0B, ClientboundBlockEventPacket.class, ClientboundBlockEventPacket::new) - .registerClientboundPacket(0x0C, ClientboundBlockUpdatePacket.class, ClientboundBlockUpdatePacket::new) - .registerClientboundPacket(0x0D, ClientboundBossEventPacket.class, ClientboundBossEventPacket::new) - .registerClientboundPacket(0x0E, ClientboundChangeDifficultyPacket.class, ClientboundChangeDifficultyPacket::new) - .registerClientboundPacket(0x0F, ClientboundChatPacket.class, ClientboundChatPacket::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, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new) - .registerClientboundPacket(0x19, ClientboundCustomSoundPacket.class, ClientboundCustomSoundPacket::new) - .registerClientboundPacket(0x1A, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new) - .registerClientboundPacket(0x1B, ClientboundEntityEventPacket.class, ClientboundEntityEventPacket::new) - .registerClientboundPacket(0x1C, ClientboundExplodePacket.class, ClientboundExplodePacket::new) - .registerClientboundPacket(0x1D, ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new) - .registerClientboundPacket(0x1E, ClientboundGameEventPacket.class, ClientboundGameEventPacket::new) - .registerClientboundPacket(0x1F, ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new) - .registerClientboundPacket(0x20, ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new) - .registerClientboundPacket(0x21, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new) - .registerClientboundPacket(0x22, ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkWithLightPacket::new) - .registerClientboundPacket(0x23, ClientboundLevelEventPacket.class, ClientboundLevelEventPacket::new) - .registerClientboundPacket(0x24, ClientboundLevelParticlesPacket.class, ClientboundLevelParticlesPacket::new) - .registerClientboundPacket(0x25, ClientboundLightUpdatePacket.class, ClientboundLightUpdatePacket::new) - .registerClientboundPacket(0x26, ClientboundLoginPacket.class, ClientboundLoginPacket::new) - .registerClientboundPacket(0x27, ClientboundMapItemDataPacket.class, ClientboundMapItemDataPacket::new) - .registerClientboundPacket(0x28, ClientboundMerchantOffersPacket.class, ClientboundMerchantOffersPacket::new) - .registerClientboundPacket(0x29, ClientboundMoveEntityPosPacket.class, ClientboundMoveEntityPosPacket::new) - .registerClientboundPacket(0x2A, ClientboundMoveEntityPosRotPacket.class, ClientboundMoveEntityPosRotPacket::new) - .registerClientboundPacket(0x2B, ClientboundMoveEntityRotPacket.class, ClientboundMoveEntityRotPacket::new) - .registerClientboundPacket(0x2C, ClientboundMoveVehiclePacket.class, ClientboundMoveVehiclePacket::new) - .registerClientboundPacket(0x2D, ClientboundOpenBookPacket.class, ClientboundOpenBookPacket::new) - .registerClientboundPacket(0x2E, ClientboundOpenScreenPacket.class, ClientboundOpenScreenPacket::new) - .registerClientboundPacket(0x2F, ClientboundOpenSignEditorPacket.class, ClientboundOpenSignEditorPacket::new) - .registerClientboundPacket(0x30, ClientboundPingPacket.class, ClientboundPingPacket::new) - .registerClientboundPacket(0x31, ClientboundPlaceGhostRecipePacket.class, ClientboundPlaceGhostRecipePacket::new) - .registerClientboundPacket(0x32, ClientboundPlayerAbilitiesPacket.class, ClientboundPlayerAbilitiesPacket::new) - .registerClientboundPacket(0x33, ClientboundPlayerCombatEndPacket.class, ClientboundPlayerCombatEndPacket::new) - .registerClientboundPacket(0x34, ClientboundPlayerCombatEnterPacket.class, ClientboundPlayerCombatEnterPacket::new) - .registerClientboundPacket(0x35, ClientboundPlayerCombatKillPacket.class, ClientboundPlayerCombatKillPacket::new) - .registerClientboundPacket(0x36, ClientboundPlayerInfoPacket.class, ClientboundPlayerInfoPacket::new) - .registerClientboundPacket(0x37, ClientboundPlayerLookAtPacket.class, ClientboundPlayerLookAtPacket::new) - .registerClientboundPacket(0x38, ClientboundPlayerPositionPacket.class, ClientboundPlayerPositionPacket::new) - .registerClientboundPacket(0x39, ClientboundRecipePacket.class, ClientboundRecipePacket::new) - .registerClientboundPacket(0x3A, ClientboundRemoveEntitiesPacket.class, ClientboundRemoveEntitiesPacket::new) - .registerClientboundPacket(0x3B, ClientboundRemoveMobEffectPacket.class, ClientboundRemoveMobEffectPacket::new) - .registerClientboundPacket(0x3C, ClientboundResourcePackPacket.class, ClientboundResourcePackPacket::new) - .registerClientboundPacket(0x3D, ClientboundRespawnPacket.class, ClientboundRespawnPacket::new) - .registerClientboundPacket(0x3E, ClientboundRotateHeadPacket.class, ClientboundRotateHeadPacket::new) - .registerClientboundPacket(0x3F, ClientboundSectionBlocksUpdatePacket.class, ClientboundSectionBlocksUpdatePacket::new) - .registerClientboundPacket(0x40, ClientboundSelectAdvancementsTabPacket.class, ClientboundSelectAdvancementsTabPacket::new) - .registerClientboundPacket(0x41, ClientboundSetActionBarTextPacket.class, ClientboundSetActionBarTextPacket::new) - .registerClientboundPacket(0x42, ClientboundSetBorderCenterPacket.class, ClientboundSetBorderCenterPacket::new) - .registerClientboundPacket(0x43, ClientboundSetBorderLerpSizePacket.class, ClientboundSetBorderLerpSizePacket::new) - .registerClientboundPacket(0x44, ClientboundSetBorderSizePacket.class, ClientboundSetBorderSizePacket::new) - .registerClientboundPacket(0x45, ClientboundSetBorderWarningDelayPacket.class, ClientboundSetBorderWarningDelayPacket::new) - .registerClientboundPacket(0x46, ClientboundSetBorderWarningDistancePacket.class, ClientboundSetBorderWarningDistancePacket::new) - .registerClientboundPacket(0x47, ClientboundSetCameraPacket.class, ClientboundSetCameraPacket::new) - .registerClientboundPacket(0x48, ClientboundSetCarriedItemPacket.class, ClientboundSetCarriedItemPacket::new) - .registerClientboundPacket(0x49, ClientboundSetChunkCacheCenterPacket.class, ClientboundSetChunkCacheCenterPacket::new) - .registerClientboundPacket(0x4A, ClientboundSetChunkCacheRadiusPacket.class, ClientboundSetChunkCacheRadiusPacket::new) - .registerClientboundPacket(0x4B, ClientboundSetDefaultSpawnPositionPacket.class, ClientboundSetDefaultSpawnPositionPacket::new) + .registerClientboundPacket(0x02, ClientboundAddPlayerPacket.class, ClientboundAddPlayerPacket::new) + .registerClientboundPacket(0x03, ClientboundAnimatePacket.class, ClientboundAnimatePacket::new) + .registerClientboundPacket(0x04, ClientboundAwardStatsPacket.class, ClientboundAwardStatsPacket::new) + .registerClientboundPacket(0x05, ClientboundBlockChangedAckPacket.class, ClientboundBlockChangedAckPacket::new) + .registerClientboundPacket(0x06, ClientboundBlockDestructionPacket.class, ClientboundBlockDestructionPacket::new) + .registerClientboundPacket(0x07, ClientboundBlockEntityDataPacket.class, ClientboundBlockEntityDataPacket::new) + .registerClientboundPacket(0x08, ClientboundBlockEventPacket.class, ClientboundBlockEventPacket::new) + .registerClientboundPacket(0x09, ClientboundBlockUpdatePacket.class, ClientboundBlockUpdatePacket::new) + .registerClientboundPacket(0x0A, ClientboundBossEventPacket.class, ClientboundBossEventPacket::new) + .registerClientboundPacket(0x0B, ClientboundChangeDifficultyPacket.class, ClientboundChangeDifficultyPacket::new) + .registerClientboundPacket(0x0C, ClientboundChatPreviewPacket.class, ClientboundChatPreviewPacket::new) + .registerClientboundPacket(0x0D, ClientboundClearTitlesPacket.class, ClientboundClearTitlesPacket::new) + .registerClientboundPacket(0x0E, ClientboundCommandSuggestionsPacket.class, ClientboundCommandSuggestionsPacket::new) + .registerClientboundPacket(0x0F, ClientboundCommandsPacket.class, ClientboundCommandsPacket::new) + .registerClientboundPacket(0x10, ClientboundContainerClosePacket.class, ClientboundContainerClosePacket::new) + .registerClientboundPacket(0x11, ClientboundContainerSetContentPacket.class, ClientboundContainerSetContentPacket::new) + .registerClientboundPacket(0x12, ClientboundContainerSetDataPacket.class, ClientboundContainerSetDataPacket::new) + .registerClientboundPacket(0x13, ClientboundContainerSetSlotPacket.class, ClientboundContainerSetSlotPacket::new) + .registerClientboundPacket(0x14, ClientboundCooldownPacket.class, ClientboundCooldownPacket::new) + .registerClientboundPacket(0x15, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new) + .registerClientboundPacket(0x16, ClientboundCustomSoundPacket.class, ClientboundCustomSoundPacket::new) + .registerClientboundPacket(0x17, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new) + .registerClientboundPacket(0x18, ClientboundEntityEventPacket.class, ClientboundEntityEventPacket::new) + .registerClientboundPacket(0x19, ClientboundExplodePacket.class, ClientboundExplodePacket::new) + .registerClientboundPacket(0x1A, ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new) + .registerClientboundPacket(0x1B, ClientboundGameEventPacket.class, ClientboundGameEventPacket::new) + .registerClientboundPacket(0x1C, ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new) + .registerClientboundPacket(0x1D, ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new) + .registerClientboundPacket(0x1E, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new) + .registerClientboundPacket(0x1F, ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkWithLightPacket::new) + .registerClientboundPacket(0x20, ClientboundLevelEventPacket.class, ClientboundLevelEventPacket::new) + .registerClientboundPacket(0x21, ClientboundLevelParticlesPacket.class, ClientboundLevelParticlesPacket::new) + .registerClientboundPacket(0x22, ClientboundLightUpdatePacket.class, ClientboundLightUpdatePacket::new) + .registerClientboundPacket(0x23, ClientboundLoginPacket.class, ClientboundLoginPacket::new) + .registerClientboundPacket(0x24, ClientboundMapItemDataPacket.class, ClientboundMapItemDataPacket::new) + .registerClientboundPacket(0x25, ClientboundMerchantOffersPacket.class, ClientboundMerchantOffersPacket::new) + .registerClientboundPacket(0x26, ClientboundMoveEntityPosPacket.class, ClientboundMoveEntityPosPacket::new) + .registerClientboundPacket(0x27, ClientboundMoveEntityPosRotPacket.class, ClientboundMoveEntityPosRotPacket::new) + .registerClientboundPacket(0x28, ClientboundMoveEntityRotPacket.class, ClientboundMoveEntityRotPacket::new) + .registerClientboundPacket(0x29, ClientboundMoveVehiclePacket.class, ClientboundMoveVehiclePacket::new) + .registerClientboundPacket(0x2A, ClientboundOpenBookPacket.class, ClientboundOpenBookPacket::new) + .registerClientboundPacket(0x2B, ClientboundOpenScreenPacket.class, ClientboundOpenScreenPacket::new) + .registerClientboundPacket(0x2C, ClientboundOpenSignEditorPacket.class, ClientboundOpenSignEditorPacket::new) + .registerClientboundPacket(0x2D, ClientboundPingPacket.class, ClientboundPingPacket::new) + .registerClientboundPacket(0x2E, ClientboundPlaceGhostRecipePacket.class, ClientboundPlaceGhostRecipePacket::new) + .registerClientboundPacket(0x2F, ClientboundPlayerAbilitiesPacket.class, ClientboundPlayerAbilitiesPacket::new) + .registerClientboundPacket(0x30, ClientboundPlayerChatPacket.class, ClientboundPlayerChatPacket::new) + .registerClientboundPacket(0x31, ClientboundPlayerCombatEndPacket.class, ClientboundPlayerCombatEndPacket::new) + .registerClientboundPacket(0x32, ClientboundPlayerCombatEnterPacket.class, ClientboundPlayerCombatEnterPacket::new) + .registerClientboundPacket(0x33, ClientboundPlayerCombatKillPacket.class, ClientboundPlayerCombatKillPacket::new) + .registerClientboundPacket(0x34, ClientboundPlayerInfoPacket.class, ClientboundPlayerInfoPacket::new) + .registerClientboundPacket(0x35, ClientboundPlayerLookAtPacket.class, ClientboundPlayerLookAtPacket::new) + .registerClientboundPacket(0x36, ClientboundPlayerPositionPacket.class, ClientboundPlayerPositionPacket::new) + .registerClientboundPacket(0x37, ClientboundRecipePacket.class, ClientboundRecipePacket::new) + .registerClientboundPacket(0x38, ClientboundRemoveEntitiesPacket.class, ClientboundRemoveEntitiesPacket::new) + .registerClientboundPacket(0x39, ClientboundRemoveMobEffectPacket.class, ClientboundRemoveMobEffectPacket::new) + .registerClientboundPacket(0x3A, ClientboundResourcePackPacket.class, ClientboundResourcePackPacket::new) + .registerClientboundPacket(0x3B, ClientboundRespawnPacket.class, ClientboundRespawnPacket::new) + .registerClientboundPacket(0x3C, ClientboundRotateHeadPacket.class, ClientboundRotateHeadPacket::new) + .registerClientboundPacket(0x3D, ClientboundSectionBlocksUpdatePacket.class, ClientboundSectionBlocksUpdatePacket::new) + .registerClientboundPacket(0x3E, ClientboundSelectAdvancementsTabPacket.class, ClientboundSelectAdvancementsTabPacket::new) + .registerClientboundPacket(0x3F, ClientboundServerDataPacket.class, ClientboundServerDataPacket::new) + .registerClientboundPacket(0x40, ClientboundSetActionBarTextPacket.class, ClientboundSetActionBarTextPacket::new) + .registerClientboundPacket(0x41, ClientboundSetBorderCenterPacket.class, ClientboundSetBorderCenterPacket::new) + .registerClientboundPacket(0x42, ClientboundSetBorderLerpSizePacket.class, ClientboundSetBorderLerpSizePacket::new) + .registerClientboundPacket(0x43, ClientboundSetBorderSizePacket.class, ClientboundSetBorderSizePacket::new) + .registerClientboundPacket(0x44, ClientboundSetBorderWarningDelayPacket.class, ClientboundSetBorderWarningDelayPacket::new) + .registerClientboundPacket(0x45, ClientboundSetBorderWarningDistancePacket.class, ClientboundSetBorderWarningDistancePacket::new) + .registerClientboundPacket(0x46, ClientboundSetCameraPacket.class, ClientboundSetCameraPacket::new) + .registerClientboundPacket(0x47, ClientboundSetCarriedItemPacket.class, ClientboundSetCarriedItemPacket::new) + .registerClientboundPacket(0x48, ClientboundSetChunkCacheCenterPacket.class, ClientboundSetChunkCacheCenterPacket::new) + .registerClientboundPacket(0x49, ClientboundSetChunkCacheRadiusPacket.class, ClientboundSetChunkCacheRadiusPacket::new) + .registerClientboundPacket(0x4A, ClientboundSetDefaultSpawnPositionPacket.class, ClientboundSetDefaultSpawnPositionPacket::new) + .registerClientboundPacket(0x4B, ClientboundSetDisplayChatPreviewPacket.class, ClientboundSetDisplayChatPreviewPacket::new) .registerClientboundPacket(0x4C, ClientboundSetDisplayObjectivePacket.class, ClientboundSetDisplayObjectivePacket::new) .registerClientboundPacket(0x4D, ClientboundSetEntityDataPacket.class, ClientboundSetEntityDataPacket::new) .registerClientboundPacket(0x4E, ClientboundSetEntityLinkPacket.class, ClientboundSetEntityLinkPacket::new) @@ -284,63 +287,66 @@ public class MinecraftCodec { .registerClientboundPacket(0x5C, ClientboundSoundEntityPacket.class, ClientboundSoundEntityPacket::new) .registerClientboundPacket(0x5D, ClientboundSoundPacket.class, ClientboundSoundPacket::new) .registerClientboundPacket(0x5E, ClientboundStopSoundPacket.class, ClientboundStopSoundPacket::new) - .registerClientboundPacket(0x5F, ClientboundTabListPacket.class, ClientboundTabListPacket::new) - .registerClientboundPacket(0x60, ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new) - .registerClientboundPacket(0x61, ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new) - .registerClientboundPacket(0x62, ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new) - .registerClientboundPacket(0x63, ClientboundUpdateAdvancementsPacket.class, ClientboundUpdateAdvancementsPacket::new) - .registerClientboundPacket(0x64, ClientboundUpdateAttributesPacket.class, ClientboundUpdateAttributesPacket::new) - .registerClientboundPacket(0x65, ClientboundUpdateMobEffectPacket.class, ClientboundUpdateMobEffectPacket::new) - .registerClientboundPacket(0x66, ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new) - .registerClientboundPacket(0x67, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new) + .registerClientboundPacket(0x5F, ClientboundSystemChatPacket.class, ClientboundSystemChatPacket::new) + .registerClientboundPacket(0x60, ClientboundTabListPacket.class, ClientboundTabListPacket::new) + .registerClientboundPacket(0x61, ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new) + .registerClientboundPacket(0x62, ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new) + .registerClientboundPacket(0x63, ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new) + .registerClientboundPacket(0x64, ClientboundUpdateAdvancementsPacket.class, ClientboundUpdateAdvancementsPacket::new) + .registerClientboundPacket(0x65, ClientboundUpdateAttributesPacket.class, ClientboundUpdateAttributesPacket::new) + .registerClientboundPacket(0x66, ClientboundUpdateMobEffectPacket.class, ClientboundUpdateMobEffectPacket::new) + .registerClientboundPacket(0x67, ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new) + .registerClientboundPacket(0x68, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new) .registerServerboundPacket(0x00, ServerboundAcceptTeleportationPacket.class, ServerboundAcceptTeleportationPacket::new) .registerServerboundPacket(0x01, ServerboundBlockEntityTagQuery.class, ServerboundBlockEntityTagQuery::new) .registerServerboundPacket(0x02, ServerboundChangeDifficultyPacket.class, ServerboundChangeDifficultyPacket::new) - .registerServerboundPacket(0x03, ServerboundChatPacket.class, ServerboundChatPacket::new) - .registerServerboundPacket(0x04, ServerboundClientCommandPacket.class, ServerboundClientCommandPacket::new) - .registerServerboundPacket(0x05, ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new) - .registerServerboundPacket(0x06, ServerboundCommandSuggestionPacket.class, ServerboundCommandSuggestionPacket::new) - .registerServerboundPacket(0x07, ServerboundContainerButtonClickPacket.class, ServerboundContainerButtonClickPacket::new) - .registerServerboundPacket(0x08, ServerboundContainerClickPacket.class, ServerboundContainerClickPacket::new) - .registerServerboundPacket(0x09, ServerboundContainerClosePacket.class, ServerboundContainerClosePacket::new) - .registerServerboundPacket(0x0A, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new) - .registerServerboundPacket(0x0B, ServerboundEditBookPacket.class, ServerboundEditBookPacket::new) - .registerServerboundPacket(0x0C, ServerboundEntityTagQuery.class, ServerboundEntityTagQuery::new) - .registerServerboundPacket(0x0D, ServerboundInteractPacket.class, ServerboundInteractPacket::new) - .registerServerboundPacket(0x0E, ServerboundJigsawGeneratePacket.class, ServerboundJigsawGeneratePacket::new) - .registerServerboundPacket(0x0F, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new) - .registerServerboundPacket(0x10, ServerboundLockDifficultyPacket.class, ServerboundLockDifficultyPacket::new) - .registerServerboundPacket(0x11, ServerboundMovePlayerPosPacket.class, ServerboundMovePlayerPosPacket::new) - .registerServerboundPacket(0x12, ServerboundMovePlayerPosRotPacket.class, ServerboundMovePlayerPosRotPacket::new) - .registerServerboundPacket(0x13, ServerboundMovePlayerRotPacket.class, ServerboundMovePlayerRotPacket::new) - .registerServerboundPacket(0x14, ServerboundMovePlayerStatusOnlyPacket.class, ServerboundMovePlayerStatusOnlyPacket::new) - .registerServerboundPacket(0x15, ServerboundMoveVehiclePacket.class, ServerboundMoveVehiclePacket::new) - .registerServerboundPacket(0x16, ServerboundPaddleBoatPacket.class, ServerboundPaddleBoatPacket::new) - .registerServerboundPacket(0x17, ServerboundPickItemPacket.class, ServerboundPickItemPacket::new) - .registerServerboundPacket(0x18, ServerboundPlaceRecipePacket.class, ServerboundPlaceRecipePacket::new) - .registerServerboundPacket(0x19, ServerboundPlayerAbilitiesPacket.class, ServerboundPlayerAbilitiesPacket::new) - .registerServerboundPacket(0x1A, ServerboundPlayerActionPacket.class, ServerboundPlayerActionPacket::new) - .registerServerboundPacket(0x1B, ServerboundPlayerCommandPacket.class, ServerboundPlayerCommandPacket::new) - .registerServerboundPacket(0x1C, ServerboundPlayerInputPacket.class, ServerboundPlayerInputPacket::new) - .registerServerboundPacket(0x1D, ServerboundPongPacket.class, ServerboundPongPacket::new) - .registerServerboundPacket(0x1E, ServerboundRecipeBookChangeSettingsPacket.class, ServerboundRecipeBookChangeSettingsPacket::new) - .registerServerboundPacket(0x1F, ServerboundRecipeBookSeenRecipePacket.class, ServerboundRecipeBookSeenRecipePacket::new) - .registerServerboundPacket(0x20, ServerboundRenameItemPacket.class, ServerboundRenameItemPacket::new) - .registerServerboundPacket(0x21, ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new) - .registerServerboundPacket(0x22, ServerboundSeenAdvancementsPacket.class, ServerboundSeenAdvancementsPacket::new) - .registerServerboundPacket(0x23, ServerboundSelectTradePacket.class, ServerboundSelectTradePacket::new) - .registerServerboundPacket(0x24, ServerboundSetBeaconPacket.class, ServerboundSetBeaconPacket::new) - .registerServerboundPacket(0x25, ServerboundSetCarriedItemPacket.class, ServerboundSetCarriedItemPacket::new) - .registerServerboundPacket(0x26, ServerboundSetCommandBlockPacket.class, ServerboundSetCommandBlockPacket::new) - .registerServerboundPacket(0x27, ServerboundSetCommandMinecartPacket.class, ServerboundSetCommandMinecartPacket::new) - .registerServerboundPacket(0x28, ServerboundSetCreativeModeSlotPacket.class, ServerboundSetCreativeModeSlotPacket::new) - .registerServerboundPacket(0x29, ServerboundSetJigsawBlockPacket.class, ServerboundSetJigsawBlockPacket::new) - .registerServerboundPacket(0x2A, ServerboundSetStructureBlockPacket.class, ServerboundSetStructureBlockPacket::new) - .registerServerboundPacket(0x2B, ServerboundSignUpdatePacket.class, ServerboundSignUpdatePacket::new) - .registerServerboundPacket(0x2C, ServerboundSwingPacket.class, ServerboundSwingPacket::new) - .registerServerboundPacket(0x2D, ServerboundTeleportToEntityPacket.class, ServerboundTeleportToEntityPacket::new) - .registerServerboundPacket(0x2E, ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new) - .registerServerboundPacket(0x2F, ServerboundUseItemPacket.class, ServerboundUseItemPacket::new) + .registerClientboundPacket(0x03, ServerboundChatCommandPacket.class, ServerboundChatCommandPacket::new) + .registerServerboundPacket(0x04, ServerboundChatPacket.class, ServerboundChatPacket::new) + .registerServerboundPacket(0x05, ServerboundChatPreviewPacket.class, ServerboundChatPreviewPacket::new) + .registerServerboundPacket(0x06, ServerboundClientCommandPacket.class, ServerboundClientCommandPacket::new) + .registerServerboundPacket(0x07, ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new) + .registerServerboundPacket(0x08, ServerboundCommandSuggestionPacket.class, ServerboundCommandSuggestionPacket::new) + .registerServerboundPacket(0x09, ServerboundContainerButtonClickPacket.class, ServerboundContainerButtonClickPacket::new) + .registerServerboundPacket(0x0A, ServerboundContainerClickPacket.class, ServerboundContainerClickPacket::new) + .registerServerboundPacket(0x0B, ServerboundContainerClosePacket.class, ServerboundContainerClosePacket::new) + .registerServerboundPacket(0x0C, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new) + .registerServerboundPacket(0x0D, ServerboundEditBookPacket.class, ServerboundEditBookPacket::new) + .registerServerboundPacket(0x0E, ServerboundEntityTagQuery.class, ServerboundEntityTagQuery::new) + .registerServerboundPacket(0x0F, ServerboundInteractPacket.class, ServerboundInteractPacket::new) + .registerServerboundPacket(0x10, ServerboundJigsawGeneratePacket.class, ServerboundJigsawGeneratePacket::new) + .registerServerboundPacket(0x11, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new) + .registerServerboundPacket(0x12, ServerboundLockDifficultyPacket.class, ServerboundLockDifficultyPacket::new) + .registerServerboundPacket(0x13, ServerboundMovePlayerPosPacket.class, ServerboundMovePlayerPosPacket::new) + .registerServerboundPacket(0x14, ServerboundMovePlayerPosRotPacket.class, ServerboundMovePlayerPosRotPacket::new) + .registerServerboundPacket(0x15, ServerboundMovePlayerRotPacket.class, ServerboundMovePlayerRotPacket::new) + .registerServerboundPacket(0x16, ServerboundMovePlayerStatusOnlyPacket.class, ServerboundMovePlayerStatusOnlyPacket::new) + .registerServerboundPacket(0x17, ServerboundMoveVehiclePacket.class, ServerboundMoveVehiclePacket::new) + .registerServerboundPacket(0x18, ServerboundPaddleBoatPacket.class, ServerboundPaddleBoatPacket::new) + .registerServerboundPacket(0x19, ServerboundPickItemPacket.class, ServerboundPickItemPacket::new) + .registerServerboundPacket(0x1A, ServerboundPlaceRecipePacket.class, ServerboundPlaceRecipePacket::new) + .registerServerboundPacket(0x1B, ServerboundPlayerAbilitiesPacket.class, ServerboundPlayerAbilitiesPacket::new) + .registerServerboundPacket(0x1C, ServerboundPlayerActionPacket.class, ServerboundPlayerActionPacket::new) + .registerServerboundPacket(0x1D, ServerboundPlayerCommandPacket.class, ServerboundPlayerCommandPacket::new) + .registerServerboundPacket(0x1E, ServerboundPlayerInputPacket.class, ServerboundPlayerInputPacket::new) + .registerServerboundPacket(0x1F, ServerboundPongPacket.class, ServerboundPongPacket::new) + .registerServerboundPacket(0x20, ServerboundRecipeBookChangeSettingsPacket.class, ServerboundRecipeBookChangeSettingsPacket::new) + .registerServerboundPacket(0x21, ServerboundRecipeBookSeenRecipePacket.class, ServerboundRecipeBookSeenRecipePacket::new) + .registerServerboundPacket(0x22, ServerboundRenameItemPacket.class, ServerboundRenameItemPacket::new) + .registerServerboundPacket(0x23, ServerboundResourcePackPacket.class, ServerboundResourcePackPacket::new) + .registerServerboundPacket(0x24, ServerboundSeenAdvancementsPacket.class, ServerboundSeenAdvancementsPacket::new) + .registerServerboundPacket(0x25, ServerboundSelectTradePacket.class, ServerboundSelectTradePacket::new) + .registerServerboundPacket(0x26, ServerboundSetBeaconPacket.class, ServerboundSetBeaconPacket::new) + .registerServerboundPacket(0x27, ServerboundSetCarriedItemPacket.class, ServerboundSetCarriedItemPacket::new) + .registerServerboundPacket(0x28, ServerboundSetCommandBlockPacket.class, ServerboundSetCommandBlockPacket::new) + .registerServerboundPacket(0x29, ServerboundSetCommandMinecartPacket.class, ServerboundSetCommandMinecartPacket::new) + .registerServerboundPacket(0x2A, ServerboundSetCreativeModeSlotPacket.class, ServerboundSetCreativeModeSlotPacket::new) + .registerServerboundPacket(0x2B, ServerboundSetJigsawBlockPacket.class, ServerboundSetJigsawBlockPacket::new) + .registerServerboundPacket(0x2C, ServerboundSetStructureBlockPacket.class, ServerboundSetStructureBlockPacket::new) + .registerServerboundPacket(0x2D, ServerboundSignUpdatePacket.class, ServerboundSignUpdatePacket::new) + .registerServerboundPacket(0x2E, ServerboundSwingPacket.class, ServerboundSwingPacket::new) + .registerServerboundPacket(0x2F, ServerboundTeleportToEntityPacket.class, ServerboundTeleportToEntityPacket::new) + .registerServerboundPacket(0x30, ServerboundUseItemOnPacket.class, ServerboundUseItemOnPacket::new) + .registerServerboundPacket(0x31, ServerboundUseItemPacket.class, ServerboundUseItemPacket::new) ) .build(); } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index 23b9ed375..ac4c02c35 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -163,7 +163,12 @@ public class MagicValues { register(MessageType.CHAT, 0); register(MessageType.SYSTEM, 1); - register(MessageType.NOTIFICATION, 2); + register(MessageType.GAME_INFO, 2); + register(MessageType.SAY_COMMAND, 3); + register(MessageType.MSG_COMMAND, 4); + register(MessageType.TEAM_MSG_COMMAND, 5); + register(MessageType.EMOTE_COMMAND, 6); + register(MessageType.TELLRAW_COMMAND, 7); register(GameMode.UNKNOWN, 255); // https://bugs.mojang.com/browse/MC-189885 - should be -1 register(GameMode.SURVIVAL, 0); @@ -664,54 +669,54 @@ public class MagicValues { register(CommandType.LITERAL, 1); register(CommandType.ARGUMENT, 2); - register(CommandParser.BOOL, "brigadier:bool"); - register(CommandParser.DOUBLE, "brigadier:double"); - register(CommandParser.FLOAT, "brigadier:float"); - register(CommandParser.INTEGER, "brigadier:integer"); - register(CommandParser.LONG, "brigadier:long"); - register(CommandParser.STRING, "brigadier:string"); - register(CommandParser.ENTITY, "minecraft:entity"); - register(CommandParser.GAME_PROFILE, "minecraft:game_profile"); - register(CommandParser.BLOCK_POS, "minecraft:block_pos"); - register(CommandParser.COLUMN_POS, "minecraft:column_pos"); - register(CommandParser.VEC3, "minecraft:vec3"); - register(CommandParser.VEC2, "minecraft:vec2"); - register(CommandParser.BLOCK_STATE, "minecraft:block_state"); - register(CommandParser.BLOCK_PREDICATE, "minecraft:block_predicate"); - register(CommandParser.ITEM_STACK, "minecraft:item_stack"); - register(CommandParser.ITEM_PREDICATE, "minecraft:item_predicate"); - register(CommandParser.COLOR, "minecraft:color"); - register(CommandParser.COMPONENT, "minecraft:component"); - register(CommandParser.MESSAGE, "minecraft:message"); - register(CommandParser.NBT, "minecraft:nbt"); - register(CommandParser.NBT_PATH, "minecraft:nbt_path"); - register(CommandParser.OBJECTIVE, "minecraft:objective"); - register(CommandParser.OBJECTIVE_CRITERIA, "minecraft:objective_criteria"); - register(CommandParser.OPERATION, "minecraft:operation"); - register(CommandParser.PARTICLE, "minecraft:particle"); - register(CommandParser.ROTATION, "minecraft:rotation"); - register(CommandParser.SCOREBOARD_SLOT, "minecraft:scoreboard_slot"); - register(CommandParser.SCORE_HOLDER, "minecraft:score_holder"); - register(CommandParser.SWIZZLE, "minecraft:swizzle"); - register(CommandParser.TEAM, "minecraft:team"); - register(CommandParser.UUID, "minecraft:uuid"); - register(CommandParser.ITEM_SLOT, "minecraft:item_slot"); - register(CommandParser.RESOURCE_LOCATION, "minecraft:resource_location"); - register(CommandParser.MOB_EFFECT, "minecraft:mob_effect"); - register(CommandParser.FUNCTION, "minecraft:function"); - register(CommandParser.ENTITY_ANCHOR, "minecraft:entity_anchor"); - register(CommandParser.RANGE, "minecraft:range"); - register(CommandParser.INT_RANGE, "minecraft:int_range"); - register(CommandParser.FLOAT_RANGE, "minecraft:float_range"); - register(CommandParser.ITEM_ENCHANTMENT, "minecraft:item_enchantment"); - register(CommandParser.ENTITY_SUMMON, "minecraft:entity_summon"); - register(CommandParser.DIMENSION, "minecraft:dimension"); - register(CommandParser.TIME, "minecraft:time"); - register(CommandParser.NBT_COMPOUND_TAG, "minecraft:nbt_compound_tag"); - register(CommandParser.NBT_TAG, "minecraft:nbt_tag"); - register(CommandParser.ANGLE, "minecraft:angle"); - register(CommandParser.RESOURCE, "minecraft:resource"); - register(CommandParser.RESOURCE_OR_TAG, "minecraft:resource_or_tag"); + register(CommandParser.BOOL, 0); + register(CommandParser.FLOAT, 1); + register(CommandParser.DOUBLE, 2); + register(CommandParser.INTEGER, 3); + register(CommandParser.LONG, 4); + register(CommandParser.STRING, 5); + register(CommandParser.ENTITY, 6); + register(CommandParser.GAME_PROFILE, 7); + register(CommandParser.BLOCK_POS, 8); + register(CommandParser.COLUMN_POS, 9); + register(CommandParser.VEC3, 10); + register(CommandParser.VEC2, 11); + register(CommandParser.BLOCK_STATE, 12); + register(CommandParser.BLOCK_PREDICATE, 13); + register(CommandParser.ITEM_STACK, 14); + register(CommandParser.ITEM_PREDICATE, 15); + register(CommandParser.COLOR, 16); + register(CommandParser.COMPONENT, 17); + register(CommandParser.MESSAGE, 18); + register(CommandParser.NBT_COMPOUND_TAG, 19); + register(CommandParser.NBT_TAG, 20); + register(CommandParser.NBT_PATH, 21); + register(CommandParser.OBJECTIVE, 22); + register(CommandParser.OBJECTIVE_CRITERIA, 23); + register(CommandParser.OPERATION, 24); + register(CommandParser.PARTICLE, 25); + register(CommandParser.ANGLE, 26); + register(CommandParser.ROTATION, 27); + register(CommandParser.SCOREBOARD_SLOT, 28); + register(CommandParser.SCORE_HOLDER, 29); + register(CommandParser.SWIZZLE, 30); + register(CommandParser.TEAM, 31); + register(CommandParser.ITEM_SLOT, 32); + register(CommandParser.RESOURCE_LOCATION, 33); + register(CommandParser.MOB_EFFECT, 34); + register(CommandParser.FUNCTION, 35); + register(CommandParser.ENTITY_ANCHOR, 36); + register(CommandParser.INT_RANGE, 37); + register(CommandParser.FLOAT_RANGE, 38); + register(CommandParser.ITEM_ENCHANTMENT, 39); + register(CommandParser.ENTITY_SUMMON, 40); + register(CommandParser.DIMENSION, 41); + register(CommandParser.TIME, 42); + register(CommandParser.RESOURCE_OR_TAG, 43); + register(CommandParser.RESOURCE, 44); + register(CommandParser.TEMPLATE_MIRROR, 45); + register(CommandParser.TEMPLATE_ROTATION, 46); + register(CommandParser.UUID, 47); register(SuggestionType.ASK_SERVER, "minecraft:ask_server"); register(SuggestionType.ALL_RECIPES, "minecraft:all_recipes"); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/MessageType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/MessageType.java index f6bfb9392..300b8ea2f 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/MessageType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/MessageType.java @@ -3,5 +3,10 @@ public enum MessageType { CHAT, SYSTEM, - NOTIFICATION; + GAME_INFO, + SAY_COMMAND, + MSG_COMMAND, + TEAM_MSG_COMMAND, + EMOTE_COMMAND, + TELLRAW_COMMAND; } 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 65a324a35..469307976 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 @@ -7,6 +7,8 @@ import lombok.NonNull; import net.kyori.adventure.text.Component; +import java.security.PublicKey; + @Data @AllArgsConstructor public class PlayerListEntry { @@ -14,20 +16,23 @@ public class PlayerListEntry { private final GameMode gameMode; private final int ping; private final Component displayName; + private final long expiresAt; + private final PublicKey publicKey; + private final byte[] keySignature; public PlayerListEntry(GameProfile profile) { - this(profile, null, 0, null); + this(profile, null, 0, null, 0, null, null); } public PlayerListEntry(GameProfile profile, GameMode gameMode) { - this(profile, gameMode, 0, null); + this(profile, gameMode, 0, null, 0, null, null); } public PlayerListEntry(GameProfile profile, int ping) { - this(profile, null, ping, null); + this(profile, null, ping, null, 0, null, null); } public PlayerListEntry(GameProfile profile, Component displayName) { - this(profile, null, 0, displayName); + this(profile, null, 0, displayName, 0, null, null); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java index 6bf47b742..691e7adc2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java @@ -21,7 +21,6 @@ public enum CommandParser { COLOR, COMPONENT, MESSAGE, - NBT, NBT_COMPOUND_TAG, NBT_TAG, NBT_PATH, @@ -48,5 +47,7 @@ public enum CommandParser { DIMENSION, TIME, RESOURCE, - RESOURCE_OR_TAG + RESOURCE_OR_TAG, + TEMPLATE_MIRROR, + TEMPLATE_ROTATION; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java index 5261a1c9a..1ebbb4bc2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/block/BlockEntityType.java @@ -39,7 +39,9 @@ public enum BlockEntityType { JIGSAW, CAMPFIRE, BEEHIVE, - SCULK_SENSOR; + SCULK_SENSOR, + SCULK_CATALYST, + SCULK_SHRIEKER; private static final BlockEntityType[] VALUES = values(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/status/ServerStatusInfo.java b/src/main/java/com/github/steveice10/mc/protocol/data/status/ServerStatusInfo.java index 678728975..103830983 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/status/ServerStatusInfo.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/status/ServerStatusInfo.java @@ -15,4 +15,5 @@ public class ServerStatusInfo { private @NonNull PlayerInfo playerInfo; private @NonNull Component description; private byte[] iconPng; + private boolean previewsChat; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPacket.java deleted file mode 100644 index e20ca6cc9..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPacket.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound; - -import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; -import com.github.steveice10.mc.protocol.data.MagicValues; -import com.github.steveice10.mc.protocol.data.game.MessageType; -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import com.github.steveice10.packetlib.packet.Packet; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NonNull; -import lombok.With; -import net.kyori.adventure.text.Component; - -import java.io.IOException; -import java.util.UUID; - -@Data -@With -@AllArgsConstructor -public class ClientboundChatPacket implements Packet { - private final @NonNull Component message; - private final @NonNull MessageType type; - private final @NonNull UUID senderUuid; - - public ClientboundChatPacket(@NonNull String text) { - this(DefaultComponentSerializer.get().deserialize(text)); - } - - public ClientboundChatPacket(@NonNull Component message) { - this(message, MessageType.SYSTEM); - } - - public ClientboundChatPacket(@NonNull String text, @NonNull MessageType type) { - this(DefaultComponentSerializer.get().deserialize(text), type, new UUID(0, 0)); - } - - public ClientboundChatPacket(@NonNull Component message, @NonNull MessageType type) { - this(message, type, new UUID(0, 0)); - } - - public ClientboundChatPacket(@NonNull String text, @NonNull MessageType type, @NonNull UUID uuid) { - this(DefaultComponentSerializer.get().deserialize(text), type, uuid); - } - - public ClientboundChatPacket(NetInput in) throws IOException { - this.message = DefaultComponentSerializer.get().deserialize(in.readString()); - this.type = MagicValues.key(MessageType.class, in.readByte()); - this.senderUuid = in.readUUID(); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeString(DefaultComponentSerializer.get().serialize(this.message)); - out.writeByte(MagicValues.value(Integer.class, this.type)); - out.writeUUID(this.senderUuid); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPreviewPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPreviewPacket.java new file mode 100644 index 000000000..7e22b3698 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundChatPreviewPacket.java @@ -0,0 +1,38 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound; + +import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; +import net.kyori.adventure.text.Component; + +import javax.annotation.Nullable; +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundChatPreviewPacket implements Packet { + private final int queryId; + private final @Nullable Component preview; + + public ClientboundChatPreviewPacket(NetInput in) throws IOException { + this.queryId = in.readInt(); + if (in.readBoolean()) { + this.preview = DefaultComponentSerializer.get().deserialize(in.readString()); + } else { + this.preview = null; + } + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(this.queryId); + if (this.preview != null) { + out.writeString(DefaultComponentSerializer.get().serialize(this.preview)); + } + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java index 83deaa6c3..eba344384 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java @@ -69,9 +69,7 @@ public ClientboundCommandsPacket(NetInput in) throws IOException { CommandParser parser = null; CommandProperties properties = null; if (type == CommandType.ARGUMENT) { - String identifier = Identifier.formalize(in.readString()); - if (identifier.equals("minecraft:")) continue; - parser = MagicValues.key(CommandParser.class, identifier); + parser = MagicValues.key(CommandParser.class, in.readVarInt()); switch (parser) { case DOUBLE: { byte numberFlags = in.readByte(); @@ -120,18 +118,14 @@ public ClientboundCommandsPacket(NetInput in) throws IOException { } case LONG: { byte numberFlags = in.readByte(); - long min; - long max; + long min = Long.MIN_VALUE; + long max = Long.MAX_VALUE; if ((numberFlags & NUMBER_FLAG_MIN_DEFINED) != 0) { min = in.readLong(); - } else { - min = Long.MIN_VALUE; } if ((numberFlags & NUMBER_FLAG_MAX_DEFINED) != 0) { max = in.readLong(); - } else { - max = Long.MAX_VALUE; } properties = new LongProperties(min, max); @@ -205,7 +199,7 @@ public void write(NetOutput out) throws IOException { } if (node.getType() == CommandType.ARGUMENT) { - out.writeString(MagicValues.value(String.class, node.getParser())); + out.writeVarInt(MagicValues.value(Integer.class, node.getParser())); switch (node.getParser()) { case DOUBLE: { DoubleProperties properties = (DoubleProperties) node.getProperties(); 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 dbaac9a03..27b4a3657 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundLoginPacket.java @@ -27,7 +27,7 @@ public class ClientboundLoginPacket implements Packet { private final int worldCount; private final @NonNull String[] worldNames; private final @NonNull CompoundTag dimensionCodec; - private final @NonNull CompoundTag dimension; + private final @NonNull String dimension; private final @NonNull String worldName; private final long hashedSeed; private final int maxPlayers; @@ -51,7 +51,7 @@ public ClientboundLoginPacket(NetInput in) throws IOException { this.worldNames[i] = in.readString(); } this.dimensionCodec = NBT.read(in); - this.dimension = NBT.read(in); + this.dimension = in.readString(); this.worldName = in.readString(); this.hashedSeed = in.readLong(); this.maxPlayers = in.readVarInt(); @@ -77,7 +77,7 @@ public void write(NetOutput out) throws IOException { out.writeString(worldName); } NBT.write(out, this.dimensionCodec); - NBT.write(out, this.dimension); + out.writeString(this.dimension); out.writeString(this.worldName); out.writeLong(this.hashedSeed); out.writeVarInt(this.maxPlayers); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java new file mode 100644 index 000000000..7f740930a --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerChatPacket.java @@ -0,0 +1,73 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound; + +import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; +import com.github.steveice10.mc.protocol.data.MagicValues; +import com.github.steveice10.mc.protocol.data.game.MessageType; +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; +import net.kyori.adventure.text.Component; + +import javax.annotation.Nullable; +import java.io.IOException; +import java.util.UUID; + +@Data +@With +@AllArgsConstructor +public class ClientboundPlayerChatPacket implements Packet { + private final Component signedContent; + private final @Nullable Component unsignedContent; + private final MessageType type; + private final UUID senderUUID; + private final Component senderName; + private final @Nullable Component senderTeamName; + private final long salt; + private final byte[] signature; + private final long timeStamp; + + public ClientboundPlayerChatPacket(NetInput in) throws IOException { + this.signedContent = DefaultComponentSerializer.get().deserialize(in.readString()); + if (in.readBoolean()) { + this.unsignedContent = DefaultComponentSerializer.get().deserialize(in.readString()); + } else { + this.unsignedContent = null; + } + + this.type = MagicValues.key(MessageType.class, in.readVarInt()); + this.senderUUID = in.readUUID(); + this.senderName = DefaultComponentSerializer.get().deserialize(in.readString()); + if (in.readBoolean()) { + this.senderTeamName = DefaultComponentSerializer.get().deserialize(in.readString()); + } else { + this.senderTeamName = null; + } + + this.salt = in.readLong(); + this.signature = in.readBytes(in.readVarInt()); + this.timeStamp = in.readLong(); + } + + @Override + public void write(NetOutput out) throws IOException { + DefaultComponentSerializer.get().serialize(this.signedContent); + if (this.unsignedContent != null) { + DefaultComponentSerializer.get().serialize(this.unsignedContent); + } + + out.writeVarInt(MagicValues.value(Integer.class, this.type)); + out.writeUUID(this.senderUUID); + DefaultComponentSerializer.get().serialize(this.senderName); + if (this.senderTeamName != null) { + DefaultComponentSerializer.get().serialize(this.senderTeamName); + } + + out.writeLong(this.timeStamp); + out.writeLong(this.salt); + out.writeVarInt(this.signature.length); + out.writeBytes(this.signature); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoPacket.java index 0f918b98b..834c3ba3c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundPlayerInfoPacket.java @@ -16,6 +16,10 @@ import net.kyori.adventure.text.Component; import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.X509EncodedKeySpec; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -65,7 +69,22 @@ public ClientboundPlayerInfoPacket(NetInput in) throws IOException { displayName = DefaultComponentSerializer.get().deserialize(in.readString()); } - entry = new PlayerListEntry(profile, gameMode, ping, displayName); + Long expiresAt = null; + PublicKey publicKey = null; + byte[] keySignature = null; + if (in.readBoolean()) { + expiresAt = in.readLong(); + byte[] keyBytes = in.readBytes(in.readVarInt()); + keySignature = in.readBytes(in.readVarInt()); + + try { + publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(keyBytes)); + } catch (GeneralSecurityException e) { + throw new IOException("Could not decode public key.", e); + } + } + + entry = new PlayerListEntry(profile, gameMode, ping, displayName, expiresAt, publicKey, keySignature); break; } case UPDATE_GAMEMODE: { @@ -125,6 +144,15 @@ public void write(NetOutput out) throws IOException { out.writeString(DefaultComponentSerializer.get().serialize(entry.getDisplayName())); } + if (entry.getPublicKey() != null) { + out.writeLong(entry.getExpiresAt()); + byte[] encoded = entry.getPublicKey().getEncoded(); + out.writeVarInt(encoded.length); + out.writeBytes(encoded); + out.writeVarInt(entry.getKeySignature().length); + out.writeBytes(entry.getKeySignature()); + } + break; case UPDATE_GAMEMODE: out.writeVarInt(MagicValues.value(Integer.class, entry.getGameMode())); 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 bb05500a6..583434a05 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 @@ -18,7 +18,7 @@ @With @AllArgsConstructor public class ClientboundRespawnPacket implements Packet { - private final @NonNull CompoundTag dimension; + private final @NonNull String dimension; private final @NonNull String worldName; private final long hashedSeed; private final @NonNull GameMode gamemode; @@ -28,7 +28,7 @@ public class ClientboundRespawnPacket implements Packet { private final boolean copyMetadata; public ClientboundRespawnPacket(NetInput in) throws IOException { - this.dimension = NBT.read(in); + this.dimension = in.readString(); this.worldName = in.readString(); this.hashedSeed = in.readLong(); this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte()); @@ -40,7 +40,7 @@ public ClientboundRespawnPacket(NetInput in) throws IOException { @Override public void write(NetOutput out) throws IOException { - NBT.write(out, this.dimension); + out.writeString(this.dimension); out.writeString(this.worldName); out.writeLong(this.hashedSeed); out.writeByte(MagicValues.value(Integer.class, this.gamemode)); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java new file mode 100644 index 000000000..579a0d853 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundServerDataPacket.java @@ -0,0 +1,53 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound; + +import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; +import net.kyori.adventure.text.Component; + +import javax.annotation.Nullable; +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundServerDataPacket implements Packet { + private final @Nullable Component motd; + private final @Nullable String iconBase64; + private final boolean previewsChat; + + public ClientboundServerDataPacket(NetInput in) throws IOException { + if (in.readBoolean()) { + this.motd = DefaultComponentSerializer.get().deserialize(in.readString()); + } else { + this.motd = null; + } + + if (in.readBoolean()) { + this.iconBase64 = in.readString(); + } else { + this.iconBase64 = null; + } + + this.previewsChat = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeBoolean(this.motd != null); + if (this.motd != null) { + out.writeString(DefaultComponentSerializer.get().serialize(this.motd)); + } + + out.writeBoolean(this.iconBase64 != null); + if (this.iconBase64 != null) { + out.writeString(this.iconBase64); + } + + out.writeBoolean(this.previewsChat); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetDisplayChatPreviewPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetDisplayChatPreviewPacket.java new file mode 100644 index 000000000..37597b13c --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSetDisplayChatPreviewPacket.java @@ -0,0 +1,26 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound; + +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundSetDisplayChatPreviewPacket implements Packet { + private final boolean enabled; + + public ClientboundSetDisplayChatPreviewPacket(NetInput in) throws IOException { + this.enabled = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeBoolean(this.enabled); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java index ab678ef31..608b80593 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSoundEntityPacket.java @@ -21,6 +21,7 @@ public class ClientboundSoundEntityPacket implements Packet { private final int entityId; private final float volume; private final float pitch; + private final long seed; public ClientboundSoundEntityPacket(NetInput in) throws IOException { this.soundId = in.readVarInt(); @@ -28,6 +29,7 @@ public ClientboundSoundEntityPacket(NetInput in) throws IOException { this.entityId = in.readVarInt(); this.volume = in.readFloat(); this.pitch = in.readFloat(); + this.seed = in.readLong(); } @Override @@ -37,5 +39,6 @@ public void write(NetOutput out) throws IOException { out.writeVarInt(this.entityId); out.writeFloat(this.volume); out.writeFloat(this.pitch); + out.writeLong(this.seed); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java new file mode 100644 index 000000000..9fb2efff2 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundSystemChatPacket.java @@ -0,0 +1,33 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound; + +import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer; +import com.github.steveice10.mc.protocol.data.MagicValues; +import com.github.steveice10.mc.protocol.data.game.MessageType; +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; +import net.kyori.adventure.text.Component; + +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundSystemChatPacket implements Packet { + private final Component content; + private final MessageType type; + + public ClientboundSystemChatPacket(NetInput in) throws IOException { + this.content = DefaultComponentSerializer.get().deserialize(in.readString()); + this.type = MagicValues.key(MessageType.class, in.readVarInt()); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(DefaultComponentSerializer.get().serialize(this.content)); + out.writeVarInt(MagicValues.value(Integer.class, this.type)); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java index de73c47f2..111bdbc29 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/ClientboundUpdateMobEffectPacket.java @@ -1,6 +1,8 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity; +import com.github.steveice10.mc.protocol.data.game.NBT; import com.github.steveice10.mc.protocol.data.game.entity.Effect; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.packetlib.io.NetInput; import com.github.steveice10.packetlib.io.NetOutput; import com.github.steveice10.packetlib.packet.Packet; @@ -9,6 +11,7 @@ import lombok.NonNull; import lombok.With; +import javax.annotation.Nullable; import java.io.IOException; @Data @@ -24,6 +27,7 @@ public class ClientboundUpdateMobEffectPacket implements Packet { private final int duration; private final boolean ambient; private final boolean showParticles; + private final @Nullable CompoundTag factorData; public ClientboundUpdateMobEffectPacket(NetInput in) throws IOException { this.entityId = in.readVarInt(); @@ -34,6 +38,11 @@ public ClientboundUpdateMobEffectPacket(NetInput in) throws IOException { int flags = in.readByte(); this.ambient = (flags & FLAG_AMBIENT) != 0; this.showParticles = (flags & FLAG_SHOW_PARTICLES) != 0; + if (in.readBoolean()) { + this.factorData = NBT.read(in); + } else { + this.factorData = null; + } } @Override @@ -53,5 +62,9 @@ public void write(NetOutput out) throws IOException { } out.writeByte(flags); + out.writeBoolean(this.factorData != null); + if (this.factorData != null) { + NBT.write(out, this.factorData); + } } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockBreakAckPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockBreakAckPacket.java deleted file mode 100644 index 27b4fabdf..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockBreakAckPacket.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player; - -import com.github.steveice10.mc.protocol.data.MagicValues; -import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; -import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction; -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import com.github.steveice10.packetlib.packet.Packet; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NonNull; -import lombok.With; - -import java.io.IOException; - -@Data -@With -@AllArgsConstructor -public class ClientboundBlockBreakAckPacket implements Packet { - private final @NonNull PlayerAction action; - private final boolean successful; - private final @NonNull Position position; - private final int newState; - - public ClientboundBlockBreakAckPacket(NetInput in) throws IOException { - this.position = Position.read(in); - this.newState = in.readVarInt(); - this.action = MagicValues.key(PlayerAction.class, in.readVarInt()); - this.successful = in.readBoolean(); - } - - @Override - public void write(NetOutput out) throws IOException { - Position.write(out, this.position); - out.writeVarInt(this.newState); - out.writeVarInt(MagicValues.value(Integer.class, this.action)); - out.writeBoolean(this.successful); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java new file mode 100644 index 000000000..35b6a66d1 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/player/ClientboundBlockChangedAckPacket.java @@ -0,0 +1,26 @@ +package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player; + +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ClientboundBlockChangedAckPacket implements Packet { + private final int sequence; + + public ClientboundBlockChangedAckPacket(NetInput in) throws IOException { + this.sequence = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeVarInt(this.sequence); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java index d7d8cef8a..1ada183d9 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddEntityPacket.java @@ -34,25 +34,26 @@ public class ClientboundAddEntityPacket implements Packet { private final double y; private final double z; private final float yaw; + private final float headYaw; private final float pitch; private final double motionX; private final double motionY; private final double motionZ; public ClientboundAddEntityPacket(int entityId, @NonNull UUID uuid, @NonNull EntityType type, - double x, double y, double z, float yaw, float pitch) { - this(entityId, uuid, type, EMPTY_DATA, x, y, z, yaw, pitch, 0, 0, 0); + double x, double y, double z, float yaw, float pitch, float headYaw) { + this(entityId, uuid, type, EMPTY_DATA, x, y, z, yaw, headYaw, pitch, 0, 0, 0); } public ClientboundAddEntityPacket(int entityId, @NonNull UUID uuid, @NonNull EntityType type, @NonNull ObjectData data, - double x, double y, double z, float yaw, float pitch) { - this(entityId, uuid, type, data, x, y, z, yaw, pitch, 0, 0, 0); + double x, double y, double z, float yaw, float pitch, float headYaw) { + this(entityId, uuid, type, data, x, y, z, yaw, headYaw, pitch, 0, 0, 0); } public ClientboundAddEntityPacket(int entityId, @NonNull UUID uuid, @NonNull EntityType type, double x, double y, double z, float yaw, float pitch, - double motionX, double motionY, double motionZ) { - this(entityId, uuid, type, EMPTY_DATA, x, y, z, yaw, pitch, motionX, motionY, motionZ); + float headYaw, double motionX, double motionY, double motionZ) { + this(entityId, uuid, type, EMPTY_DATA, x, y, z, yaw, headYaw, pitch, motionX, motionY, motionZ); } public ClientboundAddEntityPacket(NetInput in) throws IOException { @@ -64,8 +65,9 @@ public ClientboundAddEntityPacket(NetInput in) throws IOException { this.z = in.readDouble(); this.pitch = in.readByte() * 360 / 256f; this.yaw = in.readByte() * 360 / 256f; + this.headYaw = in.readByte() * 360 / 256f; - int data = in.readInt(); + int data = in.readVarInt(); if (this.type == EntityType.MINECART) { this.data = MagicValues.key(MinecartType.class, data); } else if (this.type == EntityType.ITEM_FRAME || this.type == EntityType.GLOW_ITEM_FRAME) { @@ -100,6 +102,7 @@ public void write(NetOutput out) throws IOException { out.writeDouble(this.z); out.writeByte((byte) (this.pitch * 256 / 360)); out.writeByte((byte) (this.yaw * 256 / 360)); + out.writeByte((byte) (this.headYaw * 256 / 360)); int data = 0; if (this.data instanceof MinecartType) { @@ -116,7 +119,7 @@ public void write(NetOutput out) throws IOException { data = ((GenericObjectData) this.data).getValue(); } - out.writeInt(data); + out.writeVarInt(data); out.writeShort((int) (this.motionX * 8000)); out.writeShort((int) (this.motionY * 8000)); diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddMobPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddMobPacket.java deleted file mode 100644 index 7b3cf332f..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddMobPacket.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn; - -import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType; -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import com.github.steveice10.packetlib.packet.Packet; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NonNull; -import lombok.With; - -import java.io.IOException; -import java.util.UUID; - -@Data -@With -@AllArgsConstructor -public class ClientboundAddMobPacket implements Packet { - private final int entityId; - private final @NonNull UUID uuid; - private final @NonNull EntityType type; - private final double x; - private final double y; - private final double z; - private final float pitch; - private final float yaw; - private final float headYaw; - private final double motionX; - private final double motionY; - private final double motionZ; - - public ClientboundAddMobPacket(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.uuid = in.readUUID(); - this.type = EntityType.read(in); - this.x = in.readDouble(); - this.y = in.readDouble(); - this.z = in.readDouble(); - this.yaw = in.readByte() * 360 / 256f; - this.pitch = in.readByte() * 360 / 256f; - this.headYaw = in.readByte() * 360 / 256f; - this.motionX = in.readShort() / 8000D; - this.motionY = in.readShort() / 8000D; - this.motionZ = in.readShort() / 8000D; - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeUUID(this.uuid); - out.writeVarInt(this.type.ordinal()); - out.writeDouble(this.x); - out.writeDouble(this.y); - out.writeDouble(this.z); - out.writeByte((byte) (this.yaw * 256 / 360)); - out.writeByte((byte) (this.pitch * 256 / 360)); - out.writeByte((byte) (this.headYaw * 256 / 360)); - out.writeShort((int) (this.motionX * 8000)); - out.writeShort((int) (this.motionY * 8000)); - out.writeShort((int) (this.motionZ * 8000)); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddPaintingPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddPaintingPacket.java deleted file mode 100644 index b436eaafe..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/entity/spawn/ClientboundAddPaintingPacket.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn; - -import com.github.steveice10.mc.protocol.data.MagicValues; -import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; -import com.github.steveice10.mc.protocol.data.game.entity.object.Direction; -import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType; -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import com.github.steveice10.packetlib.packet.Packet; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NonNull; -import lombok.With; - -import java.io.IOException; -import java.util.UUID; - -@Data -@With -@AllArgsConstructor -public class ClientboundAddPaintingPacket implements Packet { - private final int entityId; - private final @NonNull UUID uuid; - private final @NonNull PaintingType paintingType; - private final @NonNull Position position; - private final @NonNull Direction direction; - - public ClientboundAddPaintingPacket(NetInput in) throws IOException { - this.entityId = in.readVarInt(); - this.uuid = in.readUUID(); - this.paintingType = MagicValues.key(PaintingType.class, in.readVarInt()); - this.position = Position.read(in); - this.direction = Direction.getByHorizontalIndex(in.readUnsignedByte()); - } - - @Override - public void write(NetOutput out) throws IOException { - out.writeVarInt(this.entityId); - out.writeUUID(this.uuid); - out.writeVarInt(MagicValues.value(Integer.class, this.paintingType)); - Position.write(out, this.position); - out.writeByte(this.direction.getHorizontalIndex()); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundAddVibrationSignalPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundAddVibrationSignalPacket.java deleted file mode 100644 index f53223199..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundAddVibrationSignalPacket.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level; - -import com.github.steveice10.mc.protocol.data.game.Identifier; -import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; -import com.github.steveice10.mc.protocol.data.game.level.vibration.BlockVibrationSource; -import com.github.steveice10.mc.protocol.data.game.level.vibration.EntityVibrationSource; -import com.github.steveice10.mc.protocol.data.game.level.vibration.VibrationSource; -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import com.github.steveice10.packetlib.packet.Packet; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NonNull; -import lombok.With; - -import java.io.IOException; - -@Data -@With -@AllArgsConstructor -public class ClientboundAddVibrationSignalPacket implements Packet { - private final @NonNull Position origin; - private final @NonNull VibrationSource destination; - private final int arrivalInTicks; - - public ClientboundAddVibrationSignalPacket(NetInput in) throws IOException { - this.origin = Position.read(in); - String identifier = Identifier.formalize(in.readString()); - switch (identifier) { - case "minecraft:block": - this.destination = BlockVibrationSource.read(in); - break; - case "minecraft:entity": - this.destination = EntityVibrationSource.read(in); - break; - default: - throw new IllegalStateException(); - } - this.arrivalInTicks = in.readVarInt(); - } - - @Override - public void write(NetOutput out) throws IOException { - Position.write(out, this.origin); - if (this.destination instanceof BlockVibrationSource) { - out.writeString("minecraft:block"); - BlockVibrationSource.write(out, (BlockVibrationSource) this.destination); - } else if (this.destination instanceof EntityVibrationSource) { - out.writeString("minecraft:entity"); - EntityVibrationSource.write(out, (EntityVibrationSource) this.destination); - } - out.writeVarInt(this.arrivalInTicks); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundCustomSoundPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundCustomSoundPacket.java index 7d538121b..50ec47616 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundCustomSoundPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundCustomSoundPacket.java @@ -26,6 +26,7 @@ public class ClientboundCustomSoundPacket implements Packet { private final double z; private final float volume; private final float pitch; + private final long seed; public ClientboundCustomSoundPacket(NetInput in) throws IOException { String value = in.readString(); @@ -42,6 +43,7 @@ public ClientboundCustomSoundPacket(NetInput in) throws IOException { this.z = in.readInt() / 8D; this.volume = in.readFloat(); this.pitch = in.readFloat(); + this.seed = in.readLong(); } @Override @@ -60,5 +62,6 @@ public void write(NetOutput out) throws IOException { out.writeInt((int) (this.z * 8)); out.writeFloat(this.volume); out.writeFloat(this.pitch); + out.writeLong(this.seed); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java index 72652d36d..5fa2098c1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/level/ClientboundSoundPacket.java @@ -24,6 +24,7 @@ public class ClientboundSoundPacket implements Packet { private final double z; private final float volume; private final float pitch; + private final long seed; public ClientboundSoundPacket(NetInput in) throws IOException { this.sound = BuiltinSound.VALUES[in.readVarInt()]; @@ -33,6 +34,7 @@ public ClientboundSoundPacket(NetInput in) throws IOException { this.z = in.readInt() / 8D; this.volume = in.readFloat(); this.pitch = in.readFloat(); + this.seed = in.readLong(); } @Override @@ -44,5 +46,6 @@ public void write(NetOutput out) throws IOException { out.writeInt((int) (this.z * 8)); out.writeFloat(this.volume); out.writeFloat(this.pitch); + out.writeLong(this.seed); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java new file mode 100644 index 000000000..7a245aec1 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatCommandPacket.java @@ -0,0 +1,53 @@ +package com.github.steveice10.mc.protocol.packet.ingame.serverbound; + +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +@Data +@With +@AllArgsConstructor +public class ServerboundChatCommandPacket implements Packet { + private final String command; + private final long timeStamp; + private final long salt; + private final Map signatures; + private final boolean signedPreview; + + public ServerboundChatCommandPacket(NetInput in) throws IOException { + this.command = in.readString(); + this.timeStamp = in.readLong(); + this.salt = in.readLong(); + this.signatures = new HashMap<>(); + int signatureCount = in.readVarInt(); + for (int i = 0; i < signatureCount; i++) { + String signatureId = in.readString(); + byte[] signature = in.readBytes(in.readVarInt()); + signatures.put(signatureId, signature); + } + + this.signedPreview = in.readBoolean(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeString(this.command); + out.writeLong(this.timeStamp); + out.writeLong(this.salt); + out.writeVarInt(this.signatures.size()); + for (Map.Entry signature : this.signatures.entrySet()) { + out.writeString(signature.getKey()); + out.writeVarInt(signature.getValue().length); + out.writeBytes(signature.getValue()); + } + + out.writeBoolean(this.signedPreview); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java index 63911c345..8089d153b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPacket.java @@ -15,13 +15,26 @@ @AllArgsConstructor public class ServerboundChatPacket implements Packet { private final @NonNull String message; + private final long timeStamp; + private final long salt; + private final byte[] signature; + private final boolean signedPreview; public ServerboundChatPacket(NetInput in) throws IOException { this.message = in.readString(); + this.timeStamp = in.readLong(); + this.salt = in.readLong(); + this.signature = in.readBytes(in.readVarInt()); + this.signedPreview = in.readBoolean(); } @Override public void write(NetOutput out) throws IOException { out.writeString(this.message); + out.writeLong(this.timeStamp); + out.writeLong(this.salt); + out.writeVarInt(this.signature.length); + out.writeBytes(this.signature); + out.writeBoolean(this.signedPreview); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPreviewPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPreviewPacket.java new file mode 100644 index 000000000..85c2fabc1 --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/ServerboundChatPreviewPacket.java @@ -0,0 +1,29 @@ +package com.github.steveice10.mc.protocol.packet.ingame.serverbound; + +import com.github.steveice10.packetlib.io.NetInput; +import com.github.steveice10.packetlib.io.NetOutput; +import com.github.steveice10.packetlib.packet.Packet; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.With; + +import java.io.IOException; + +@Data +@With +@AllArgsConstructor +public class ServerboundChatPreviewPacket implements Packet { + private final int queryId; + private final String query; + + public ServerboundChatPreviewPacket(NetInput in) throws IOException { + this.queryId = in.readInt(); + this.query = in.readString(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeInt(this.queryId); + out.writeString(this.query); + } +} diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java index 3d1df2541..02a7c91cf 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/inventory/ServerboundSetBeaconPacket.java @@ -8,22 +8,39 @@ import lombok.With; import java.io.IOException; +import java.util.OptionalInt; @Data @With @AllArgsConstructor public class ServerboundSetBeaconPacket implements Packet { - private final int primaryEffect; - private final int secondaryEffect; + private final OptionalInt primaryEffect; + private final OptionalInt secondaryEffect; public ServerboundSetBeaconPacket(NetInput in) throws IOException { - this.primaryEffect = in.readVarInt(); - this.secondaryEffect = in.readVarInt(); + if (in.readBoolean()) { + this.primaryEffect = OptionalInt.of(in.readVarInt()); + } else { + this.primaryEffect = OptionalInt.empty(); + } + + if (in.readBoolean()) { + this.secondaryEffect = OptionalInt.of(in.readVarInt()); + } else { + this.secondaryEffect = OptionalInt.empty(); + } } @Override public void write(NetOutput out) throws IOException { - out.writeVarInt(this.primaryEffect); - out.writeVarInt(this.secondaryEffect); + out.writeBoolean(this.primaryEffect.isPresent()); + if (this.primaryEffect.isPresent()) { + out.writeVarInt(this.primaryEffect.getAsInt()); + } + + out.writeBoolean(this.secondaryEffect.isPresent()); + if (this.secondaryEffect.isPresent()) { + out.writeVarInt(this.secondaryEffect.getAsInt()); + } } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java index ba3f06f3e..9d1ea4c7c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundPlayerActionPacket.java @@ -21,11 +21,13 @@ public class ServerboundPlayerActionPacket implements Packet { private final @NonNull PlayerAction action; private final @NonNull Position position; private final @NonNull Direction face; + private final int sequence; public ServerboundPlayerActionPacket(NetInput in) throws IOException { this.action = MagicValues.key(PlayerAction.class, in.readVarInt()); this.position = Position.read(in); this.face = Direction.VALUES[in.readUnsignedByte()]; + this.sequence = in.readVarInt(); } @Override @@ -33,5 +35,6 @@ public void write(NetOutput out) throws IOException { out.writeVarInt(MagicValues.value(Integer.class, this.action)); Position.write(out, this.position); out.writeByte(this.face.ordinal()); + out.writeVarInt(this.sequence); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java index 5bece5b6b..a33b4a06c 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemOnPacket.java @@ -25,6 +25,7 @@ public class ServerboundUseItemOnPacket implements Packet { private final float cursorY; private final float cursorZ; private final boolean insideBlock; + private final int sequence; public ServerboundUseItemOnPacket(NetInput in) throws IOException { this.hand = MagicValues.key(Hand.class, in.readVarInt()); @@ -34,6 +35,7 @@ public ServerboundUseItemOnPacket(NetInput in) throws IOException { this.cursorY = in.readFloat(); this.cursorZ = in.readFloat(); this.insideBlock = in.readBoolean(); + this.sequence = in.readVarInt(); } @Override @@ -45,5 +47,6 @@ public void write(NetOutput out) throws IOException { out.writeFloat(this.cursorY); out.writeFloat(this.cursorZ); out.writeBoolean(this.insideBlock); + out.writeVarInt(this.sequence); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java index 7215c7b33..cf58244cf 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/serverbound/player/ServerboundUseItemPacket.java @@ -17,13 +17,16 @@ @AllArgsConstructor public class ServerboundUseItemPacket implements Packet { private final @NonNull Hand hand; + private final int sequence; public ServerboundUseItemPacket(NetInput in) throws IOException { this.hand = MagicValues.key(Hand.class, in.readVarInt()); + this.sequence = in.readVarInt(); } @Override public void write(NetOutput out) throws IOException { out.writeVarInt(MagicValues.value(Integer.class, this.hand)); + out.writeVarInt(this.sequence); } } diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java index d0078d184..b6133ac6b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/clientbound/ClientboundGameProfilePacket.java @@ -10,6 +10,8 @@ import lombok.With; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; @Data @With @@ -18,13 +20,37 @@ public class ClientboundGameProfilePacket implements Packet { private final @NonNull GameProfile profile; public ClientboundGameProfilePacket(NetInput in) throws IOException { - this.profile = new GameProfile(in.readUUID(), in.readString()); + GameProfile profile = new GameProfile(in.readUUID(), in.readString()); + int properties = in.readVarInt(); + List propertyList = new ArrayList<>(); + for (int index = 0; index < properties; index++) { + String propertyName = in.readString(); + String value = in.readString(); + String signature = null; + if (in.readBoolean()) { + signature = in.readString(); + } + + propertyList.add(new GameProfile.Property(propertyName, value, signature)); + } + + profile.setProperties(propertyList); + this.profile = profile; } @Override public void write(NetOutput out) throws IOException { out.writeUUID(this.profile.getId()); out.writeString(this.profile.getName()); + out.writeVarInt(this.profile.getProperties().size()); + for (GameProfile.Property property : this.profile.getProperties()) { + out.writeString(property.getName()); + out.writeString(property.getValue()); + out.writeBoolean(property.hasSignature()); + if (property.hasSignature()) { + out.writeString(property.getSignature()); + } + } } @Override 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 a8bb9067c..6df291fcd 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 @@ -8,21 +8,53 @@ import lombok.NonNull; import lombok.With; +import javax.annotation.Nullable; import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.X509EncodedKeySpec; @Data @With @AllArgsConstructor public class ServerboundHelloPacket implements Packet { private final @NonNull String username; + private final @Nullable Long expiresAt; + private final @Nullable PublicKey publicKey; + private final @Nullable byte[] keySignature; public ServerboundHelloPacket(NetInput in) throws IOException { this.username = in.readString(); + if (in.readBoolean()) { + this.expiresAt = in.readLong(); + byte[] publicKey = in.readBytes(in.readVarInt()); + this.keySignature = in.readBytes(in.readVarInt()); + + try { + this.publicKey = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKey)); + } catch (GeneralSecurityException e) { + throw new IOException("Could not decode public key.", e); + } + } else { + this.expiresAt = null; + this.publicKey = null; + this.keySignature = null; + } } @Override public void write(NetOutput out) throws IOException { out.writeString(this.username); + out.writeBoolean(this.publicKey != null); + if (this.publicKey != null) { + out.writeLong(this.expiresAt); + byte[] encoded = this.publicKey.getEncoded(); + out.writeVarInt(encoded.length); + out.writeBytes(encoded); + out.writeVarInt(this.keySignature.length); + out.writeBytes(this.keySignature); + } } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundKeyPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundKeyPacket.java index f9146e326..e07c86c04 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundKeyPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundKeyPacket.java @@ -7,6 +7,7 @@ import lombok.NonNull; import lombok.ToString; +import javax.annotation.Nullable; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; @@ -20,11 +21,22 @@ @EqualsAndHashCode public class ServerboundKeyPacket implements Packet { private final @NonNull byte[] sharedKey; - private final @NonNull byte[] verifyToken; + private final @Nullable byte[] verifyToken; + private final @Nullable Long salt; + private final @Nullable byte[] signature; public ServerboundKeyPacket(PublicKey publicKey, SecretKey secretKey, byte[] verifyToken) { this.sharedKey = runEncryption(Cipher.ENCRYPT_MODE, publicKey, secretKey.getEncoded()); this.verifyToken = runEncryption(Cipher.ENCRYPT_MODE, publicKey, verifyToken); + this.salt = null; + this.signature = null; + } + + public ServerboundKeyPacket(PublicKey publicKey, SecretKey secretKey, long salt, byte[] signature) { + this.sharedKey = runEncryption(Cipher.ENCRYPT_MODE, publicKey, secretKey.getEncoded()); + this.salt = salt; + this.signature = signature; + this.verifyToken = null; } public SecretKey getSecretKey(PrivateKey privateKey) { @@ -37,15 +49,30 @@ public byte[] getVerifyToken(PrivateKey privateKey) { public ServerboundKeyPacket(NetInput in) throws IOException { this.sharedKey = in.readBytes(in.readVarInt()); - this.verifyToken = in.readBytes(in.readVarInt()); + if (in.readBoolean()) { + this.verifyToken = in.readBytes(in.readVarInt()); + this.salt = null; + this.signature = null; + } else { + this.salt = in.readLong(); + this.signature = in.readBytes(in.readVarInt()); + this.verifyToken = null; + } } @Override public void write(NetOutput out) throws IOException { out.writeVarInt(this.sharedKey.length); out.writeBytes(this.sharedKey); - out.writeVarInt(this.verifyToken.length); - out.writeBytes(this.verifyToken); + out.writeBoolean(this.verifyToken != null); + if (this.verifyToken != null) { + out.writeVarInt(this.verifyToken.length); + out.writeBytes(this.verifyToken); + } else { + out.writeLong(this.salt); + out.writeVarInt(this.signature.length); + out.writeBytes(this.signature); + } } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java index 95da82143..092314d79 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacket.java @@ -53,7 +53,8 @@ public ClientboundStatusResponsePacket(NetInput in) throws IOException { icon = this.stringToIcon(obj.get("favicon").getAsString()); } - this.info = new ServerStatusInfo(version, players, description, icon); + boolean previewsChat = obj.get("previewsChat").getAsBoolean(); + this.info = new ServerStatusInfo(version, players, description, icon, previewsChat); } @Override @@ -83,6 +84,7 @@ public void write(NetOutput out) throws IOException { if (this.info.getIconPng() != null) { obj.addProperty("favicon", this.iconToString(this.info.getIconPng())); } + obj.addProperty("previewsChat", this.info.isPreviewsChat()); out.writeString(obj.toString()); } From 6d09b95665c89b62aea7c0e618ab5aa1282a34b8 Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Thu, 19 May 2022 20:01:31 +0100 Subject: [PATCH 2/8] Fix building --- .../java/com/github/steveice10/mc/protocol/ClientListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f964e0619..6fd082c31 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java +++ b/src/main/java/com/github/steveice10/mc/protocol/ClientListener.java @@ -125,7 +125,7 @@ public void packetSent(Session session, Packet packet) { if (this.targetState == ProtocolState.LOGIN) { GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY); - session.send(new ServerboundHelloPacket(profile.getName())); + session.send(new ServerboundHelloPacket(profile.getName(), null, null, null)); } else { session.send(new ServerboundStatusRequestPacket()); } From 54c47dcc65aa3a273d7a5ad0a1bea9fafa01422b Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Thu, 19 May 2022 20:33:01 +0100 Subject: [PATCH 3/8] Actually fix building --- pom.xml | 2 +- .../mc/protocol/data/game/command/CommandParser.java | 1 - .../ingame/clientbound/ClientboundCommandsPacket.java | 6 ------ .../steveice10/mc/protocol/MinecraftProtocolTest.java | 5 +++-- .../github/steveice10/mc/protocol/data/MagicValuesTest.java | 2 +- .../login/serverbound/ServerboundHelloPacketTest.java | 2 +- .../clientbound/ClientboundStatusResponsePacketTest.java | 3 ++- 7 files changed, 8 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index f4df39a47..eab8d5127 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.steveice10 mcprotocollib - 1.18.2-2-SNAPSHOT + 1.19-SNAPSHOT jar MCProtocolLib diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java index 691e7adc2..2e3044a22 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/command/CommandParser.java @@ -39,7 +39,6 @@ public enum CommandParser { MOB_EFFECT, FUNCTION, ENTITY_ANCHOR, - RANGE, INT_RANGE, FLOAT_RANGE, ITEM_ENCHANTMENT, diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java index eba344384..24cc40773 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/clientbound/ClientboundCommandsPacket.java @@ -143,9 +143,6 @@ public ClientboundCommandsPacket(NetInput in) throws IOException { case SCORE_HOLDER: properties = new ScoreHolderProperties(in.readBoolean()); break; - case RANGE: - properties = new RangeProperties(in.readBoolean()); - break; case RESOURCE: case RESOURCE_OR_TAG: properties = new ResourceProperties(in.readString()); @@ -313,9 +310,6 @@ public void write(NetOutput out) throws IOException { case SCORE_HOLDER: out.writeBoolean(((ScoreHolderProperties) node.getProperties()).isAllowMultiple()); break; - case RANGE: - out.writeBoolean(((RangeProperties) node.getProperties()).isAllowDecimals()); - break; case RESOURCE: case RESOURCE_OR_TAG: out.writeString(((ResourceProperties) node.getProperties()).getRegistryKey()); 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 917323629..e28c6f58e 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -47,9 +47,10 @@ public class MinecraftProtocolTest { new VersionInfo(MinecraftCodec.CODEC.getMinecraftVersion(), MinecraftCodec.CODEC.getProtocolVersion()), new PlayerInfo(100, 0, new GameProfile[0]), Component.text("Hello world!"), - null + null, + false ); - private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), getOverworldTag(), "minecraft:world", 100, 0, 16, 16, false, false, false, false); + private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "dimension:overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false); private static Server server; diff --git a/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java b/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java index 039cbc33a..1612b6dd9 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/data/MagicValuesTest.java @@ -164,7 +164,7 @@ public void setup() { this.register(RotationOrigin.class, Integer.class); this.register(RecipeType.class, String.class); this.register(CommandType.class, Integer.class); - this.register(CommandParser.class, String.class); + this.register(CommandParser.class, Integer.class); this.register(SuggestionType.class, String.class); this.register(StringProperties.class, Integer.class); this.register(SoundCategory.class, Integer.class); diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java index 3e0b9b556..838380014 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/login/serverbound/ServerboundHelloPacketTest.java @@ -6,6 +6,6 @@ public class ServerboundHelloPacketTest extends PacketTest { @Before public void setup() { - this.setPackets(new ServerboundHelloPacket("Username")); + this.setPackets(new ServerboundHelloPacket("Username", null, null, null)); } } diff --git a/src/test/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacketTest.java b/src/test/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacketTest.java index 6d020c18d..d4a12366c 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacketTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/packet/status/clientbound/ClientboundStatusResponsePacketTest.java @@ -21,7 +21,8 @@ public void setup() { new GameProfile(UUID.randomUUID(), "Username") }), Component.text("Description"), - null + null, + false ) )); } From 5cad78b15ef3cc7767cf95eeace98077a28589ab Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Thu, 19 May 2022 21:19:24 +0100 Subject: [PATCH 4/8] Update enums --- .../mc/protocol/data/MagicValues.java | 5 + .../data/game/entity/EntityEvent.java | 3 +- .../data/game/entity/type/PaintingType.java | 6 +- .../data/game/level/sound/BuiltinSound.java | 118 ++++++++++++++++++ .../level/vibration/BlockVibrationSource.java | 25 ---- .../vibration/EntityVibrationSource.java | 24 ---- .../game/level/vibration/VibrationSource.java | 4 - 7 files changed, 130 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/BlockVibrationSource.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/EntityVibrationSource.java delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/VibrationSource.java diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java index ac4c02c35..18cfa6da3 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java @@ -248,6 +248,7 @@ public class MagicValues { register(EntityEvent.GOAT_LOWERING_HEAD, 58); register(EntityEvent.GOAT_STOP_LOWERING_HEAD, 59); register(EntityEvent.MAKE_POOF_PARTICLES, 60); + register(EntityEvent.WARDEN_RECEIVE_SIGNAL, 61); register(PositionElement.X, 0); register(PositionElement.Y, 1); @@ -289,6 +290,10 @@ public class MagicValues { register(PaintingType.BURNING_SKULL, 23); register(PaintingType.SKELETON, 24); register(PaintingType.DONKEY_KONG, 25); + register(PaintingType.EARTH, 26); + register(PaintingType.WIND, 27); + register(PaintingType.WATER, 28); + register(PaintingType.FIRE, 29); register(ScoreboardPosition.PLAYER_LIST, 0); register(ScoreboardPosition.SIDEBAR, 1); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/EntityEvent.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/EntityEvent.java index e26566869..7b5317207 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/EntityEvent.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/EntityEvent.java @@ -60,5 +60,6 @@ public enum EntityEvent { LIVING_FREEZE, GOAT_LOWERING_HEAD, GOAT_STOP_LOWERING_HEAD, - MAKE_POOF_PARTICLES + MAKE_POOF_PARTICLES, + WARDEN_RECEIVE_SIGNAL } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/PaintingType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/PaintingType.java index b0473f038..5fca0cff1 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/PaintingType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/PaintingType.java @@ -26,5 +26,9 @@ public enum PaintingType { PIG_SCENE, BURNING_SKULL, SKELETON, - DONKEY_KONG; + DONKEY_KONG, + EARTH, + WIND, + WATER, + FIRE; } diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/BuiltinSound.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/BuiltinSound.java index 6c93e54c6..22ab0406b 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/BuiltinSound.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/sound/BuiltinSound.java @@ -10,6 +10,13 @@ @Getter @AllArgsConstructor public enum BuiltinSound implements Sound { + ALLAY_AMBIENT_WITH_ITEM("entity.allay.ambient_with_item"), + ALLAY_AMBIENT_WITHOUT_ITEM("entity.allay_ambient_without_item"), + ALLAY_DEATH("entity.allay.death"), + ALLAY_HURT("entity.allay.hurt"), + ALLAY_ITEM_GIVEN("entity.allay.item_given"), + ALLAY_ITEM_TAKEN("entity.allay.item_taken"), + ALLAY_THROW("entity.allay.allay_throw"), AMBIENT_CAVE("ambient.cave"), AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"), AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"), @@ -164,11 +171,13 @@ public enum BuiltinSound implements Sound { ITEM_BUCKET_EMPTY_FISH("item.bucket.empty_fish"), ITEM_BUCKET_EMPTY_LAVA("item.bucket.empty_lava"), ITEM_BUCKET_EMPTY_POWDER_SNOW("item.bucket.empty_powder_snow"), + ITEM_BUCKET_EMPTY_TADPOLE("item.bucket.empty_tadpole"), ITEM_BUCKET_FILL("item.bucket.fill"), ITEM_BUCKET_FILL_AXOLOTL("item.bucket.fill_axolotl"), ITEM_BUCKET_FILL_FISH("item.bucket.fill_fish"), ITEM_BUCKET_FILL_LAVA("item.bucket.fill_lava"), ITEM_BUCKET_FILL_POWDER_SNOW("item.bucket.fill_powder_snow"), + ITEM_BUCKET_FILL_TADPOLE("item.bucket.fill_tadpole"), ITEM_BUNDLE_DROP_CONTENTS("item.bundle.drop_contents"), ITEM_BUNDLE_INSERT("item.bundle.insert"), ITEM_BUNDLE_REMOVE_ONE("item.bundle.remove_one"), @@ -401,6 +410,25 @@ public enum BuiltinSound implements Sound { ENTITY_FOX_SNIFF("entity.fox.sniff"), ENTITY_FOX_SPIT("entity.fox.spit"), ENTITY_FOX_TELEPORT("entity.fox.teleport"), + BLOCK_FROGLIGHT_BREAK("block.froglight.break"), + BLOCK_FROGLIGHT_FALL("block.froglight.fall"), + BLOCK_FROGLIGHT_HIT("block.froglight.hit"), + BLOCK_FROGLIGHT_PLACE("block.froglight.place"), + BLOCK_FROGLIGHT_STEP("block.froglight.step"), + BLOCK_FROGSPAWN_STEP("block.frogspawn.step"), + BLOCK_FROGSPAWN_BREAK("block.frogspawn.break"), + BLOCK_FROGSPAWN_FALL("block.frogspawn.fall"), + BLOCK_FROGSPAWN_HATCH("block.frogspawn.hatch"), + BLOCK_FROGSPAWN_HIT("block.frogspawn.hit"), + BLOCK_FROGSPAWN_PLACE("block.frogspawn.place"), + ENTITY_FROG_AMBIENT("entity.frog.ambient"), + ENTITY_FROG_DEATH("entity.frog.death"), + ENTITY_FROG_EAT("entity.frog.eat"), + ENTITY_FROG_HURT("entity.frog.hurt"), + ENTITY_FROG_LAY_SPAWN("entity.frog.lay_spawn"), + ENTITY_FROG_LONG_JUMP("entity.frog.long_jump"), + ENTITY_FROG_STEP("entity.frog.step"), + ENTITY_FROG_TONGUE("entity.frog.tongue"), BLOCK_ROOTS_BREAK("block.roots.break"), BLOCK_ROOTS_STEP("block.roots.step"), BLOCK_ROOTS_PLACE("block.roots.place"), @@ -452,6 +480,8 @@ public enum BuiltinSound implements Sound { ENTITY_GOAT_MILK("entity.goat.milk"), ENTITY_GOAT_PREPARE_RAM("entity.goat.prepare_ram"), ENTITY_GOAT_RAM_IMPACT("entity.goat.ram_impact"), + ENTITY_GOAT_HORN_BREAK("entity.goat.horn_break"), + ENTITY_GOAT_HORN_PLAY("item.goat_horn.play"), ENTITY_GOAT_SCREAMING_AMBIENT("entity.goat.screaming.ambient"), ENTITY_GOAT_SCREAMING_DEATH("entity.goat.screaming.death"), ENTITY_GOAT_SCREAMING_EAT("entity.goat.screaming.eat"), @@ -460,6 +490,7 @@ public enum BuiltinSound implements Sound { ENTITY_GOAT_SCREAMING_MILK("entity.goat.screaming.milk"), ENTITY_GOAT_SCREAMING_PREPARE_RAM("entity.goat.screaming.prepare_ram"), ENTITY_GOAT_SCREAMING_RAM_IMPACT("entity.goat.screaming.ram_impact"), + ENTITY_GOAT_SCREAMING_HORN_BREAK("entity.goat.screaming.horn_break"), ENTITY_GOAT_STEP("entity.goat.step"), BLOCK_GRASS_BREAK("block.grass.break"), BLOCK_GRASS_FALL("block.grass.fall"), @@ -503,6 +534,14 @@ public enum BuiltinSound implements Sound { BLOCK_HONEY_BLOCK_STEP("block.honey_block.step"), ITEM_HONEYCOMB_WAX_ON("item.honeycomb.wax_on"), ITEM_HONEY_BOTTLE_DRINK("item.honey_bottle.drink"), + ITEM_GOAT_HORN_SOUND_0("item.goat_horn.sound.0"), + ITEM_GOAT_HORN_SOUND_1("item.goat_horn.sound.1"), + ITEM_GOAT_HORN_SOUND_2("item.goat_horn.sound.2"), + ITEM_GOAT_HORN_SOUND_3("item.goat_horn.sound.3"), + ITEM_GOAT_HORN_SOUND_4("item.goat_horn.sound.4"), + ITEM_GOAT_HORN_SOUND_5("item.goat_horn.sound.5"), + ITEM_GOAT_HORN_SOUND_6("item.goat_horn.sound.6"), + ITEM_GOAT_HORN_SOUND_7("item.goat_horn.sound.7"), ENTITY_HORSE_AMBIENT("entity.horse.ambient"), ENTITY_HORSE_ANGRY("entity.horse.angry"), ENTITY_HORSE_ARMOR("entity.horse.armor"), @@ -595,6 +634,11 @@ public enum BuiltinSound implements Sound { ENTITY_MAGMA_CUBE_JUMP("entity.magma_cube.jump"), ENTITY_MAGMA_CUBE_SQUISH("entity.magma_cube.squish"), ENTITY_MAGMA_CUBE_SQUISH_SMALL("entity.magma_cube.squish_small"), + BLOCK_MANGROVE_ROOTS_BREAK("block.mangrove_roots.break"), + BLOCK_MANGROVE_ROOTS_FALL("block.mangrove_roots.fall"), + BLOCK_MANGROVE_ROOTS_HIT("block.mangrove_roots.hit"), + BLOCK_MANGROVE_ROOTS_PLACE("block.mangrove_roots.place"), + BLOCK_MANGROVE_ROOTS_STEP("block.mangrove_roots.step"), BLOCK_MEDIUM_AMETHYST_BUD_BREAK("block.medium_amethyst_bud.break"), BLOCK_MEDIUM_AMETHYST_BUD_PLACE("block.medium_amethyst_bud.place"), BLOCK_METAL_BREAK("block.metal.break"), @@ -622,6 +666,21 @@ public enum BuiltinSound implements Sound { BLOCK_MOSS_HIT("block.moss.hit"), BLOCK_MOSS_PLACE("block.moss.place"), BLOCK_MOSS_STEP("block.moss.step"), + BLOCK_MUD_BREAK("block.mud.break"), + BLOCK_MUD_FALL("block.mud.fall"), + BLOCK_MUD_HIT("block.mud.hit"), + BLOCK_MUD_PLACE("block.mud.place"), + BLOCK_MUD_STEP("block.mud.step"), + BLOCK_MUD_BRICKS_BREAK("block.mud_bricks.break"), + BLOCK_MUD_BRICKS_FALL("block.mud_bricks.fall"), + BLOCK_MUD_BRICKS_HIT("block.mud_bricks.hit"), + BLOCK_MUD_BRICKS_PLACE("block.mud_bricks.place"), + BLOCK_MUD_BRICKS_STEP("block.mud_bricks.step"), + BLOCK_MUDDY_MANGROVE_ROOTS_BREAK("block.muddy_mangrove_roots.break"), + BLOCK_MUDDY_MANGROVE_ROOTS_FALL("block.muddy_mangrove_roots.fall"), + BLOCK_MUDDY_MANGROVE_ROOTS_HIT("block.muddy_mangrove_roots.hit"), + BLOCK_MUDDY_MANGROVE_ROOTS_PLACE("block.muddy_mangrove_roots.place"), + BLOCK_MUDDY_MANGROVE_ROOTS_STEP("block.muddy_mangrove_roots.step"), ENTITY_MULE_AMBIENT("entity.mule.ambient"), ENTITY_MULE_ANGRY("entity.mule.angry"), ENTITY_MULE_CHEST("entity.mule.chest"), @@ -630,6 +689,7 @@ public enum BuiltinSound implements Sound { ENTITY_MULE_HURT("entity.mule.hurt"), MUSIC_CREATIVE("music.creative"), MUSIC_CREDITS("music.credits"), + MUSIC_DISC_5("music_disc.5"), MUSIC_DISC_11("music_disc.11"), MUSIC_DISC_13("music_disc.13"), MUSIC_DISC_BLOCKS("music_disc.blocks"), @@ -650,10 +710,14 @@ public enum BuiltinSound implements Sound { MUSIC_MENU("music.menu"), MUSIC_NETHER_BASALT_DELTAS("music.nether.basalt_deltas"), MUSIC_NETHER_CRIMSON_FOREST("music.nether.crimson_forest"), + MUSIC_OVERWORLD_DEEP_DARK("music.overworld.deep_dark"), MUSIC_OVERWORLD_DRIPSTONE_CAVES("music.overworld.dripstone_caves"), MUSIC_OVERWORLD_GROVE("music.overworld.grove"), MUSIC_OVERWORLD_JAGGED_PEAKS("music.overworld.jagged_peaks"), MUSIC_OVERWORLD_LUSH_CAVES("music.overworld.lush_caves"), + MUSIC_OVERWORLD_SWAMP("music.overworld.swamp"), + MUSIC_OVERWORLD_JUNGLE_AND_FOREST("music.overworld.jungle_and_forest"), + MUSIC_OVERWORLD_OLD_GROWTH_TAIGA("music.overworld.old_growth_taiga"), MUSIC_OVERWORLD_MEADOW("music.overworld.meadow"), MUSIC_NETHER_NETHER_WASTES("music.nether.nether_wastes"), MUSIC_OVERWORLD_FROZEN_PEAKS("music.overworld.frozen_peaks"), @@ -669,6 +733,11 @@ public enum BuiltinSound implements Sound { BLOCK_NETHER_BRICKS_FALL("block.nether_bricks.fall"), BLOCK_NETHER_WART_BREAK("block.nether_wart.break"), ITEM_NETHER_WART_PLANT("item.nether_wart.plant"), + BLOCK_PACKED_MUD_BREAK("block.packed_mud.break"), + BLOCK_PACKED_MUD_FALL("block.packed_mud.fall"), + BLOCK_PACKED_MUD_HIT("block.packed_mud.hit"), + BLOCK_PACKED_MUD_PLACE("block.packed_mud.place"), + BLOCK_PACKED_MUD_STEP("block.packed_mud.step"), BLOCK_STEM_BREAK("block.stem.break"), BLOCK_STEM_STEP("block.stem.step"), BLOCK_STEM_PLACE("block.stem.place"), @@ -772,6 +841,7 @@ public enum BuiltinSound implements Sound { ENTITY_PARROT_IMITATE_STRAY("entity.parrot.imitate.stray"), ENTITY_PARROT_IMITATE_VEX("entity.parrot.imitate.vex"), ENTITY_PARROT_IMITATE_VINDICATOR("entity.parrot.imitate.vindicator"), + ENTITY_PARROT_IMITATE_WARDEN("entity.parrot.imitate.warden"), ENTITY_PARROT_IMITATE_WITCH("entity.parrot.imitate.witch"), ENTITY_PARROT_IMITATE_WITHER("entity.parrot.imitate.wither"), ENTITY_PARROT_IMITATE_WITHER_SKELETON("entity.parrot.imitate.wither_skeleton"), @@ -907,6 +977,19 @@ public enum BuiltinSound implements Sound { BLOCK_SCAFFOLDING_HIT("block.scaffolding.hit"), BLOCK_SCAFFOLDING_PLACE("block.scaffolding.place"), BLOCK_SCAFFOLDING_STEP("block.scaffolding.step"), + BLOCK_SCULK_SPREAD("block.sculk.spread"), + BLOCK_SCULK_CHARGE("block.sculk.charge"), + BLOCK_SCULK_BREAK("block.sculk.break"), + BLOCK_SCULK_FALL("block.sculk.fall"), + BLOCK_SCULK_HIT("block.sculk.hit"), + BLOCK_SCULK_PLACE("block.sculk.place"), + BLOCK_SCULK_STEP("block.sculk.step"), + BLOCK_SCULK_CATALYST_BLOOM("block.sculk_catalyst.bloom"), + BLOCK_SCULK_CATALYST_BREAK("block.sculk_catalyst.break"), + BLOCK_SCULK_CATALYST_FALL("block.sculk_catalyst.fall"), + BLOCK_SCULK_CATALYST_HIT("block.sculk_catalyst.hit"), + BLOCK_SCULK_CATALYST_PLACE("block.sculk_catalyst.place"), + BLOCK_SCULK_CATALYST_STEP("block.sculk_catalyst.step"), BLOCK_SCULK_SENSOR_CLICKING("block.sculk_sensor.clicking"), BLOCK_SCULK_SENSOR_CLICKING_STOP("block.sculk_sensor.clicking_stop"), BLOCK_SCULK_SENSOR_BREAK("block.sculk_sensor.break"), @@ -914,6 +997,17 @@ public enum BuiltinSound implements Sound { BLOCK_SCULK_SENSOR_HIT("block.sculk_sensor.hit"), BLOCK_SCULK_SENSOR_PLACE("block.sculk_sensor.place"), BLOCK_SCULK_SENSOR_STEP("block.sculk_sensor.step"), + BLOCK_SCULK_SHRIEKER_BREAK("block.sculk_shrieker.break"), + BLOCK_SCULK_SHRIEKER_FALL("block.sculk_shrieker.fall"), + BLOCK_SCULK_SHRIEKER_HIT("block.sculk_shrieker.hit"), + BLOCK_SCULK_SHRIEKER_PLACE("block.sculk_shrieker.place"), + BLOCK_SCULK_SHRIEKER_SHRIEK("block.sculk_shrieker.shriek"), + BLOCK_SCULK_SHRIEKER_STEP("block.sculk_shrieker.step"), + BLOCK_SCULK_VEIN_BREAK("block.sculk_vein.break"), + BLOCK_SCULK_VEIN_FALL("block.sculk_vein.fall"), + BLOCK_SCULK_VEIN_HIT("block.sculk_vein.hit"), + BLOCK_SCULK_VEIN_PLACE("block.sculk_vein.place"), + BLOCK_SCULK_VEIN_STEP("block.sculk_vein.step"), ENTITY_SHEEP_AMBIENT("entity.sheep.ambient"), ENTITY_SHEEP_DEATH("entity.sheep.death"), ENTITY_SHEEP_HURT("entity.sheep.hurt"), @@ -1044,6 +1138,10 @@ public enum BuiltinSound implements Sound { BLOCK_SWEET_BERRY_BUSH_BREAK("block.sweet_berry_bush.break"), BLOCK_SWEET_BERRY_BUSH_PLACE("block.sweet_berry_bush.place"), BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES("block.sweet_berry_bush.pick_berries"), + ENTITY_TADPOLE_DEATH("entity.tadpole.death"), + ENTITY_TADPOLE_FLOP("entity.tadpole.flop"), + ENTITY_TADPOLE_GROW_UP("entity.tadpole.grow_up"), + ENTITY_TADPOLE_HURT("entity.tadpole.hurt"), ENCHANT_THORNS_HIT("enchant.thorns.hit"), ENTITY_TNT_PRIMED("entity.tnt.primed"), ITEM_TOTEM_USE("item.totem.use"), @@ -1133,6 +1231,26 @@ public enum BuiltinSound implements Sound { ENTITY_WANDERING_TRADER_REAPPEARED("entity.wandering_trader.reappeared"), ENTITY_WANDERING_TRADER_TRADE("entity.wandering_trader.trade"), ENTITY_WANDERING_TRADER_YES("entity.wandering_trader.yes"), + ENTITY_WARDEN_AGITATED("entity.warden.agitated"), + ENTITY_WARDEN_AMBIENT("entity.warden.ambient"), + ENTITY_WARDEN_ANGRY("entity.warden.angry"), + ENTITY_WARDEN_ATTACK_IMPACT("entity.warden.attack_impact"), + ENTITY_WARDEN_DEATH("entity.warden.death"), + ENTITY_WARDEN_DIG("entity.warden.dig"), + ENTITY_WARDEN_EMERGE("entity.warden.emerge"), + ENTITY_WARDEN_HEARTBEAT("entity.warden.heartbeat"), + ENTITY_WARDEN_HURT("entity.warden.hurt"), + ENTITY_WARDEN_LISTENING("entity.warden.listening"), + ENTITY_WARDEN_LISTENING_ANGRY("entity.warden.listening_angry"), + ENTITY_WARDEN_NEARBY_CLOSE("entity.warden.nearby_close"), + ENTITY_WARDEN_NEARBY_CLOSER("entity.warden.nearby_closer"), + ENTITY_WARDEN_NEARBY_CLOSEST("entity.warden.nearby_closest"), + ENTITY_WARDEN_ROAR("entity.warden.roar"), + ENTITY_WARDEN_SNIFF("entity.warden.sniff"), + ENTITY_WARDEN_SONIC_BOOM("entity.warden.sonic_boom"), + ENTITY_WARDEN_SONIC_CHARGE("entity.warden.sonic_charge"), + ENTITY_WARDEN_STEP("entity.warden.step"), + ENTITY_WARDEN_TENDRIL_CLICKS("entity.warden.tendril_clicks"), BLOCK_WATER_AMBIENT("block.water.ambient"), WEATHER_RAIN("weather.rain"), WEATHER_RAIN_ABOVE("weather.rain.above"), diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/BlockVibrationSource.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/BlockVibrationSource.java deleted file mode 100644 index 4c51d13d5..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/BlockVibrationSource.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.github.steveice10.mc.protocol.data.game.level.vibration; - -import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.ToString; - -import java.io.IOException; - -@AllArgsConstructor -@Getter -@ToString -public class BlockVibrationSource implements VibrationSource { - private final Position destinationPos; - - public static BlockVibrationSource read(NetInput in) throws IOException { - return new BlockVibrationSource(Position.read(in)); - } - - public static void write(NetOutput out, BlockVibrationSource vibration) throws IOException { - Position.write(out, vibration.getDestinationPos()); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/EntityVibrationSource.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/EntityVibrationSource.java deleted file mode 100644 index e82e7a71d..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/EntityVibrationSource.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.github.steveice10.mc.protocol.data.game.level.vibration; - -import com.github.steveice10.packetlib.io.NetInput; -import com.github.steveice10.packetlib.io.NetOutput; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.ToString; - -import java.io.IOException; - -@AllArgsConstructor -@Getter -@ToString -public class EntityVibrationSource implements VibrationSource { - private final int destinationEntityId; - - public static EntityVibrationSource read(NetInput in) throws IOException { - return new EntityVibrationSource(in.readVarInt()); - } - - public static void write(NetOutput out, EntityVibrationSource vibration) throws IOException { - out.writeVarInt(vibration.getDestinationEntityId()); - } -} diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/VibrationSource.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/VibrationSource.java deleted file mode 100644 index ba43c3516..000000000 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/level/vibration/VibrationSource.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.github.steveice10.mc.protocol.data.game.level.vibration; - -public interface VibrationSource { -} From 54073a6cf949108aa83cc3cd5a9e1d4b2a8c74ca Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Fri, 20 May 2022 13:26:02 +0100 Subject: [PATCH 5/8] Missed some --- .../steveice10/mc/protocol/data/game/entity/Effect.java | 3 ++- .../mc/protocol/data/game/entity/type/EntityType.java | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/Effect.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/Effect.java index 8ea33bde6..3f474f462 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/Effect.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/Effect.java @@ -32,7 +32,8 @@ public enum Effect { CONDUIT_POWER, DOLPHINS_GRACE, BAD_OMEN, - HERO_OF_THE_VILLAGE; + HERO_OF_THE_VILLAGE, + DARKNESS; public static final Effect[] VALUES = values(); diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java index a7090a325..b3d514397 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java +++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/type/EntityType.java @@ -5,6 +5,7 @@ import java.io.IOException; public enum EntityType { + ALLAY, AREA_EFFECT_CLOUD, ARMOR_STAND, ARROW, @@ -13,6 +14,7 @@ public enum EntityType { BEE, BLAZE, BOAT, + CHEST_BOAT, CAT, CAVE_SPIDER, CHICKEN, @@ -35,6 +37,7 @@ public enum EntityType { FALLING_BLOCK, FIREWORK_ROCKET, FOX, + FROG, GHAST, GIANT, GLOW_ITEM_FRAME, @@ -94,6 +97,7 @@ public enum EntityType { SQUID, STRAY, STRIDER, + TADPOLE, EGG, ENDER_PEARL, EXPERIENCE_BOTTLE, @@ -106,6 +110,7 @@ public enum EntityType { VILLAGER, VINDICATOR, WANDERING_TRADER, + WARDEN, WITCH, WITHER, WITHER_SKELETON, From d4fa7b4458a6f0bfa75aad57389a948f15a3c5ef Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Mon, 23 May 2022 18:08:06 +0100 Subject: [PATCH 6/8] 1.19-pre2 --- .../mc/protocol/codec/MinecraftCodec.java | 4 ++-- .../clientbound/ClientboundLoginPacket.java | 16 ++++++++++++++++ .../clientbound/ClientboundRespawnPacket.java | 16 ++++++++++++++++ .../mc/protocol/MinecraftProtocolTest.java | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) 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 d9a42065b..7389c6dd9 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 @@ -172,8 +172,8 @@ public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion((1 << 30) | 85) - .minecraftVersion("1.19-pre1") + .protocolVersion((1 << 30) | 86) + .minecraftVersion("1.19-pre2") .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) ) 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 27b4a3657..76eccf907 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 @@ -2,6 +2,7 @@ import com.github.steveice10.mc.protocol.data.MagicValues; import com.github.steveice10.mc.protocol.data.game.NBT; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.packetlib.io.NetInput; @@ -12,6 +13,7 @@ import lombok.NonNull; import lombok.With; +import javax.annotation.Nullable; import java.io.IOException; @Data @@ -37,6 +39,8 @@ public class ClientboundLoginPacket implements Packet { private final boolean enableRespawnScreen; private final boolean debug; private final boolean flat; + private final @Nullable String lastDeathDimension; + private final @Nullable Position lastDeathPos; public ClientboundLoginPacket(NetInput in) throws IOException { this.entityId = in.readInt(); @@ -61,6 +65,13 @@ public ClientboundLoginPacket(NetInput in) throws IOException { this.enableRespawnScreen = in.readBoolean(); this.debug = in.readBoolean(); this.flat = in.readBoolean(); + if (in.readBoolean()) { + this.lastDeathDimension = in.readString(); + this.lastDeathPos = Position.read(in); + } else { + this.lastDeathDimension = null; + this.lastDeathPos = null; + } } @Override @@ -87,5 +98,10 @@ public void write(NetOutput out) throws IOException { out.writeBoolean(this.enableRespawnScreen); out.writeBoolean(this.debug); out.writeBoolean(this.flat); + out.writeBoolean(this.lastDeathPos != null); + if (this.lastDeathPos != null) { + out.writeString(this.lastDeathDimension); + Position.write(out, this.lastDeathPos); + } } } 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 583434a05..59e63c3d3 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 @@ -2,6 +2,7 @@ import com.github.steveice10.mc.protocol.data.MagicValues; import com.github.steveice10.mc.protocol.data.game.NBT; +import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.packetlib.io.NetInput; @@ -12,6 +13,7 @@ import lombok.NonNull; import lombok.With; +import javax.annotation.Nullable; import java.io.IOException; @Data @@ -26,6 +28,8 @@ public class ClientboundRespawnPacket implements Packet { private final boolean debug; private final boolean flat; private final boolean copyMetadata; + private final @Nullable String lastDeathDimension; + private final @Nullable Position lastDeathPos; public ClientboundRespawnPacket(NetInput in) throws IOException { this.dimension = in.readString(); @@ -36,6 +40,13 @@ public ClientboundRespawnPacket(NetInput in) throws IOException { this.debug = in.readBoolean(); this.flat = in.readBoolean(); this.copyMetadata = in.readBoolean(); + if (in.readBoolean()) { + this.lastDeathDimension = in.readString(); + this.lastDeathPos = Position.read(in); + } else { + this.lastDeathDimension = null; + this.lastDeathPos = null; + } } @Override @@ -48,5 +59,10 @@ public void write(NetOutput out) throws IOException { out.writeBoolean(this.debug); out.writeBoolean(this.flat); out.writeBoolean(this.copyMetadata); + out.writeBoolean(this.lastDeathPos != null); + if (this.lastDeathPos != null) { + out.writeString(this.lastDeathDimension); + Position.write(out, this.lastDeathPos); + } } } 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 e28c6f58e..5b2ff3fc6 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -50,7 +50,7 @@ public class MinecraftProtocolTest { null, false ); - private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "dimension:overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false); + private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "dimension:overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false, null, null); private static Server server; From d0e98a0516d55fbf58a1842cbb70536773295fff Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Wed, 25 May 2022 17:45:51 +0100 Subject: [PATCH 7/8] 1.19-pre3 --- .../github/steveice10/mc/protocol/codec/MinecraftCodec.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 7389c6dd9..56571d8f8 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 @@ -172,8 +172,8 @@ public class MinecraftCodec { public static final PacketCodec CODEC = PacketCodec.builder() - .protocolVersion((1 << 30) | 86) - .minecraftVersion("1.19-pre2") + .protocolVersion((1 << 30) | 87) + .minecraftVersion("1.19-pre3") .state(ProtocolState.HANDSHAKE, PacketStateCodec.builder() .registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new) ) From 62ba5aa8a290b4f792f277bdc57b9523ff84b19d Mon Sep 17 00:00:00 2001 From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com> Date: Wed, 25 May 2022 21:20:25 +0100 Subject: [PATCH 8/8] Fix tests a bit --- .../mc/protocol/MinecraftProtocolTest.java | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) 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 5b2ff3fc6..00402c2fa 100644 --- a/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java +++ b/src/test/java/com/github/steveice10/mc/protocol/MinecraftProtocolTest.java @@ -11,6 +11,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket; import com.github.steveice10.opennbt.tag.builtin.ByteTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.DoubleTag; import com.github.steveice10.opennbt.tag.builtin.FloatTag; import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.ListTag; @@ -41,7 +42,7 @@ public class MinecraftProtocolTest { private static final String HOST = "localhost"; - private static final int PORT = 25560; + private static final int PORT = 25562; private static final ServerStatusInfo SERVER_INFO = new ServerStatusInfo( new VersionInfo(MinecraftCodec.CODEC.getMinecraftVersion(), MinecraftCodec.CODEC.getProtocolVersion()), @@ -50,7 +51,7 @@ public class MinecraftProtocolTest { null, false ); - private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "dimension:overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false, null, null); + private static final ClientboundLoginPacket JOIN_GAME_PACKET = new ClientboundLoginPacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "overworld", "minecraft:world", 100, 0, 16, 16, false, false, false, false, null, null); private static Server server; @@ -142,30 +143,44 @@ public void disconnected(DisconnectedEvent event) { } private static CompoundTag getDimensionTag() { - CompoundTag tag = new CompoundTag(""); - ListTag dimensionTag = new ListTag("dimension"); CompoundTag overworldTag = getOverworldTag(); - dimensionTag.add(overworldTag); - overworldTag.put(tag); + CompoundTag tag = new CompoundTag("minecraft:dimension_type"); + tag.put(new StringTag("type", "minecraft:dimension_type")); + ListTag list = new ListTag("value"); + list.add(overworldTag); + tag.put(list); return tag; } private static CompoundTag getOverworldTag() { CompoundTag overworldTag = new CompoundTag(""); + CompoundTag element = new CompoundTag("element"); + element.put(new FloatTag("ambient_light", 0f)); + element.put(new ByteTag("bed_works", (byte) 1)); + element.put(new DoubleTag("coordinate_scale", 1d)); + element.put(new StringTag("effects", "minecraft:overworld")); + element.put(new ByteTag("has_ceiling", (byte) 0)); + element.put(new ByteTag("has_raids", (byte) 1)); + element.put(new ByteTag("has_skylight", (byte) 1)); + element.put(new IntTag("height", 384)); + element.put(new StringTag("infiniburn", "#minecraft:infiniburn_overworld")); + element.put(new IntTag("logical_height", 384)); + element.put(new IntTag("min_y", -64)); + element.put(new IntTag("monster_spawner_block_light_limit", 0)); + CompoundTag spawnLightLevel = new CompoundTag("monster_spawn_light_level"); + spawnLightLevel.put(new StringTag("type", "minecraft:uniform")); + CompoundTag value = new CompoundTag("value"); + value.put(new IntTag("max_inclusive", 7)); + value.put(new IntTag("min_inclusive", 0)); + spawnLightLevel.put(value); + element.put(spawnLightLevel); + element.put(new ByteTag("natural", (byte) 1)); + element.put(new ByteTag("piglin_safe", (byte) 0)); + element.put(new ByteTag("respawn_anchor_works", (byte) 0)); + element.put(new ByteTag("ultrawarm", (byte) 0)); + overworldTag.put(element); + overworldTag.put(new IntTag("id", 0)); overworldTag.put(new StringTag("name", "minecraft:overworld")); - overworldTag.put(new ByteTag("piglin_safe", (byte) 0)); - overworldTag.put(new ByteTag("natural", (byte) 1)); - overworldTag.put(new FloatTag("ambient_light", 0f)); - overworldTag.put(new StringTag("infiniburn", "minecraft:infiniburn_overworld")); - overworldTag.put(new ByteTag("respawn_anchor_works", (byte) 0)); - overworldTag.put(new ByteTag("has_skylight", (byte) 1)); - overworldTag.put(new ByteTag("bed_works", (byte) 1)); - overworldTag.put(new StringTag("effects", "minecraft:overworld")); - overworldTag.put(new ByteTag("has_raids", (byte) 1)); - overworldTag.put(new IntTag("logical_height", 256)); - overworldTag.put(new FloatTag("coordinate_scale", 1f)); - overworldTag.put(new ByteTag("ultrawarm", (byte) 0)); - overworldTag.put(new ByteTag("has_ceiling", (byte) 0)); return overworldTag; } }