Update to 1.19.4-pre1. The new netty pipeline is still to be implemented.

This commit is contained in:
D3ATHBRINGER13 2023-02-25 16:07:16 +00:00
parent 9d15762233
commit d52d258bec
24 changed files with 465 additions and 199 deletions

View file

@ -5,7 +5,7 @@
<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.19.3-SNAPSHOT</version>
<version>1.19.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MCProtocolLib</name>

View file

@ -30,7 +30,11 @@ import com.github.steveice10.packetlib.packet.Packet;
import net.kyori.adventure.text.Component;
import javax.crypto.SecretKey;
import java.security.*;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.UUID;
@ -125,7 +129,7 @@ public class ServerListener extends SessionAdapter {
if (builder == null) {
builder = $ -> new ServerStatusInfo(
new VersionInfo(protocol.getCodec().getMinecraftVersion(), protocol.getCodec().getProtocolVersion()),
new PlayerInfo(0, 20, new GameProfile[0]),
new PlayerInfo(0, 20, new ArrayList<>()),
Component.text("A Minecraft Server"),
null,
false

View file

@ -13,6 +13,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCo
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomChatCompletionsPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDeleteChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDelimiterPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisconnectPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
@ -36,7 +37,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUp
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateTagsPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundDamageEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundHurtAnimationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosRotPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityRotPacket;
@ -79,6 +82,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.Clientb
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEntityDataPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundChunksBiomesPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundExplodePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundForgetLevelChunkPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
@ -195,9 +199,9 @@ public class MinecraftCodec {
}
public static final PacketCodec CODEC = PacketCodec.builder()
.protocolVersion(761)
.protocolVersion((1 << 30) | 120)
.helper(() -> new MinecraftCodecHelper(LEVEL_EVENTS, SOUND_NAMES))
.minecraftVersion("1.19.3")
.minecraftVersion("1.19.4 Pre-release 1")
.state(ProtocolState.HANDSHAKE, PacketStateCodec.builder()
.registerServerboundPacket(0x00, ClientIntentionPacket.class, ClientIntentionPacket::new)
)
@ -216,146 +220,150 @@ public class MinecraftCodec {
.registerServerboundPacket(0x00, ServerboundStatusRequestPacket.class, ServerboundStatusRequestPacket::new)
.registerServerboundPacket(0x01, ServerboundPingRequestPacket.class, ServerboundPingRequestPacket::new)
).state(ProtocolState.GAME, PacketStateCodec.builder()
.registerClientboundPacket(0x00, ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new)
.registerClientboundPacket(0x01, ClientboundAddExperienceOrbPacket.class, ClientboundAddExperienceOrbPacket::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, ClientboundClearTitlesPacket.class, ClientboundClearTitlesPacket::new)
.registerClientboundPacket(0x0D, ClientboundCommandSuggestionsPacket.class, ClientboundCommandSuggestionsPacket::new)
.registerClientboundPacket(0x0E, ClientboundCommandsPacket.class, ClientboundCommandsPacket::new)
.registerClientboundPacket(0x0F, ClientboundContainerClosePacket.class, ClientboundContainerClosePacket::new)
.registerClientboundPacket(0x10, ClientboundContainerSetContentPacket.class, ClientboundContainerSetContentPacket::new)
.registerClientboundPacket(0x11, ClientboundContainerSetDataPacket.class, ClientboundContainerSetDataPacket::new)
.registerClientboundPacket(0x12, ClientboundContainerSetSlotPacket.class, ClientboundContainerSetSlotPacket::new)
.registerClientboundPacket(0x13, ClientboundCooldownPacket.class, ClientboundCooldownPacket::new)
.registerClientboundPacket(0x14, ClientboundCustomChatCompletionsPacket.class, ClientboundCustomChatCompletionsPacket::new)
.registerClientboundPacket(0x15, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new)
.registerClientboundPacket(0x16, ClientboundDeleteChatPacket.class, ClientboundDeleteChatPacket::new)
.registerClientboundPacket(0x17, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new)
.registerClientboundPacket(0x18, ClientboundDisguisedChatPacket.class, ClientboundDisguisedChatPacket::new)
.registerClientboundPacket(0x19, ClientboundEntityEventPacket.class, ClientboundEntityEventPacket::new)
.registerClientboundPacket(0x1A, ClientboundExplodePacket.class, ClientboundExplodePacket::new)
.registerClientboundPacket(0x1B, ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new)
.registerClientboundPacket(0x1C, ClientboundGameEventPacket.class, ClientboundGameEventPacket::new)
.registerClientboundPacket(0x1D, ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new)
.registerClientboundPacket(0x1E, ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new)
.registerClientboundPacket(0x1F, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new)
.registerClientboundPacket(0x20, ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkWithLightPacket::new)
.registerClientboundPacket(0x21, ClientboundLevelEventPacket.class, ClientboundLevelEventPacket::new)
.registerClientboundPacket(0x22, ClientboundLevelParticlesPacket.class, ClientboundLevelParticlesPacket::new)
.registerClientboundPacket(0x23, ClientboundLightUpdatePacket.class, ClientboundLightUpdatePacket::new)
.registerClientboundPacket(0x24, ClientboundLoginPacket.class, ClientboundLoginPacket::new)
.registerClientboundPacket(0x25, ClientboundMapItemDataPacket.class, ClientboundMapItemDataPacket::new)
.registerClientboundPacket(0x26, ClientboundMerchantOffersPacket.class, ClientboundMerchantOffersPacket::new)
.registerClientboundPacket(0x27, ClientboundMoveEntityPosPacket.class, ClientboundMoveEntityPosPacket::new)
.registerClientboundPacket(0x28, ClientboundMoveEntityPosRotPacket.class, ClientboundMoveEntityPosRotPacket::new)
.registerClientboundPacket(0x29, ClientboundMoveEntityRotPacket.class, ClientboundMoveEntityRotPacket::new)
.registerClientboundPacket(0x2A, ClientboundMoveVehiclePacket.class, ClientboundMoveVehiclePacket::new)
.registerClientboundPacket(0x2B, ClientboundOpenBookPacket.class, ClientboundOpenBookPacket::new)
.registerClientboundPacket(0x2C, ClientboundOpenScreenPacket.class, ClientboundOpenScreenPacket::new)
.registerClientboundPacket(0x2D, ClientboundOpenSignEditorPacket.class, ClientboundOpenSignEditorPacket::new)
.registerClientboundPacket(0x2E, ClientboundPingPacket.class, ClientboundPingPacket::new)
.registerClientboundPacket(0x2F, ClientboundPlaceGhostRecipePacket.class, ClientboundPlaceGhostRecipePacket::new)
.registerClientboundPacket(0x30, ClientboundPlayerAbilitiesPacket.class, ClientboundPlayerAbilitiesPacket::new)
.registerClientboundPacket(0x31, ClientboundPlayerChatPacket.class, ClientboundPlayerChatPacket::new)
.registerClientboundPacket(0x32, ClientboundPlayerCombatEndPacket.class, ClientboundPlayerCombatEndPacket::new)
.registerClientboundPacket(0x33, ClientboundPlayerCombatEnterPacket.class, ClientboundPlayerCombatEnterPacket::new)
.registerClientboundPacket(0x34, ClientboundPlayerCombatKillPacket.class, ClientboundPlayerCombatKillPacket::new)
.registerClientboundPacket(0x35, ClientboundPlayerInfoRemovePacket.class, ClientboundPlayerInfoRemovePacket::new)
.registerClientboundPacket(0x36, ClientboundPlayerInfoUpdatePacket.class, ClientboundPlayerInfoUpdatePacket::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, ClientboundServerDataPacket.class, ClientboundServerDataPacket::new)
.registerClientboundPacket(0x42, ClientboundSetActionBarTextPacket.class, ClientboundSetActionBarTextPacket::new)
.registerClientboundPacket(0x43, ClientboundSetBorderCenterPacket.class, ClientboundSetBorderCenterPacket::new)
.registerClientboundPacket(0x44, ClientboundSetBorderLerpSizePacket.class, ClientboundSetBorderLerpSizePacket::new)
.registerClientboundPacket(0x45, ClientboundSetBorderSizePacket.class, ClientboundSetBorderSizePacket::new)
.registerClientboundPacket(0x46, ClientboundSetBorderWarningDelayPacket.class, ClientboundSetBorderWarningDelayPacket::new)
.registerClientboundPacket(0x47, ClientboundSetBorderWarningDistancePacket.class, ClientboundSetBorderWarningDistancePacket::new)
.registerClientboundPacket(0x48, ClientboundSetCameraPacket.class, ClientboundSetCameraPacket::new)
.registerClientboundPacket(0x49, ClientboundSetCarriedItemPacket.class, ClientboundSetCarriedItemPacket::new)
.registerClientboundPacket(0x4A, ClientboundSetChunkCacheCenterPacket.class, ClientboundSetChunkCacheCenterPacket::new)
.registerClientboundPacket(0x4B, ClientboundSetChunkCacheRadiusPacket.class, ClientboundSetChunkCacheRadiusPacket::new)
.registerClientboundPacket(0x4C, ClientboundSetDefaultSpawnPositionPacket.class, ClientboundSetDefaultSpawnPositionPacket::new)
.registerClientboundPacket(0x4D, ClientboundSetDisplayObjectivePacket.class, ClientboundSetDisplayObjectivePacket::new)
.registerClientboundPacket(0x4E, ClientboundSetEntityDataPacket.class, ClientboundSetEntityDataPacket::new)
.registerClientboundPacket(0x4F, ClientboundSetEntityLinkPacket.class, ClientboundSetEntityLinkPacket::new)
.registerClientboundPacket(0x50, ClientboundSetEntityMotionPacket.class, ClientboundSetEntityMotionPacket::new)
.registerClientboundPacket(0x51, ClientboundSetEquipmentPacket.class, ClientboundSetEquipmentPacket::new)
.registerClientboundPacket(0x52, ClientboundSetExperiencePacket.class, ClientboundSetExperiencePacket::new)
.registerClientboundPacket(0x53, ClientboundSetHealthPacket.class, ClientboundSetHealthPacket::new)
.registerClientboundPacket(0x54, ClientboundSetObjectivePacket.class, ClientboundSetObjectivePacket::new)
.registerClientboundPacket(0x55, ClientboundSetPassengersPacket.class, ClientboundSetPassengersPacket::new)
.registerClientboundPacket(0x56, ClientboundSetPlayerTeamPacket.class, ClientboundSetPlayerTeamPacket::new)
.registerClientboundPacket(0x57, ClientboundSetScorePacket.class, ClientboundSetScorePacket::new)
.registerClientboundPacket(0x58, ClientboundSetSimulationDistancePacket.class, ClientboundSetSimulationDistancePacket::new)
.registerClientboundPacket(0x59, ClientboundSetSubtitleTextPacket.class, ClientboundSetSubtitleTextPacket::new)
.registerClientboundPacket(0x5A, ClientboundSetTimePacket.class, ClientboundSetTimePacket::new)
.registerClientboundPacket(0x5B, ClientboundSetTitleTextPacket.class, ClientboundSetTitleTextPacket::new)
.registerClientboundPacket(0x5C, ClientboundSetTitlesAnimationPacket.class, ClientboundSetTitlesAnimationPacket::new)
.registerClientboundPacket(0x5D, ClientboundSoundEntityPacket.class, ClientboundSoundEntityPacket::new)
.registerClientboundPacket(0x5E, ClientboundSoundPacket.class, ClientboundSoundPacket::new)
.registerClientboundPacket(0x5F, ClientboundStopSoundPacket.class, ClientboundStopSoundPacket::new)
.registerClientboundPacket(0x60, ClientboundSystemChatPacket.class, ClientboundSystemChatPacket::new)
.registerClientboundPacket(0x61, ClientboundTabListPacket.class, ClientboundTabListPacket::new)
.registerClientboundPacket(0x62, ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new)
.registerClientboundPacket(0x63, ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new)
.registerClientboundPacket(0x64, ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new)
.registerClientboundPacket(0x65, ClientboundUpdateAdvancementsPacket.class, ClientboundUpdateAdvancementsPacket::new)
.registerClientboundPacket(0x66, ClientboundUpdateAttributesPacket.class, ClientboundUpdateAttributesPacket::new)
.registerClientboundPacket(0x67, ClientboundUpdateEnabledFeaturesPacket.class, ClientboundUpdateEnabledFeaturesPacket::new)
.registerClientboundPacket(0x68, ClientboundUpdateMobEffectPacket.class, ClientboundUpdateMobEffectPacket::new)
.registerClientboundPacket(0x69, ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new)
.registerClientboundPacket(0x6A, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new)
.registerClientboundPacket(0x00, ClientboundDelimiterPacket.class, ClientboundDelimiterPacket::new)
.registerClientboundPacket(0x01, ClientboundAddEntityPacket.class, ClientboundAddEntityPacket::new)
.registerClientboundPacket(0x02, ClientboundAddExperienceOrbPacket.class, ClientboundAddExperienceOrbPacket::new)
.registerClientboundPacket(0x03, ClientboundAddPlayerPacket.class, ClientboundAddPlayerPacket::new)
.registerClientboundPacket(0x04, ClientboundAnimatePacket.class, ClientboundAnimatePacket::new)
.registerClientboundPacket(0x05, ClientboundAwardStatsPacket.class, ClientboundAwardStatsPacket::new)
.registerClientboundPacket(0x06, ClientboundBlockChangedAckPacket.class, ClientboundBlockChangedAckPacket::new)
.registerClientboundPacket(0x07, ClientboundBlockDestructionPacket.class, ClientboundBlockDestructionPacket::new)
.registerClientboundPacket(0x08, ClientboundBlockEntityDataPacket.class, ClientboundBlockEntityDataPacket::new)
.registerClientboundPacket(0x09, ClientboundBlockEventPacket.class, ClientboundBlockEventPacket::new)
.registerClientboundPacket(0x0A, ClientboundBlockUpdatePacket.class, ClientboundBlockUpdatePacket::new)
.registerClientboundPacket(0x0B, ClientboundBossEventPacket.class, ClientboundBossEventPacket::new)
.registerClientboundPacket(0x0C, ClientboundChangeDifficultyPacket.class, ClientboundChangeDifficultyPacket::new)
.registerClientboundPacket(0x0D, ClientboundChunksBiomesPacket.class, ClientboundChunksBiomesPacket::new)
.registerClientboundPacket(0x0E, ClientboundClearTitlesPacket.class, ClientboundClearTitlesPacket::new)
.registerClientboundPacket(0x0F, ClientboundCommandSuggestionsPacket.class, ClientboundCommandSuggestionsPacket::new)
.registerClientboundPacket(0x10, ClientboundCommandsPacket.class, ClientboundCommandsPacket::new)
.registerClientboundPacket(0x11, ClientboundContainerClosePacket.class, ClientboundContainerClosePacket::new)
.registerClientboundPacket(0x12, ClientboundContainerSetContentPacket.class, ClientboundContainerSetContentPacket::new)
.registerClientboundPacket(0x13, ClientboundContainerSetDataPacket.class, ClientboundContainerSetDataPacket::new)
.registerClientboundPacket(0x14, ClientboundContainerSetSlotPacket.class, ClientboundContainerSetSlotPacket::new)
.registerClientboundPacket(0x15, ClientboundCooldownPacket.class, ClientboundCooldownPacket::new)
.registerClientboundPacket(0x16, ClientboundCustomChatCompletionsPacket.class, ClientboundCustomChatCompletionsPacket::new)
.registerClientboundPacket(0x17, ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket::new)
.registerClientboundPacket(0x18, ClientboundDamageEventPacket.class, ClientboundDamageEventPacket::new)
.registerClientboundPacket(0x19, ClientboundDeleteChatPacket.class, ClientboundDeleteChatPacket::new)
.registerClientboundPacket(0x1A, ClientboundDisconnectPacket.class, ClientboundDisconnectPacket::new)
.registerClientboundPacket(0x1B, ClientboundDisguisedChatPacket.class, ClientboundDisguisedChatPacket::new)
.registerClientboundPacket(0x1C, ClientboundEntityEventPacket.class, ClientboundEntityEventPacket::new)
.registerClientboundPacket(0x1D, ClientboundExplodePacket.class, ClientboundExplodePacket::new)
.registerClientboundPacket(0x1E, ClientboundForgetLevelChunkPacket.class, ClientboundForgetLevelChunkPacket::new)
.registerClientboundPacket(0x1F, ClientboundGameEventPacket.class, ClientboundGameEventPacket::new)
.registerClientboundPacket(0x20, ClientboundHorseScreenOpenPacket.class, ClientboundHorseScreenOpenPacket::new)
.registerClientboundPacket(0x21, ClientboundHurtAnimationPacket.class, ClientboundHurtAnimationPacket::new)
.registerClientboundPacket(0x22, ClientboundInitializeBorderPacket.class, ClientboundInitializeBorderPacket::new)
.registerClientboundPacket(0x23, ClientboundKeepAlivePacket.class, ClientboundKeepAlivePacket::new)
.registerClientboundPacket(0x24, ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkWithLightPacket::new)
.registerClientboundPacket(0x25, ClientboundLevelEventPacket.class, ClientboundLevelEventPacket::new)
.registerClientboundPacket(0x26, ClientboundLevelParticlesPacket.class, ClientboundLevelParticlesPacket::new)
.registerClientboundPacket(0x27, ClientboundLightUpdatePacket.class, ClientboundLightUpdatePacket::new)
.registerClientboundPacket(0x28, ClientboundLoginPacket.class, ClientboundLoginPacket::new)
.registerClientboundPacket(0x29, ClientboundMapItemDataPacket.class, ClientboundMapItemDataPacket::new)
.registerClientboundPacket(0x2A, ClientboundMerchantOffersPacket.class, ClientboundMerchantOffersPacket::new)
.registerClientboundPacket(0x2B, ClientboundMoveEntityPosPacket.class, ClientboundMoveEntityPosPacket::new)
.registerClientboundPacket(0x2C, ClientboundMoveEntityPosRotPacket.class, ClientboundMoveEntityPosRotPacket::new)
.registerClientboundPacket(0x2D, ClientboundMoveEntityRotPacket.class, ClientboundMoveEntityRotPacket::new)
.registerClientboundPacket(0x2E, ClientboundMoveVehiclePacket.class, ClientboundMoveVehiclePacket::new)
.registerClientboundPacket(0x2F, ClientboundOpenBookPacket.class, ClientboundOpenBookPacket::new)
.registerClientboundPacket(0x30, ClientboundOpenScreenPacket.class, ClientboundOpenScreenPacket::new)
.registerClientboundPacket(0x31, ClientboundOpenSignEditorPacket.class, ClientboundOpenSignEditorPacket::new)
.registerClientboundPacket(0x32, ClientboundPingPacket.class, ClientboundPingPacket::new)
.registerClientboundPacket(0x33, ClientboundPlaceGhostRecipePacket.class, ClientboundPlaceGhostRecipePacket::new)
.registerClientboundPacket(0x34, ClientboundPlayerAbilitiesPacket.class, ClientboundPlayerAbilitiesPacket::new)
.registerClientboundPacket(0x35, ClientboundPlayerChatPacket.class, ClientboundPlayerChatPacket::new)
.registerClientboundPacket(0x36, ClientboundPlayerCombatEndPacket.class, ClientboundPlayerCombatEndPacket::new)
.registerClientboundPacket(0x37, ClientboundPlayerCombatEnterPacket.class, ClientboundPlayerCombatEnterPacket::new)
.registerClientboundPacket(0x38, ClientboundPlayerCombatKillPacket.class, ClientboundPlayerCombatKillPacket::new)
.registerClientboundPacket(0x39, ClientboundPlayerInfoRemovePacket.class, ClientboundPlayerInfoRemovePacket::new)
.registerClientboundPacket(0x3A, ClientboundPlayerInfoUpdatePacket.class, ClientboundPlayerInfoUpdatePacket::new)
.registerClientboundPacket(0x3B, ClientboundPlayerLookAtPacket.class, ClientboundPlayerLookAtPacket::new)
.registerClientboundPacket(0x3C, ClientboundPlayerPositionPacket.class, ClientboundPlayerPositionPacket::new)
.registerClientboundPacket(0x3D, ClientboundRecipePacket.class, ClientboundRecipePacket::new)
.registerClientboundPacket(0x3E, ClientboundRemoveEntitiesPacket.class, ClientboundRemoveEntitiesPacket::new)
.registerClientboundPacket(0x3F, ClientboundRemoveMobEffectPacket.class, ClientboundRemoveMobEffectPacket::new)
.registerClientboundPacket(0x40, ClientboundResourcePackPacket.class, ClientboundResourcePackPacket::new)
.registerClientboundPacket(0x41, ClientboundRespawnPacket.class, ClientboundRespawnPacket::new)
.registerClientboundPacket(0x42, ClientboundRotateHeadPacket.class, ClientboundRotateHeadPacket::new)
.registerClientboundPacket(0x43, ClientboundSectionBlocksUpdatePacket.class, ClientboundSectionBlocksUpdatePacket::new)
.registerClientboundPacket(0x44, ClientboundSelectAdvancementsTabPacket.class, ClientboundSelectAdvancementsTabPacket::new)
.registerClientboundPacket(0x45, ClientboundServerDataPacket.class, ClientboundServerDataPacket::new)
.registerClientboundPacket(0x46, ClientboundSetActionBarTextPacket.class, ClientboundSetActionBarTextPacket::new)
.registerClientboundPacket(0x47, ClientboundSetBorderCenterPacket.class, ClientboundSetBorderCenterPacket::new)
.registerClientboundPacket(0x48, ClientboundSetBorderLerpSizePacket.class, ClientboundSetBorderLerpSizePacket::new)
.registerClientboundPacket(0x49, ClientboundSetBorderSizePacket.class, ClientboundSetBorderSizePacket::new)
.registerClientboundPacket(0x4A, ClientboundSetBorderWarningDelayPacket.class, ClientboundSetBorderWarningDelayPacket::new)
.registerClientboundPacket(0x4B, ClientboundSetBorderWarningDistancePacket.class, ClientboundSetBorderWarningDistancePacket::new)
.registerClientboundPacket(0x4C, ClientboundSetCameraPacket.class, ClientboundSetCameraPacket::new)
.registerClientboundPacket(0x4D, ClientboundSetCarriedItemPacket.class, ClientboundSetCarriedItemPacket::new)
.registerClientboundPacket(0x4E, ClientboundSetChunkCacheCenterPacket.class, ClientboundSetChunkCacheCenterPacket::new)
.registerClientboundPacket(0x4F, ClientboundSetChunkCacheRadiusPacket.class, ClientboundSetChunkCacheRadiusPacket::new)
.registerClientboundPacket(0x50, ClientboundSetDefaultSpawnPositionPacket.class, ClientboundSetDefaultSpawnPositionPacket::new)
.registerClientboundPacket(0x51, ClientboundSetDisplayObjectivePacket.class, ClientboundSetDisplayObjectivePacket::new)
.registerClientboundPacket(0x52, ClientboundSetEntityDataPacket.class, ClientboundSetEntityDataPacket::new)
.registerClientboundPacket(0x53, ClientboundSetEntityLinkPacket.class, ClientboundSetEntityLinkPacket::new)
.registerClientboundPacket(0x54, ClientboundSetEntityMotionPacket.class, ClientboundSetEntityMotionPacket::new)
.registerClientboundPacket(0x55, ClientboundSetEquipmentPacket.class, ClientboundSetEquipmentPacket::new)
.registerClientboundPacket(0x56, ClientboundSetExperiencePacket.class, ClientboundSetExperiencePacket::new)
.registerClientboundPacket(0x57, ClientboundSetHealthPacket.class, ClientboundSetHealthPacket::new)
.registerClientboundPacket(0x58, ClientboundSetObjectivePacket.class, ClientboundSetObjectivePacket::new)
.registerClientboundPacket(0x59, ClientboundSetPassengersPacket.class, ClientboundSetPassengersPacket::new)
.registerClientboundPacket(0x5A, ClientboundSetPlayerTeamPacket.class, ClientboundSetPlayerTeamPacket::new)
.registerClientboundPacket(0x5B, ClientboundSetScorePacket.class, ClientboundSetScorePacket::new)
.registerClientboundPacket(0x5C, ClientboundSetSimulationDistancePacket.class, ClientboundSetSimulationDistancePacket::new)
.registerClientboundPacket(0x5D, ClientboundSetSubtitleTextPacket.class, ClientboundSetSubtitleTextPacket::new)
.registerClientboundPacket(0x5E, ClientboundSetTimePacket.class, ClientboundSetTimePacket::new)
.registerClientboundPacket(0x5F, ClientboundSetTitleTextPacket.class, ClientboundSetTitleTextPacket::new)
.registerClientboundPacket(0x60, ClientboundSetTitlesAnimationPacket.class, ClientboundSetTitlesAnimationPacket::new)
.registerClientboundPacket(0x61, ClientboundSoundEntityPacket.class, ClientboundSoundEntityPacket::new)
.registerClientboundPacket(0x62, ClientboundSoundPacket.class, ClientboundSoundPacket::new)
.registerClientboundPacket(0x63, ClientboundStopSoundPacket.class, ClientboundStopSoundPacket::new)
.registerClientboundPacket(0x64, ClientboundSystemChatPacket.class, ClientboundSystemChatPacket::new)
.registerClientboundPacket(0x65, ClientboundTabListPacket.class, ClientboundTabListPacket::new)
.registerClientboundPacket(0x66, ClientboundTagQueryPacket.class, ClientboundTagQueryPacket::new)
.registerClientboundPacket(0x67, ClientboundTakeItemEntityPacket.class, ClientboundTakeItemEntityPacket::new)
.registerClientboundPacket(0x68, ClientboundTeleportEntityPacket.class, ClientboundTeleportEntityPacket::new)
.registerClientboundPacket(0x69, ClientboundUpdateAdvancementsPacket.class, ClientboundUpdateAdvancementsPacket::new)
.registerClientboundPacket(0x6A, ClientboundUpdateAttributesPacket.class, ClientboundUpdateAttributesPacket::new)
.registerClientboundPacket(0x6B, ClientboundUpdateEnabledFeaturesPacket.class, ClientboundUpdateEnabledFeaturesPacket::new)
.registerClientboundPacket(0x6C, ClientboundUpdateMobEffectPacket.class, ClientboundUpdateMobEffectPacket::new)
.registerClientboundPacket(0x6D, ClientboundUpdateRecipesPacket.class, ClientboundUpdateRecipesPacket::new)
.registerClientboundPacket(0x6E, ClientboundUpdateTagsPacket.class, ClientboundUpdateTagsPacket::new)
.registerServerboundPacket(0x00, ServerboundAcceptTeleportationPacket.class, ServerboundAcceptTeleportationPacket::new)
.registerServerboundPacket(0x01, ServerboundBlockEntityTagQuery.class, ServerboundBlockEntityTagQuery::new)
.registerServerboundPacket(0x02, ServerboundChangeDifficultyPacket.class, ServerboundChangeDifficultyPacket::new)
.registerServerboundPacket(0x03, ServerboundChatAckPacket.class, ServerboundChatAckPacket::new)
.registerServerboundPacket(0x04, ServerboundChatCommandPacket.class, ServerboundChatCommandPacket::new)
.registerServerboundPacket(0x05, ServerboundChatPacket.class, ServerboundChatPacket::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, ServerboundChatSessionUpdatePacket.class, ServerboundChatSessionUpdatePacket::new)
.registerServerboundPacket(0x06, ServerboundChatSessionUpdatePacket.class, ServerboundChatSessionUpdatePacket::new)
.registerServerboundPacket(0x07, ServerboundClientCommandPacket.class, ServerboundClientCommandPacket::new)
.registerServerboundPacket(0x08, ServerboundClientInformationPacket.class, ServerboundClientInformationPacket::new)
.registerServerboundPacket(0x09, ServerboundCommandSuggestionPacket.class, ServerboundCommandSuggestionPacket::new)
.registerServerboundPacket(0x0A, ServerboundContainerButtonClickPacket.class, ServerboundContainerButtonClickPacket::new)
.registerServerboundPacket(0x0B, ServerboundContainerClickPacket.class, ServerboundContainerClickPacket::new)
.registerServerboundPacket(0x0C, ServerboundContainerClosePacket.class, ServerboundContainerClosePacket::new)
.registerServerboundPacket(0x0D, ServerboundCustomPayloadPacket.class, ServerboundCustomPayloadPacket::new)
.registerServerboundPacket(0x0E, ServerboundEditBookPacket.class, ServerboundEditBookPacket::new)
.registerServerboundPacket(0x0F, ServerboundEntityTagQuery.class, ServerboundEntityTagQuery::new)
.registerServerboundPacket(0x10, ServerboundInteractPacket.class, ServerboundInteractPacket::new)
.registerServerboundPacket(0x11, ServerboundJigsawGeneratePacket.class, ServerboundJigsawGeneratePacket::new)
.registerServerboundPacket(0x12, ServerboundKeepAlivePacket.class, ServerboundKeepAlivePacket::new)
.registerServerboundPacket(0x13, ServerboundLockDifficultyPacket.class, ServerboundLockDifficultyPacket::new)
.registerServerboundPacket(0x14, ServerboundMovePlayerPosPacket.class, ServerboundMovePlayerPosPacket::new)
.registerServerboundPacket(0x15, ServerboundMovePlayerPosRotPacket.class, ServerboundMovePlayerPosRotPacket::new)
.registerServerboundPacket(0x16, ServerboundMovePlayerRotPacket.class, ServerboundMovePlayerRotPacket::new)
.registerServerboundPacket(0x17, ServerboundMovePlayerStatusOnlyPacket.class, ServerboundMovePlayerStatusOnlyPacket::new)
.registerServerboundPacket(0x18, ServerboundMoveVehiclePacket.class, ServerboundMoveVehiclePacket::new)
.registerServerboundPacket(0x19, ServerboundPaddleBoatPacket.class, ServerboundPaddleBoatPacket::new)
.registerServerboundPacket(0x1A, ServerboundPickItemPacket.class, ServerboundPickItemPacket::new)
.registerServerboundPacket(0x1B, ServerboundPlaceRecipePacket.class, ServerboundPlaceRecipePacket::new)
.registerServerboundPacket(0x1C, ServerboundPlayerAbilitiesPacket.class, ServerboundPlayerAbilitiesPacket::new)
.registerServerboundPacket(0x1D, ServerboundPlayerActionPacket.class, ServerboundPlayerActionPacket::new)
.registerServerboundPacket(0x1E, ServerboundPlayerCommandPacket.class, ServerboundPlayerCommandPacket::new)
.registerServerboundPacket(0x1F, ServerboundPlayerInputPacket.class, ServerboundPlayerInputPacket::new)
.registerServerboundPacket(0x20, ServerboundPongPacket.class, ServerboundPongPacket::new)
.registerServerboundPacket(0x21, ServerboundRecipeBookChangeSettingsPacket.class, ServerboundRecipeBookChangeSettingsPacket::new)
.registerServerboundPacket(0x22, ServerboundRecipeBookSeenRecipePacket.class, ServerboundRecipeBookSeenRecipePacket::new)
.registerServerboundPacket(0x23, ServerboundRenameItemPacket.class, ServerboundRenameItemPacket::new)

View file

@ -8,18 +8,39 @@ import com.github.steveice10.mc.protocol.data.game.chunk.BitStorage;
import com.github.steveice10.mc.protocol.data.game.chunk.ChunkSection;
import com.github.steveice10.mc.protocol.data.game.chunk.DataPalette;
import com.github.steveice10.mc.protocol.data.game.chunk.NibbleArray3d;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.*;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.GlobalPalette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.ListPalette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.MapPalette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.Palette;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.PaletteType;
import com.github.steveice10.mc.protocol.data.game.chunk.palette.SingletonPalette;
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.*;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.GlobalPos;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.SnifferState;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.VillagerData;
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
import com.github.steveice10.mc.protocol.data.game.entity.player.BlockBreakStage;
import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType;
import com.github.steveice10.mc.protocol.data.game.level.LightUpdateData;
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
import com.github.steveice10.mc.protocol.data.game.level.event.LevelEvent;
import com.github.steveice10.mc.protocol.data.game.level.particle.*;
import com.github.steveice10.mc.protocol.data.game.level.particle.BlockParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.DustColorTransitionParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.DustParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.FallingDustParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.ItemParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.Particle;
import com.github.steveice10.mc.protocol.data.game.level.particle.ParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.ParticleType;
import com.github.steveice10.mc.protocol.data.game.level.particle.SculkChargeParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.ShriekParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.VibrationParticleData;
import com.github.steveice10.mc.protocol.data.game.level.particle.positionsource.BlockPositionSource;
import com.github.steveice10.mc.protocol.data.game.level.particle.positionsource.EntityPositionSource;
import com.github.steveice10.mc.protocol.data.game.level.particle.positionsource.PositionSource;
@ -37,6 +58,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.github.steveice10.packetlib.codec.BasePacketCodecHelper;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.math.vector.Vector4f;
import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.RequiredArgsConstructor;
@ -53,7 +75,11 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.*;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.ObjIntConsumer;
import java.util.function.ToIntFunction;
@RequiredArgsConstructor
public class MinecraftCodecHelper extends BasePacketCodecHelper {
@ -269,6 +295,22 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
buf.writeFloat(rot.getZ());
}
public Vector4f readQuaternion(ByteBuf buf) {
float x = buf.readFloat();
float y = buf.readFloat();
float z = buf.readFloat();
float w = buf.readFloat();
return Vector4f.from(x, y, z, w);
}
public void writeQuaternion(ByteBuf buf, Vector4f vec4) {
buf.writeFloat(vec4.getX());
buf.writeFloat(vec4.getY());
buf.writeFloat(vec4.getZ());
buf.writeFloat(vec4.getW());
}
public Direction readDirection(ByteBuf buf) {
return Direction.from(this.readVarInt(buf));
}
@ -293,6 +335,14 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
this.writeEnum(buf, type);
}
public SnifferState readSnifferState(ByteBuf buf) {
return SnifferState.from(this.readVarInt(buf));
}
public void writeSnifferState(ByteBuf buf, SnifferState state) {
this.writeEnum(buf, state);
}
private void writeEnum(ByteBuf buf, Enum<?> e) {
this.writeVarInt(buf, e.ordinal());
}

View file

@ -159,7 +159,6 @@ public class MagicValues {
register(Difficulty.HARD, 3);
register(Animation.SWING_ARM, 0);
register(Animation.DAMAGE, 1);
register(Animation.LEAVE_BED, 2);
register(Animation.SWING_OFFHAND, 3);
register(Animation.CRITICAL_HIT, 4);

View file

@ -0,0 +1,12 @@
package com.github.steveice10.mc.protocol.data.game.chunk;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class ChunkBiomeData {
private final int x;
private final int z;
private final byte[] buffer;
}

View file

@ -1,13 +1,19 @@
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.*;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.LongEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
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.mc.protocol.data.game.level.particle.Particle;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.math.vector.Vector4f;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import net.kyori.adventure.text.Component;
@ -36,7 +42,8 @@ public class MetadataType<T> {
public static final MetadataType<Optional<Vector3i>> OPTIONAL_POSITION = new MetadataType<>(optionalReader(MinecraftCodecHelper::readPosition), optionalWriter(MinecraftCodecHelper::writePosition), ObjectEntityMetadata::new);
public static final MetadataType<Direction> DIRECTION = new MetadataType<>(MinecraftCodecHelper::readDirection, MinecraftCodecHelper::writeDirection, ObjectEntityMetadata::new);
public static final MetadataType<Optional<UUID>> OPTIONAL_UUID = new MetadataType<>(optionalReader(MinecraftCodecHelper::readUUID), optionalWriter(MinecraftCodecHelper::writeUUID), ObjectEntityMetadata::new);
public static final OptionalIntMetadataType BLOCK_STATE = new OptionalIntMetadataType(ObjectEntityMetadata::new);
public static final IntMetadataType BLOCK_STATE = new IntMetadataType(MinecraftCodecHelper::readVarInt, MinecraftCodecHelper::writeVarInt, IntEntityMetadata::new);
public static final MetadataType<Optional<Integer>> OPTIONAL_BLOCK_STATE = new MetadataType<>(optionalReader(MinecraftCodecHelper::readVarInt), optionalWriter(MinecraftCodecHelper::writeVarInt), ObjectEntityMetadata::new);
public static final MetadataType<CompoundTag> NBT_TAG = new MetadataType<>(MinecraftCodecHelper::readTag, MinecraftCodecHelper::writeTag, ObjectEntityMetadata::new);
public static final MetadataType<Particle> PARTICLE = new MetadataType<>(MinecraftCodecHelper::readParticle, MinecraftCodecHelper::writeParticle, ObjectEntityMetadata::new);
public static final MetadataType<VillagerData> VILLAGER_DATA = new MetadataType<>(MinecraftCodecHelper::readVillagerData, MinecraftCodecHelper::writeVillagerData, ObjectEntityMetadata::new);
@ -46,6 +53,9 @@ public class MetadataType<T> {
public static final IntMetadataType FROG_VARIANT = new IntMetadataType(MinecraftCodecHelper::readVarInt, MinecraftCodecHelper::writeVarInt, IntEntityMetadata::new);
public static final MetadataType<Optional<GlobalPos>> OPTIONAL_GLOBAL_POS = new MetadataType<>(optionalReader(MinecraftCodecHelper::readGlobalPos), optionalWriter(MinecraftCodecHelper::writeGlobalPos), ObjectEntityMetadata::new);
public static final MetadataType<PaintingType> PAINTING_VARIANT = new MetadataType<>(MinecraftCodecHelper::readPaintingType, MinecraftCodecHelper::writePaintingType, ObjectEntityMetadata::new);
public static final MetadataType<SnifferState> SNIFFER_STATE = new MetadataType<>(MinecraftCodecHelper::readSnifferState, MinecraftCodecHelper::writeSnifferState, ObjectEntityMetadata::new);
public static final MetadataType<Vector3f> VECTOR3 = new MetadataType<>(MinecraftCodecHelper::readRotation, MinecraftCodecHelper::writeRotation, ObjectEntityMetadata::new);
public static final MetadataType<Vector4f> QUATERNION = new MetadataType<>(MinecraftCodecHelper::readQuaternion, MinecraftCodecHelper::writeQuaternion, ObjectEntityMetadata::new);
protected final int id;
protected final Reader<T> reader;

View file

@ -0,0 +1,17 @@
package com.github.steveice10.mc.protocol.data.game.entity.metadata;
public enum SnifferState {
IDLING,
FEELING_HAPPY,
SCENTING,
SNIFFING,
SEARCHING,
DIGGING,
RISING;
private static final SnifferState[] VALUES = values();
public static SnifferState from(int id) {
return VALUES[id];
}
}

View file

@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.data.game.entity.player;
public enum Animation {
SWING_ARM,
DAMAGE,
LEAVE_BED,
SWING_OFFHAND,
CRITICAL_HIT,

View file

@ -30,6 +30,9 @@ public enum ParticleType {
FIREWORK,
FISHING,
FLAME,
DRIPPING_CHERRY_LEAVES,
FALLING_CHERRY_LEAVES,
LANDING_CHERRY_LEAVES,
SCULK_SOUL,
SCULK_CHARGE,
SCULK_CHARGE_POP,

View file

@ -173,6 +173,8 @@ public enum BuiltinSound implements Sound {
ITEM_BOTTLE_FILL("item.bottle.fill"),
ITEM_BOTTLE_FILL_DRAGONBREATH("item.bottle.fill_dragonbreath"),
BLOCK_BREWING_STAND_BREW("block.brewing_stand.brew"),
ITEM_BRUSH_BRUSHING("item.brush.brushing"),
ITEM_BRUSH_BRUSH_SAND_COMPLETED("item.brush.brush_sand_completed"),
BLOCK_BUBBLE_COLUMN_BUBBLE_POP("block.bubble_column.bubble_pop"),
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT("block.bubble_column.upwards_ambient"),
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE("block.bubble_column.upwards_inside"),
@ -238,6 +240,36 @@ public enum BuiltinSound implements Sound {
BLOCK_CHAIN_HIT("block.chain.hit"),
BLOCK_CHAIN_PLACE("block.chain.place"),
BLOCK_CHAIN_STEP("block.chain.step"),
BLOCK_CHERRY_WOOD_BREAK("block.cherry_wood.break"),
BLOCK_CHERRY_WOOD_FALL("block.cherry_wood.fall"),
BLOCK_CHERRY_WOOD_HIT("block.cherry_wood.hit"),
BLOCK_CHERRY_WOOD_PLACE("block.cherry_wood.place"),
BLOCK_CHERRY_WOOD_STEP("block.cherry_wood.step"),
BLOCK_CHERRY_SAPLING_BREAK("block.cherry_sapling.break"),
BLOCK_CHERRY_SAPLING_FALL("block.cherry_sapling.fall"),
BLOCK_CHERRY_SAPLING_HIT("block.cherry_sapling.hit"),
BLOCK_CHERRY_SAPLING_PLACE("block.cherry_sapling.place"),
BLOCK_CHERRY_SAPLING_STEP("block.cherry_sapling.step"),
BLOCK_CHERRY_LEAVES_BREAK("block.cherry_leaves.break"),
BLOCK_CHERRY_LEAVES_FALL("block.cherry_leaves.fall"),
BLOCK_CHERRY_LEAVES_HIT("block.cherry_leaves.hit"),
BLOCK_CHERRY_LEAVES_PLACE("block.cherry_leaves.place"),
BLOCK_CHERRY_LEAVES_STEP("block.cherry_leaves.step"),
BLOCK_CHERRY_WOOD_HANGING_SIGN_STEP("block.cherry_wood_hanging_sign.step"),
BLOCK_CHERRY_WOOD_HANGING_SIGN_BREAK("block.cherry_wood_hanging_sign.break"),
BLOCK_CHERRY_WOOD_HANGING_SIGN_FALL("block.cherry_wood_hanging_sign.fall"),
BLOCK_CHERRY_WOOD_HANGING_SIGN_HIT("block.cherry_wood_hanging_sign.hit"),
BLOCK_CHERRY_WOOD_HANGING_SIGN_PLACE("block.cherry_wood_hanging_sign.place"),
BLOCK_CHERRY_WOOD_DOOR_CLOSE("block.cherry_wood_door.close"),
BLOCK_CHERRY_WOOD_DOOR_OPEN("block.cherry_wood_door.open"),
BLOCK_CHERRY_WOOD_TRAPDOOR_CLOSE("block.cherry_wood_trapdoor.close"),
BLOCK_CHERRY_WOOD_TRAPDOOR_OPEN("block.cherry_wood_trapdoor.open"),
BLOCK_CHERRY_WOOD_BUTTON_CLICK_OFF("block.cherry_wood_button.click_off"),
BLOCK_CHERRY_WOOD_BUTTON_CLICK_ON("block.cherry_wood_button.click_on"),
BLOCK_CHERRY_WOOD_PRESSURE_PLATE_CLICK_OFF("block.cherry_wood_pressure_plate.click_off"),
BLOCK_CHERRY_WOOD_PRESSURE_PLATE_CLICK_ON("block.cherry_wood_pressure_plate.click_on"),
BLOCK_CHERRY_WOOD_FENCE_GATE_CLOSE("block.cherry_wood_fence_gate.close"),
BLOCK_CHERRY_WOOD_FENCE_GATE_OPEN("block.cherry_wood_fence_gate.open"),
BLOCK_CHEST_CLOSE("block.chest.close"),
BLOCK_CHEST_LOCKED("block.chest.locked"),
BLOCK_CHEST_OPEN("block.chest.open"),
@ -300,6 +332,12 @@ public enum BuiltinSound implements Sound {
ITEM_CROSSBOW_QUICK_CHARGE_2("item.crossbow.quick_charge_2"),
ITEM_CROSSBOW_QUICK_CHARGE_3("item.crossbow.quick_charge_3"),
ITEM_CROSSBOW_SHOOT("item.crossbow.shoot"),
BLOCK_DECORATED_POT_BREAK("block.decorated_pot.break"),
BLOCK_DECORATED_POT_FALL("block.decorated_pot.fall"),
BLOCK_DECORATED_POT_HIT("block.decorated_pot.hit"),
BLOCK_DECORATED_POT_STEP("block.decorated_pot.step"),
BLOCK_DECORATED_POT_PLACE("block.decorated_pot.place"),
BLOCK_DECORATED_POT_SHATTER("block.decorated_pot.shatter"),
BLOCK_DEEPSLATE_BRICKS_BREAK("block.deepslate_bricks.break"),
BLOCK_DEEPSLATE_BRICKS_FALL("block.deepslate_bricks.fall"),
BLOCK_DEEPSLATE_BRICKS_HIT("block.deepslate_bricks.hit"),
@ -442,6 +480,11 @@ public enum BuiltinSound implements Sound {
ENTITY_FOX_SNIFF("entity.fox.sniff"),
ENTITY_FOX_SPIT("entity.fox.spit"),
ENTITY_FOX_TELEPORT("entity.fox.teleport"),
BLOCK_SUSPICIOUS_SAND_BREAK("block.suspicious_sand.break"),
BLOCK_SUSPICIOUS_SAND_STEP("block.suspicious_sand.step"),
BLOCK_SUSPICIOUS_SAND_PLACE("block.suspicious_sand.place"),
BLOCK_SUSPICIOUS_SAND_HIT("block.suspicious_sand.hit"),
BLOCK_SUSPICIOUS_SAND_FALL("block.suspicious_sand.fall"),
BLOCK_FROGLIGHT_BREAK("block.froglight.break"),
BLOCK_FROGLIGHT_FALL("block.froglight.fall"),
BLOCK_FROGLIGHT_HIT("block.froglight.hit"),
@ -708,6 +751,11 @@ public enum BuiltinSound implements Sound {
BLOCK_MOSS_CARPET_HIT("block.moss_carpet.hit"),
BLOCK_MOSS_CARPET_PLACE("block.moss_carpet.place"),
BLOCK_MOSS_CARPET_STEP("block.moss_carpet.step"),
BLOCK_PINK_PETALS_BREAK("block.pink_petals.break"),
BLOCK_PINK_PETALS_FALL("block.pink_petals.fall"),
BLOCK_PINK_PETALS_HIT("block.pink_petals.hit"),
BLOCK_PINK_PETALS_PLACE("block.pink_petals.place"),
BLOCK_PINK_PETALS_STEP("block.pink_petals.step"),
BLOCK_MOSS_BREAK("block.moss.break"),
BLOCK_MOSS_FALL("block.moss.fall"),
BLOCK_MOSS_HIT("block.moss.hit"),
@ -766,6 +814,7 @@ public enum BuiltinSound implements Sound {
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_OVERWORLD_CHERRY_GROVE("music.overworld.cherry_grove"),
MUSIC_NETHER_NETHER_WASTES("music.nether.nether_wastes"),
MUSIC_OVERWORLD_FROZEN_PEAKS("music.overworld.frozen_peaks"),
MUSIC_OVERWORLD_SNOWY_SLOPES("music.overworld.snowy_slopes"),
@ -795,6 +844,7 @@ public enum BuiltinSound implements Sound {
BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_ON("block.nether_wood_pressure_plate.click_on"),
BLOCK_NETHER_WOOD_FENCE_GATE_CLOSE("block.nether_wood_fence_gate.close"),
BLOCK_NETHER_WOOD_FENCE_GATE_OPEN("block.nether_wood_fence_gate.open"),
INTENTIONALLY_EMPTY("intentionally_empty"),
BLOCK_PACKED_MUD_BREAK("block.packed_mud.break"),
BLOCK_PACKED_MUD_FALL("block.packed_mud.fall"),
BLOCK_PACKED_MUD_HIT("block.packed_mud.hit"),
@ -1167,6 +1217,18 @@ public enum BuiltinSound implements Sound {
ENTITY_SLIME_SQUISH_SMALL("entity.slime.squish_small"),
BLOCK_SMITHING_TABLE_USE("block.smithing_table.use"),
BLOCK_SMOKER_SMOKE("block.smoker.smoke"),
ENTITY_SNIFFER_STEP("entity.sniffer.step"),
ENTITY_SNIFFER_EAT("entity.sniffer.eat"),
ENTITY_SNIFFER_IDLE("entity.sniffer.idle"),
ENTITY_SNIFFER_HURT("entity.sniffer.hurt"),
ENTITY_SNIFFER_DEATH("entity.sniffer.death"),
ENTITY_SNIFFER_DROP_SEED("entity.sniffer.drop_seed"),
ENTITY_SNIFFER_SCENTING("entity.sniffer.scenting"),
ENTITY_SNIFFER_SNIFFING("entity.sniffer.sniffing"),
ENTITY_SNIFFER_SEARCHING("entity.sniffer.searching"),
ENTITY_SNIFFER_DIGGING("entity.sniffer.digging"),
ENTITY_SNIFFER_DIGGING_STOP("entity.sniffer.digging_stop"),
ENTITY_SNIFFER_HAPPY("entity.sniffer.happy"),
ENTITY_SNOWBALL_THROW("entity.snowball.throw"),
BLOCK_SNOW_BREAK("block.snow.break"),
BLOCK_SNOW_FALL("block.snow.fall"),
@ -1356,14 +1418,14 @@ public enum BuiltinSound implements Sound {
BLOCK_WOODEN_DOOR_OPEN("block.wooden_door.open"),
BLOCK_WOODEN_TRAPDOOR_CLOSE("block.wooden_trapdoor.close"),
BLOCK_WOODEN_TRAPDOOR_OPEN("block.wooden_trapdoor.open"),
BLOCK_WOOD_BREAK("block.wood.break"),
BLOCK_WOODEN_BUTTON_CLICK_OFF("block.wooden_button.click_off"),
BLOCK_WOODEN_BUTTON_CLICK_ON("block.wooden_button.click_on"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF("block.wooden_pressure_plate.click_off"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON("block.wooden_pressure_plate.click_on"),
BLOCK_WOOD_BREAK("block.wood.break"),
BLOCK_WOOD_FALL("block.wood.fall"),
BLOCK_WOOD_HIT("block.wood.hit"),
BLOCK_WOOD_PLACE("block.wood.place"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF("block.wooden_pressure_plate.click_off"),
BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON("block.wooden_pressure_plate.click_on"),
BLOCK_WOOD_STEP("block.wood.step"),
BLOCK_WOOL_BREAK("block.wool.break"),
BLOCK_WOOL_FALL("block.wool.fall"),

View file

@ -7,11 +7,13 @@ import lombok.Data;
import lombok.NonNull;
import lombok.Setter;
import java.util.List;
@Data
@Setter(AccessLevel.NONE)
@AllArgsConstructor
public class PlayerInfo {
private int maxPlayers;
private int onlinePlayers;
private @NonNull GameProfile[] players;
private @NonNull List<GameProfile> players;
}

View file

@ -0,0 +1,14 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import io.netty.buffer.ByteBuf;
public class ClientboundDelimiterPacket implements MinecraftPacket {
public ClientboundDelimiterPacket(ByteBuf in, MinecraftCodecHelper helper) {
}
@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
}
}

View file

@ -2,7 +2,6 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -16,38 +15,20 @@ import java.io.IOException;
@With
@AllArgsConstructor
public class ClientboundServerDataPacket implements MinecraftPacket {
private final @Nullable Component motd;
private final @Nullable String iconBase64;
private final Component motd;
private final byte @Nullable[] iconBytes;
private final boolean enforcesSecureChat;
public ClientboundServerDataPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
if (in.readBoolean()) {
this.motd = helper.readComponent(in);
} else {
this.motd = null;
}
if (in.readBoolean()) {
this.iconBase64 = helper.readString(in);
} else {
this.iconBase64 = null;
}
this.iconBytes = helper.readNullable(in, helper::readByteArray);
this.enforcesSecureChat = in.readBoolean();
}
@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) throws IOException {
out.writeBoolean(this.motd != null);
if (this.motd != null) {
helper.writeString(out, DefaultComponentSerializer.get().serialize(this.motd));
}
out.writeBoolean(this.iconBase64 != null);
if (this.iconBase64 != null) {
helper.writeString(out, this.iconBase64);
}
helper.writeComponent(out, this.motd);
helper.writeNullable(out, this.iconBytes, helper::writeByteArray);
out.writeBoolean(this.enforcesSecureChat);
}
}

View file

@ -0,0 +1,40 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.nukkitx.math.vector.Vector3d;
import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.Nullable;
public class ClientboundDamageEventPacket implements MinecraftPacket {
private final int entityId;
private final int sourceTypeId;
private final int sourceCauseId;
private final int sourceDirectId;
private final @Nullable Vector3d sourcePosition;
public ClientboundDamageEventPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.entityId = helper.readVarInt(in);
this.sourceTypeId = helper.readVarInt(in);
this.sourceCauseId = helper.readVarInt(in) - 1;
this.sourceDirectId = helper.readVarInt(in) - 1;
this.sourcePosition = in.readBoolean() ? Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble()) : null;
}
@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.entityId);
helper.writeVarInt(out, this.sourceTypeId);
helper.writeVarInt(out, this.sourceCauseId + 1);
helper.writeVarInt(out, this.sourceDirectId + 1);
if (this.sourcePosition != null) {
out.writeBoolean(true);
out.writeDouble(this.sourcePosition.getX());
out.writeDouble(this.sourcePosition.getY());
out.writeDouble(this.sourcePosition.getZ());
} else {
out.writeBoolean(false);
}
}
}

View file

@ -0,0 +1,27 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import io.netty.buffer.ByteBuf;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.With;
@Data
@With
@AllArgsConstructor
public class ClientboundHurtAnimationPacket implements MinecraftPacket {
private final int id;
private final float yaw;
public ClientboundHurtAnimationPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.id = helper.readVarInt(in);
this.yaw = in.readFloat();
}
@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.id);
out.writeFloat(this.yaw);
}
}

View file

@ -25,11 +25,10 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket {
private final float yaw;
private final float pitch;
private final int teleportId;
private final boolean dismountVehicle;
private final @NonNull List<PositionElement> relative;
public ClientboundPlayerPositionPacket(double x, double y, double z, float yaw, float pitch, int teleportId, boolean dismountVehicle, PositionElement... relative) {
this(x, y, z, yaw, pitch, teleportId, dismountVehicle, Arrays.asList(relative != null ? relative : new PositionElement[0]));
public ClientboundPlayerPositionPacket(double x, double y, double z, float yaw, float pitch, int teleportId, PositionElement... relative) {
this(x, y, z, yaw, pitch, teleportId, Arrays.asList(relative != null ? relative : new PositionElement[0]));
}
public ClientboundPlayerPositionPacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
@ -49,7 +48,6 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket {
}
this.teleportId = helper.readVarInt(in);
this.dismountVehicle = in.readBoolean();
}
@Override
@ -68,6 +66,5 @@ public class ClientboundPlayerPositionPacket implements MinecraftPacket {
out.writeByte(flags);
helper.writeVarInt(out, this.teleportId);
out.writeBoolean(this.dismountVehicle);
}
}

View file

@ -0,0 +1,33 @@
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
import com.github.steveice10.mc.protocol.codec.MinecraftCodecHelper;
import com.github.steveice10.mc.protocol.codec.MinecraftPacket;
import com.github.steveice10.mc.protocol.data.game.chunk.ChunkBiomeData;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
public class ClientboundChunksBiomesPacket implements MinecraftPacket {
private final List<ChunkBiomeData> chunkBiomeData;
public ClientboundChunksBiomesPacket(ByteBuf in, MinecraftCodecHelper helper) {
this.chunkBiomeData = new ArrayList<>();
int length = helper.readVarInt(in);
for (int i = 0; i < length; i++) {
long raw = in.readLong();
this.chunkBiomeData.add(new ChunkBiomeData((int)raw, (int)(raw >> 32), helper.readByteArray(in)));
}
}
@Override
public void serialize(ByteBuf out, MinecraftCodecHelper helper) {
helper.writeVarInt(out, this.chunkBiomeData.size());
for (ChunkBiomeData entry : this.chunkBiomeData) {
long raw = (long)entry.getX() & 0xFFFFFFFFL | ((long)entry.getZ() & 0xFFFFFFFFL) << 32;
out.writeLong(raw);
helper.writeByteArray(out, entry.getBuffer());
}
}
}

View file

@ -62,7 +62,7 @@ public class ClientboundSectionBlocksUpdatePacket implements MinecraftPacket {
helper.writeVarInt(out, this.entries.length);
for (BlockChangeEntry entry : this.entries) {
short position = (short) ((entry.getPosition().getX() - (this.chunkX << 4)) << 8 | (entry.getPosition().getZ() - (this.chunkZ << 4)) << 4 | (entry.getPosition().getY() - (this.chunkY << 4)));
helper.writeVarLong(out, (long) entry.getBlock() << 12 | position);
helper.writeVarLong(out, (long) entry.getBlock() << 12 | (long) position);
}
}
}

View file

@ -21,6 +21,8 @@ import net.kyori.adventure.text.Component;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@Data
@With
@ -30,24 +32,23 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket {
public ClientboundStatusResponsePacket(ByteBuf in, MinecraftCodecHelper helper) throws IOException {
JsonObject obj = new Gson().fromJson(helper.readString(in), JsonObject.class);
JsonObject ver = obj.get("version").getAsJsonObject();
VersionInfo version = new VersionInfo(ver.get("name").getAsString(), ver.get("protocol").getAsInt());
JsonElement desc = obj.get("description");
Component description = DefaultComponentSerializer.get().serializer().fromJson(desc, Component.class);
JsonObject plrs = obj.get("players").getAsJsonObject();
GameProfile[] profiles = new GameProfile[0];
List<GameProfile> profiles = new ArrayList<>();
if (plrs.has("sample")) {
JsonArray prof = plrs.get("sample").getAsJsonArray();
if (prof.size() > 0) {
profiles = new GameProfile[prof.size()];
for (int index = 0; index < prof.size(); index++) {
JsonObject o = prof.get(index).getAsJsonObject();
profiles[index] = new GameProfile(o.get("id").getAsString(), o.get("name").getAsString());
profiles.add(new GameProfile(o.get("id").getAsString(), o.get("name").getAsString()));
}
}
}
PlayerInfo players = new PlayerInfo(plrs.get("max").getAsInt(), plrs.get("online").getAsInt(), profiles);
JsonElement desc = obj.get("description");
Component description = DefaultComponentSerializer.get().serializer().fromJson(desc, Component.class);
JsonObject ver = obj.get("version").getAsJsonObject();
VersionInfo version = new VersionInfo(ver.get("name").getAsString(), ver.get("protocol").getAsInt());
byte[] icon = null;
if (obj.has("favicon")) {
icon = this.stringToIcon(obj.get("favicon").getAsString());
@ -66,7 +67,7 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket {
JsonObject plrs = new JsonObject();
plrs.addProperty("max", this.info.getPlayerInfo().getMaxPlayers());
plrs.addProperty("online", this.info.getPlayerInfo().getOnlinePlayers());
if (this.info.getPlayerInfo().getPlayers().length > 0) {
if (this.info.getPlayerInfo().getPlayers().size() > 0) {
JsonArray array = new JsonArray();
for (GameProfile profile : this.info.getPlayerInfo().getPlayers()) {
JsonObject o = new JsonObject();
@ -78,9 +79,9 @@ public class ClientboundStatusResponsePacket implements MinecraftPacket {
plrs.add("sample", array);
}
obj.add("version", ver);
obj.add("players", plrs);
obj.add("description", new Gson().fromJson(DefaultComponentSerializer.get().serialize(this.info.getDescription()), JsonElement.class));
obj.add("players", plrs);
obj.add("version", ver);
if (this.info.getIconPng() != null) {
obj.addProperty("favicon", this.iconToString(this.info.getIconPng()));
}

View file

@ -1,6 +1,5 @@
package com.github.steveice10.mc.protocol;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.codec.MinecraftCodec;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.status.PlayerInfo;
@ -27,6 +26,7 @@ import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.zip.GZIPInputStream;
@ -46,7 +46,7 @@ public class MinecraftProtocolTest {
private static final ServerStatusInfo SERVER_INFO = new ServerStatusInfo(
new VersionInfo(MinecraftCodec.CODEC.getMinecraftVersion(), MinecraftCodec.CODEC.getProtocolVersion()),
new PlayerInfo(100, 0, new GameProfile[0]),
new PlayerInfo(100, 0, new ArrayList<>()),
Component.text("Hello world!"),
null,
false

View file

@ -2,7 +2,12 @@ package com.github.steveice10.mc.protocol.packet.ingame.clientbound.level;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.MetadataType;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.*;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.FloatEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.LongEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ObjectEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
import com.github.steveice10.mc.protocol.packet.PacketTest;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
@ -27,7 +32,7 @@ public class ClientboundSetEntityDataPacketTest extends PacketTest {
new FloatEntityMetadata(3, MetadataType.FLOAT, 3.0f),
new LongEntityMetadata(8, MetadataType.LONG, 123456789L),
new ObjectEntityMetadata<>(5, MetadataType.POSITION, Vector3i.from(0, 1, 0)),
new ObjectEntityMetadata<>(2, MetadataType.BLOCK_STATE, OptionalInt.of(60)),
new ObjectEntityMetadata<>(2, MetadataType.BLOCK_STATE, 60),
new ObjectEntityMetadata<>(6, MetadataType.DIRECTION, Direction.EAST),
new ObjectEntityMetadata<>(7, MetadataType.OPTIONAL_VARINT, OptionalInt.of(1038))
}),

View file

@ -9,6 +9,8 @@ import com.github.steveice10.mc.protocol.packet.PacketTest;
import net.kyori.adventure.text.Component;
import org.junit.Before;
import java.util.ArrayList;
import java.util.Collections;
import java.util.UUID;
public class ClientboundStatusResponsePacketTest extends PacketTest {
@ -17,9 +19,9 @@ public class ClientboundStatusResponsePacketTest extends PacketTest {
this.setPackets(new ClientboundStatusResponsePacket(
new ServerStatusInfo(
new VersionInfo(MinecraftCodec.CODEC.getMinecraftVersion(), MinecraftCodec.CODEC.getProtocolVersion()),
new PlayerInfo(100, 10, new GameProfile[]{
new GameProfile(UUID.randomUUID(), "Username")
}),
new PlayerInfo(100, 10, new ArrayList<>(
Collections.singleton(new GameProfile(UUID.randomUUID(), "Username"))
)),
Component.text("Description"),
null,
false

Binary file not shown.