Update to 1.16-rc1 and update chunk format to use new padded array

This commit is contained in:
RednedEpic 2020-06-20 15:31:39 -05:00
parent 1205c36965
commit 3f5f9797e6
13 changed files with 284 additions and 213 deletions

View file

@ -5,7 +5,7 @@
<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>20w22a-SNAPSHOT</version>
<version>1.16-rc1</version>
<packaging>jar</packaging>
<name>MCProtocolLib</name>

View file

@ -2,8 +2,8 @@ package com.github.steveice10.mc.protocol;
public class MinecraftConstants {
// General Constants
public static final String GAME_VERSION = "20w22a";
public static final int PROTOCOL_VERSION = 719;
public static final String GAME_VERSION = "1.16-rc1";
public static final int PROTOCOL_VERSION = 734;
// General Key Constants
public static final String PROFILE_KEY = "profile";

View file

@ -375,97 +375,96 @@ public class MinecraftProtocol extends PacketProtocol {
private void initClientGame(Session session) {
this.registerIncoming(0x00, ServerSpawnEntityPacket.class);
this.registerIncoming(0x01, ServerSpawnExpOrbPacket.class);
this.registerIncoming(0x02, ServerSpawnWeatherEntityPacket.class);
this.registerIncoming(0x03, ServerSpawnLivingEntityPacket.class);
this.registerIncoming(0x04, ServerSpawnPaintingPacket.class);
this.registerIncoming(0x05, ServerSpawnPlayerPacket.class);
this.registerIncoming(0x06, ServerEntityAnimationPacket.class);
this.registerIncoming(0x07, ServerStatisticsPacket.class);
this.registerIncoming(0x08, ServerPlayerActionAckPacket.class);
this.registerIncoming(0x09, ServerBlockBreakAnimPacket.class);
this.registerIncoming(0x0A, ServerUpdateTileEntityPacket.class);
this.registerIncoming(0x0B, ServerBlockValuePacket.class);
this.registerIncoming(0x0C, ServerBlockChangePacket.class);
this.registerIncoming(0x0D, ServerBossBarPacket.class);
this.registerIncoming(0x0E, ServerDifficultyPacket.class);
this.registerIncoming(0x0F, ServerChatPacket.class);
this.registerIncoming(0x10, ServerMultiBlockChangePacket.class);
this.registerIncoming(0x11, ServerTabCompletePacket.class);
this.registerIncoming(0x12, ServerDeclareCommandsPacket.class);
this.registerIncoming(0x13, ServerConfirmTransactionPacket.class);
this.registerIncoming(0x14, ServerCloseWindowPacket.class);
this.registerIncoming(0x15, ServerWindowItemsPacket.class);
this.registerIncoming(0x16, ServerWindowPropertyPacket.class);
this.registerIncoming(0x17, ServerSetSlotPacket.class);
this.registerIncoming(0x18, ServerSetCooldownPacket.class);
this.registerIncoming(0x19, ServerPluginMessagePacket.class);
this.registerIncoming(0x1A, ServerPlaySoundPacket.class);
this.registerIncoming(0x1B, ServerDisconnectPacket.class);
this.registerIncoming(0x1C, ServerEntityStatusPacket.class);
this.registerIncoming(0x1D, ServerExplosionPacket.class);
this.registerIncoming(0x1E, ServerUnloadChunkPacket.class);
this.registerIncoming(0x1F, ServerNotifyClientPacket.class);
this.registerIncoming(0x20, ServerOpenHorseWindowPacket.class);
this.registerIncoming(0x21, ServerKeepAlivePacket.class);
this.registerIncoming(0x22, ServerChunkDataPacket.class);
this.registerIncoming(0x23, ServerPlayEffectPacket.class);
this.registerIncoming(0x24, ServerSpawnParticlePacket.class);
this.registerIncoming(0x25, ServerUpdateLightPacket.class);
this.registerIncoming(0x26, ServerJoinGamePacket.class);
this.registerIncoming(0x27, ServerMapDataPacket.class);
this.registerIncoming(0x28, ServerTradeListPacket.class);
this.registerIncoming(0x29, ServerEntityPositionPacket.class);
this.registerIncoming(0x2A, ServerEntityPositionRotationPacket.class);
this.registerIncoming(0x2B, ServerEntityRotationPacket.class);
this.registerIncoming(0x2C, ServerEntityMovementPacket.class);
this.registerIncoming(0x2D, ServerVehicleMovePacket.class);
this.registerIncoming(0x2E, ServerOpenBookPacket.class);
this.registerIncoming(0x2F, ServerOpenWindowPacket.class);
this.registerIncoming(0x30, ServerOpenTileEntityEditorPacket.class);
this.registerIncoming(0x31, ServerPreparedCraftingGridPacket.class);
this.registerIncoming(0x32, ServerPlayerAbilitiesPacket.class);
this.registerIncoming(0x33, ServerCombatPacket.class);
this.registerIncoming(0x34, ServerPlayerListEntryPacket.class);
this.registerIncoming(0x35, ServerPlayerFacingPacket.class);
this.registerIncoming(0x36, ServerPlayerPositionRotationPacket.class);
this.registerIncoming(0x37, ServerUnlockRecipesPacket.class);
this.registerIncoming(0x38, ServerEntityDestroyPacket.class);
this.registerIncoming(0x39, ServerEntityRemoveEffectPacket.class);
this.registerIncoming(0x3A, ServerResourcePackSendPacket.class);
this.registerIncoming(0x3B, ServerRespawnPacket.class);
this.registerIncoming(0x3C, ServerEntityHeadLookPacket.class);
this.registerIncoming(0x3D, ServerAdvancementTabPacket.class);
this.registerIncoming(0x3E, ServerWorldBorderPacket.class);
this.registerIncoming(0x3F, ServerSwitchCameraPacket.class);
this.registerIncoming(0x40, ServerPlayerChangeHeldItemPacket.class);
this.registerIncoming(0x41, ServerUpdateViewPositionPacket.class);
this.registerIncoming(0x42, ServerUpdateViewDistancePacket.class);
this.registerIncoming(0x43, ServerSpawnPositionPacket.class);
this.registerIncoming(0x44, ServerDisplayScoreboardPacket.class);
this.registerIncoming(0x45, ServerEntityMetadataPacket.class);
this.registerIncoming(0x46, ServerEntityAttachPacket.class);
this.registerIncoming(0x47, ServerEntityVelocityPacket.class);
this.registerIncoming(0x48, ServerEntityEquipmentPacket.class);
this.registerIncoming(0x49, ServerPlayerSetExperiencePacket.class);
this.registerIncoming(0x4A, ServerPlayerHealthPacket.class);
this.registerIncoming(0x4B, ServerScoreboardObjectivePacket.class);
this.registerIncoming(0x4C, ServerEntitySetPassengersPacket.class);
this.registerIncoming(0x4D, ServerTeamPacket.class);
this.registerIncoming(0x4E, ServerUpdateScorePacket.class);
this.registerIncoming(0x4F, ServerUpdateTimePacket.class);
this.registerIncoming(0x50, ServerTitlePacket.class);
this.registerIncoming(0x51, ServerEntitySoundEffectPacket.class);
this.registerIncoming(0x52, ServerPlayBuiltinSoundPacket.class);
this.registerIncoming(0x53, ServerStopSoundPacket.class);
this.registerIncoming(0x54, ServerPlayerListDataPacket.class);
this.registerIncoming(0x55, ServerNBTResponsePacket.class);
this.registerIncoming(0x56, ServerEntityCollectItemPacket.class);
this.registerIncoming(0x57, ServerEntityTeleportPacket.class);
this.registerIncoming(0x58, ServerAdvancementsPacket.class);
this.registerIncoming(0x59, ServerEntityPropertiesPacket.class);
this.registerIncoming(0x5A, ServerEntityEffectPacket.class);
this.registerIncoming(0x5B, ServerDeclareRecipesPacket.class);
this.registerIncoming(0x5C, ServerDeclareTagsPacket.class);
this.registerIncoming(0x02, ServerSpawnLivingEntityPacket.class);
this.registerIncoming(0x03, ServerSpawnPaintingPacket.class);
this.registerIncoming(0x04, ServerSpawnPlayerPacket.class);
this.registerIncoming(0x05, ServerEntityAnimationPacket.class);
this.registerIncoming(0x06, ServerStatisticsPacket.class);
this.registerIncoming(0x07, ServerPlayerActionAckPacket.class);
this.registerIncoming(0x08, ServerBlockBreakAnimPacket.class);
this.registerIncoming(0x09, ServerUpdateTileEntityPacket.class);
this.registerIncoming(0x0A, ServerBlockValuePacket.class);
this.registerIncoming(0x0B, ServerBlockChangePacket.class);
this.registerIncoming(0x0C, ServerBossBarPacket.class);
this.registerIncoming(0x0D, ServerDifficultyPacket.class);
this.registerIncoming(0x0E, ServerChatPacket.class);
this.registerIncoming(0x1F, ServerMultiBlockChangePacket.class);
this.registerIncoming(0x10, ServerTabCompletePacket.class);
this.registerIncoming(0x11, ServerDeclareCommandsPacket.class);
this.registerIncoming(0x12, ServerConfirmTransactionPacket.class);
this.registerIncoming(0x13, ServerCloseWindowPacket.class);
this.registerIncoming(0x14, ServerWindowItemsPacket.class);
this.registerIncoming(0x15, ServerWindowPropertyPacket.class);
this.registerIncoming(0x16, ServerSetSlotPacket.class);
this.registerIncoming(0x17, ServerSetCooldownPacket.class);
this.registerIncoming(0x18, ServerPluginMessagePacket.class);
this.registerIncoming(0x19, ServerPlaySoundPacket.class);
this.registerIncoming(0x1A, ServerDisconnectPacket.class);
this.registerIncoming(0x1B, ServerEntityStatusPacket.class);
this.registerIncoming(0x1C, ServerExplosionPacket.class);
this.registerIncoming(0x1D, ServerUnloadChunkPacket.class);
this.registerIncoming(0x1E, ServerNotifyClientPacket.class);
this.registerIncoming(0x2F, ServerOpenHorseWindowPacket.class);
this.registerIncoming(0x20, ServerKeepAlivePacket.class);
this.registerIncoming(0x21, ServerChunkDataPacket.class);
this.registerIncoming(0x22, ServerPlayEffectPacket.class);
this.registerIncoming(0x23, ServerSpawnParticlePacket.class);
this.registerIncoming(0x24, ServerUpdateLightPacket.class);
this.registerIncoming(0x25, ServerJoinGamePacket.class);
this.registerIncoming(0x26, ServerMapDataPacket.class);
this.registerIncoming(0x27, ServerTradeListPacket.class);
this.registerIncoming(0x28, ServerEntityPositionPacket.class);
this.registerIncoming(0x29, ServerEntityPositionRotationPacket.class);
this.registerIncoming(0x2A, ServerEntityRotationPacket.class);
this.registerIncoming(0x2B, ServerEntityMovementPacket.class);
this.registerIncoming(0x2C, ServerVehicleMovePacket.class);
this.registerIncoming(0x2D, ServerOpenBookPacket.class);
this.registerIncoming(0x2E, ServerOpenWindowPacket.class);
this.registerIncoming(0x3F, ServerOpenTileEntityEditorPacket.class);
this.registerIncoming(0x30, ServerPreparedCraftingGridPacket.class);
this.registerIncoming(0x31, ServerPlayerAbilitiesPacket.class);
this.registerIncoming(0x32, ServerCombatPacket.class);
this.registerIncoming(0x33, ServerPlayerListEntryPacket.class);
this.registerIncoming(0x34, ServerPlayerFacingPacket.class);
this.registerIncoming(0x35, ServerPlayerPositionRotationPacket.class);
this.registerIncoming(0x36, ServerUnlockRecipesPacket.class);
this.registerIncoming(0x37, ServerEntityDestroyPacket.class);
this.registerIncoming(0x38, ServerEntityRemoveEffectPacket.class);
this.registerIncoming(0x39, ServerResourcePackSendPacket.class);
this.registerIncoming(0x3A, ServerRespawnPacket.class);
this.registerIncoming(0x3B, ServerEntityHeadLookPacket.class);
this.registerIncoming(0x3C, ServerAdvancementTabPacket.class);
this.registerIncoming(0x3D, ServerWorldBorderPacket.class);
this.registerIncoming(0x3E, ServerSwitchCameraPacket.class);
this.registerIncoming(0x4F, ServerPlayerChangeHeldItemPacket.class);
this.registerIncoming(0x40, ServerUpdateViewPositionPacket.class);
this.registerIncoming(0x41, ServerUpdateViewDistancePacket.class);
this.registerIncoming(0x42, ServerSpawnPositionPacket.class);
this.registerIncoming(0x43, ServerDisplayScoreboardPacket.class);
this.registerIncoming(0x44, ServerEntityMetadataPacket.class);
this.registerIncoming(0x45, ServerEntityAttachPacket.class);
this.registerIncoming(0x46, ServerEntityVelocityPacket.class);
this.registerIncoming(0x47, ServerEntityEquipmentPacket.class);
this.registerIncoming(0x48, ServerPlayerSetExperiencePacket.class);
this.registerIncoming(0x49, ServerPlayerHealthPacket.class);
this.registerIncoming(0x4A, ServerScoreboardObjectivePacket.class);
this.registerIncoming(0x4B, ServerEntitySetPassengersPacket.class);
this.registerIncoming(0x4C, ServerTeamPacket.class);
this.registerIncoming(0x4D, ServerUpdateScorePacket.class);
this.registerIncoming(0x4E, ServerUpdateTimePacket.class);
this.registerIncoming(0x5F, ServerTitlePacket.class);
this.registerIncoming(0x50, ServerEntitySoundEffectPacket.class);
this.registerIncoming(0x51, ServerPlayBuiltinSoundPacket.class);
this.registerIncoming(0x52, ServerStopSoundPacket.class);
this.registerIncoming(0x53, ServerPlayerListDataPacket.class);
this.registerIncoming(0x54, ServerNBTResponsePacket.class);
this.registerIncoming(0x55, ServerEntityCollectItemPacket.class);
this.registerIncoming(0x56, ServerEntityTeleportPacket.class);
this.registerIncoming(0x57, ServerAdvancementsPacket.class);
this.registerIncoming(0x58, ServerEntityPropertiesPacket.class);
this.registerIncoming(0x59, ServerEntityEffectPacket.class);
this.registerIncoming(0x5A, ServerDeclareRecipesPacket.class);
this.registerIncoming(0x5B, ServerDeclareTagsPacket.class);
this.registerOutgoing(0x00, ClientTeleportConfirmPacket.class);
this.registerOutgoing(0x01, ClientBlockNBTRequestPacket.class);
@ -568,96 +567,95 @@ public class MinecraftProtocol extends PacketProtocol {
this.registerOutgoing(0x00, ServerSpawnEntityPacket.class);
this.registerOutgoing(0x01, ServerSpawnExpOrbPacket.class);
this.registerOutgoing(0x02, ServerSpawnWeatherEntityPacket.class);
this.registerOutgoing(0x03, ServerSpawnLivingEntityPacket.class);
this.registerOutgoing(0x04, ServerSpawnPaintingPacket.class);
this.registerOutgoing(0x05, ServerSpawnPlayerPacket.class);
this.registerOutgoing(0x06, ServerEntityAnimationPacket.class);
this.registerOutgoing(0x07, ServerStatisticsPacket.class);
this.registerOutgoing(0x08, ServerPlayerActionAckPacket.class);
this.registerOutgoing(0x09, ServerBlockBreakAnimPacket.class);
this.registerOutgoing(0x0A, ServerUpdateTileEntityPacket.class);
this.registerOutgoing(0x0B, ServerBlockValuePacket.class);
this.registerOutgoing(0x0C, ServerBlockChangePacket.class);
this.registerOutgoing(0x0D, ServerBossBarPacket.class);
this.registerOutgoing(0x0E, ServerDifficultyPacket.class);
this.registerOutgoing(0x0F, ServerChatPacket.class);
this.registerOutgoing(0x10, ServerMultiBlockChangePacket.class);
this.registerOutgoing(0x11, ServerTabCompletePacket.class);
this.registerOutgoing(0x12, ServerDeclareCommandsPacket.class);
this.registerOutgoing(0x13, ServerConfirmTransactionPacket.class);
this.registerOutgoing(0x14, ServerCloseWindowPacket.class);
this.registerOutgoing(0x15, ServerWindowItemsPacket.class);
this.registerOutgoing(0x16, ServerWindowPropertyPacket.class);
this.registerOutgoing(0x17, ServerSetSlotPacket.class);
this.registerOutgoing(0x18, ServerSetCooldownPacket.class);
this.registerOutgoing(0x19, ServerPluginMessagePacket.class);
this.registerOutgoing(0x1A, ServerPlaySoundPacket.class);
this.registerOutgoing(0x1B, ServerDisconnectPacket.class);
this.registerOutgoing(0x1C, ServerEntityStatusPacket.class);
this.registerOutgoing(0x1D, ServerExplosionPacket.class);
this.registerOutgoing(0x1E, ServerUnloadChunkPacket.class);
this.registerOutgoing(0x1F, ServerNotifyClientPacket.class);
this.registerOutgoing(0x20, ServerOpenHorseWindowPacket.class);
this.registerOutgoing(0x21, ServerKeepAlivePacket.class);
this.registerOutgoing(0x22, ServerChunkDataPacket.class);
this.registerOutgoing(0x23, ServerPlayEffectPacket.class);
this.registerOutgoing(0x24, ServerSpawnParticlePacket.class);
this.registerOutgoing(0x25, ServerUpdateLightPacket.class);
this.registerOutgoing(0x26, ServerJoinGamePacket.class);
this.registerOutgoing(0x27, ServerMapDataPacket.class);
this.registerOutgoing(0x28, ServerTradeListPacket.class);
this.registerOutgoing(0x29, ServerEntityPositionPacket.class);
this.registerOutgoing(0x2A, ServerEntityPositionRotationPacket.class);
this.registerOutgoing(0x2B, ServerEntityRotationPacket.class);
this.registerOutgoing(0x2C, ServerEntityMovementPacket.class);
this.registerOutgoing(0x2D, ServerVehicleMovePacket.class);
this.registerOutgoing(0x2E, ServerOpenBookPacket.class);
this.registerOutgoing(0x2F, ServerOpenWindowPacket.class);
this.registerOutgoing(0x30, ServerOpenTileEntityEditorPacket.class);
this.registerOutgoing(0x31, ServerPreparedCraftingGridPacket.class);
this.registerOutgoing(0x32, ServerPlayerAbilitiesPacket.class);
this.registerOutgoing(0x33, ServerCombatPacket.class);
this.registerOutgoing(0x34, ServerPlayerListEntryPacket.class);
this.registerOutgoing(0x35, ServerPlayerFacingPacket.class);
this.registerOutgoing(0x36, ServerPlayerPositionRotationPacket.class);
this.registerOutgoing(0x37, ServerUnlockRecipesPacket.class);
this.registerOutgoing(0x38, ServerEntityDestroyPacket.class);
this.registerOutgoing(0x39, ServerEntityRemoveEffectPacket.class);
this.registerOutgoing(0x3A, ServerResourcePackSendPacket.class);
this.registerOutgoing(0x3B, ServerRespawnPacket.class);
this.registerOutgoing(0x3C, ServerEntityHeadLookPacket.class);
this.registerOutgoing(0x3D, ServerAdvancementTabPacket.class);
this.registerOutgoing(0x3E, ServerWorldBorderPacket.class);
this.registerOutgoing(0x3F, ServerSwitchCameraPacket.class);
this.registerOutgoing(0x40, ServerPlayerChangeHeldItemPacket.class);
this.registerOutgoing(0x41, ServerUpdateViewPositionPacket.class);
this.registerOutgoing(0x42, ServerUpdateViewDistancePacket.class);
this.registerOutgoing(0x43, ServerSpawnPositionPacket.class);
this.registerOutgoing(0x44, ServerDisplayScoreboardPacket.class);
this.registerOutgoing(0x45, ServerEntityMetadataPacket.class);
this.registerOutgoing(0x46, ServerEntityAttachPacket.class);
this.registerOutgoing(0x47, ServerEntityVelocityPacket.class);
this.registerOutgoing(0x48, ServerEntityEquipmentPacket.class);
this.registerOutgoing(0x49, ServerPlayerSetExperiencePacket.class);
this.registerOutgoing(0x4A, ServerPlayerHealthPacket.class);
this.registerOutgoing(0x4B, ServerScoreboardObjectivePacket.class);
this.registerOutgoing(0x4C, ServerEntitySetPassengersPacket.class);
this.registerOutgoing(0x4D, ServerTeamPacket.class);
this.registerOutgoing(0x4E, ServerUpdateScorePacket.class);
this.registerOutgoing(0x4F, ServerUpdateTimePacket.class);
this.registerOutgoing(0x50, ServerTitlePacket.class);
this.registerOutgoing(0x51, ServerEntitySoundEffectPacket.class);
this.registerOutgoing(0x52, ServerPlayBuiltinSoundPacket.class);
this.registerOutgoing(0x53, ServerStopSoundPacket.class);
this.registerOutgoing(0x54, ServerPlayerListDataPacket.class);
this.registerOutgoing(0x55, ServerNBTResponsePacket.class);
this.registerOutgoing(0x56, ServerEntityCollectItemPacket.class);
this.registerOutgoing(0x57, ServerEntityTeleportPacket.class);
this.registerOutgoing(0x58, ServerAdvancementsPacket.class);
this.registerOutgoing(0x59, ServerEntityPropertiesPacket.class);
this.registerOutgoing(0x5A, ServerEntityEffectPacket.class);
this.registerOutgoing(0x5B, ServerDeclareRecipesPacket.class);
this.registerOutgoing(0x5C, ServerDeclareTagsPacket.class);
this.registerOutgoing(0x03, ServerSpawnPaintingPacket.class);
this.registerOutgoing(0x04, ServerSpawnPlayerPacket.class);
this.registerOutgoing(0x05, ServerEntityAnimationPacket.class);
this.registerOutgoing(0x06, ServerStatisticsPacket.class);
this.registerOutgoing(0x07, ServerPlayerActionAckPacket.class);
this.registerOutgoing(0x08, ServerBlockBreakAnimPacket.class);
this.registerOutgoing(0x09, ServerUpdateTileEntityPacket.class);
this.registerOutgoing(0x0A, ServerBlockValuePacket.class);
this.registerOutgoing(0x0B, ServerBlockChangePacket.class);
this.registerOutgoing(0x0C, ServerBossBarPacket.class);
this.registerOutgoing(0x0D, ServerDifficultyPacket.class);
this.registerOutgoing(0x0E, ServerChatPacket.class);
this.registerOutgoing(0x0F, ServerMultiBlockChangePacket.class);
this.registerOutgoing(0x10, ServerTabCompletePacket.class);
this.registerOutgoing(0x11, ServerDeclareCommandsPacket.class);
this.registerOutgoing(0x12, ServerConfirmTransactionPacket.class);
this.registerOutgoing(0x13, ServerCloseWindowPacket.class);
this.registerOutgoing(0x14, ServerWindowItemsPacket.class);
this.registerOutgoing(0x15, ServerWindowPropertyPacket.class);
this.registerOutgoing(0x16, ServerSetSlotPacket.class);
this.registerOutgoing(0x17, ServerSetCooldownPacket.class);
this.registerOutgoing(0x18, ServerPluginMessagePacket.class);
this.registerOutgoing(0x19, ServerPlaySoundPacket.class);
this.registerOutgoing(0x1A, ServerDisconnectPacket.class);
this.registerOutgoing(0x1B, ServerEntityStatusPacket.class);
this.registerOutgoing(0x1C, ServerExplosionPacket.class);
this.registerOutgoing(0x1D, ServerUnloadChunkPacket.class);
this.registerOutgoing(0x1E, ServerNotifyClientPacket.class);
this.registerOutgoing(0x2F, ServerOpenHorseWindowPacket.class);
this.registerOutgoing(0x20, ServerKeepAlivePacket.class);
this.registerOutgoing(0x21, ServerChunkDataPacket.class);
this.registerOutgoing(0x22, ServerPlayEffectPacket.class);
this.registerOutgoing(0x23, ServerSpawnParticlePacket.class);
this.registerOutgoing(0x24, ServerUpdateLightPacket.class);
this.registerOutgoing(0x25, ServerJoinGamePacket.class);
this.registerOutgoing(0x26, ServerMapDataPacket.class);
this.registerOutgoing(0x27, ServerTradeListPacket.class);
this.registerOutgoing(0x28, ServerEntityPositionPacket.class);
this.registerOutgoing(0x29, ServerEntityPositionRotationPacket.class);
this.registerOutgoing(0x2A, ServerEntityRotationPacket.class);
this.registerOutgoing(0x2B, ServerEntityMovementPacket.class);
this.registerOutgoing(0x2C, ServerVehicleMovePacket.class);
this.registerOutgoing(0x2D, ServerOpenBookPacket.class);
this.registerOutgoing(0x2E, ServerOpenWindowPacket.class);
this.registerOutgoing(0x3F, ServerOpenTileEntityEditorPacket.class);
this.registerOutgoing(0x30, ServerPreparedCraftingGridPacket.class);
this.registerOutgoing(0x31, ServerPlayerAbilitiesPacket.class);
this.registerOutgoing(0x32, ServerCombatPacket.class);
this.registerOutgoing(0x33, ServerPlayerListEntryPacket.class);
this.registerOutgoing(0x34, ServerPlayerFacingPacket.class);
this.registerOutgoing(0x35, ServerPlayerPositionRotationPacket.class);
this.registerOutgoing(0x36, ServerUnlockRecipesPacket.class);
this.registerOutgoing(0x37, ServerEntityDestroyPacket.class);
this.registerOutgoing(0x38, ServerEntityRemoveEffectPacket.class);
this.registerOutgoing(0x39, ServerResourcePackSendPacket.class);
this.registerOutgoing(0x3A, ServerRespawnPacket.class);
this.registerOutgoing(0x3B, ServerEntityHeadLookPacket.class);
this.registerOutgoing(0x3C, ServerAdvancementTabPacket.class);
this.registerOutgoing(0x3D, ServerWorldBorderPacket.class);
this.registerOutgoing(0x3E, ServerSwitchCameraPacket.class);
this.registerOutgoing(0x4F, ServerPlayerChangeHeldItemPacket.class);
this.registerOutgoing(0x40, ServerUpdateViewPositionPacket.class);
this.registerOutgoing(0x41, ServerUpdateViewDistancePacket.class);
this.registerOutgoing(0x42, ServerSpawnPositionPacket.class);
this.registerOutgoing(0x43, ServerDisplayScoreboardPacket.class);
this.registerOutgoing(0x44, ServerEntityMetadataPacket.class);
this.registerOutgoing(0x45, ServerEntityAttachPacket.class);
this.registerOutgoing(0x46, ServerEntityVelocityPacket.class);
this.registerOutgoing(0x47, ServerEntityEquipmentPacket.class);
this.registerOutgoing(0x48, ServerPlayerSetExperiencePacket.class);
this.registerOutgoing(0x49, ServerPlayerHealthPacket.class);
this.registerOutgoing(0x4A, ServerScoreboardObjectivePacket.class);
this.registerOutgoing(0x4B, ServerEntitySetPassengersPacket.class);
this.registerOutgoing(0x4C, ServerTeamPacket.class);
this.registerOutgoing(0x4D, ServerUpdateScorePacket.class);
this.registerOutgoing(0x4E, ServerUpdateTimePacket.class);
this.registerOutgoing(0x4F, ServerTitlePacket.class);
this.registerOutgoing(0x50, ServerEntitySoundEffectPacket.class);
this.registerOutgoing(0x51, ServerPlayBuiltinSoundPacket.class);
this.registerOutgoing(0x52, ServerStopSoundPacket.class);
this.registerOutgoing(0x53, ServerPlayerListDataPacket.class);
this.registerOutgoing(0x54, ServerNBTResponsePacket.class);
this.registerOutgoing(0x55, ServerEntityCollectItemPacket.class);
this.registerOutgoing(0x56, ServerEntityTeleportPacket.class);
this.registerOutgoing(0x57, ServerAdvancementsPacket.class);
this.registerOutgoing(0x58, ServerEntityPropertiesPacket.class);
this.registerOutgoing(0x59, ServerEntityEffectPacket.class);
this.registerOutgoing(0x5A, ServerDeclareRecipesPacket.class);
this.registerOutgoing(0x5B, ServerDeclareTagsPacket.class);
}
private void initClientStatus(Session session) {

View file

@ -10,16 +10,17 @@ import java.util.Arrays;
public class Column {
private final int x;
private final int z;
private final boolean ignoreOldData;
private final @NonNull Chunk[] chunks;
private final @NonNull CompoundTag[] tileEntities;
private final @NonNull CompoundTag heightMaps;
private final int[] biomeData;
public Column(int x, int z, @NonNull Chunk[] chunks, @NonNull CompoundTag[] tileEntities, @NonNull CompoundTag heightMaps) {
this(x, z, chunks, tileEntities, heightMaps, null);
public Column(int x, int z, boolean ignoreOldData, @NonNull Chunk[] chunks, @NonNull CompoundTag[] tileEntities, @NonNull CompoundTag heightMaps) {
this(x, z, ignoreOldData, chunks, tileEntities, heightMaps, null);
}
public Column(int x, int z, @NonNull Chunk[] chunks, @NonNull CompoundTag[] tileEntities, @NonNull CompoundTag heightMaps, int[] biomeData) {
public Column(int x, int z, boolean ignoreOldData, @NonNull Chunk[] chunks, @NonNull CompoundTag[] tileEntities, @NonNull CompoundTag heightMaps, int[] biomeData) {
if(chunks.length != 16) {
throw new IllegalArgumentException("Chunk array length must be 16.");
}
@ -30,6 +31,7 @@ public class Column {
this.x = x;
this.z = z;
this.ignoreOldData = ignoreOldData;
this.chunks = Arrays.copyOf(chunks, chunks.length);
this.biomeData = biomeData != null ? Arrays.copyOf(biomeData, biomeData.length) : null;
this.tileEntities = tileEntities != null ? tileEntities : new CompoundTag[0];

View file

@ -24,14 +24,14 @@ public class FlexibleStorage {
char valuesPerLong = (char) (64 / bitsPerEntry);
int expectedLength = (4096 + valuesPerLong - 1) / valuesPerLong;
if (data.length != expectedLength) {
throw new IllegalArgumentException("Got " + data.length + " as the chunk data length, but was expecting " + expectedLength);
this.bitsPerEntry = bitsPerEntry;
this.data = padArray(bitsPerEntry, Arrays.copyOf(data, data.length), valuesPerLong, expectedLength);
if (this.data.length != expectedLength) {
throw new IllegalArgumentException("Got " + this.data.length + " as the chunk data length, but was expecting " + expectedLength);
}
this.bitsPerEntry = bitsPerEntry;
this.data = Arrays.copyOf(data, data.length);
this.size = this.data.length * 64 / this.bitsPerEntry;
this.size = data.length * 64 / this.bitsPerEntry;
this.maxEntryValue = (1L << this.bitsPerEntry) - 1;
}
@ -86,4 +86,49 @@ public class FlexibleStorage {
this.data[endIndex] = this.data[endIndex] >>> endBitSubIndex << endBitSubIndex | ((long) value & this.maxEntryValue) >> endBitSubIndex;
}
}
private static final int[] MAGIC_CHUNK_VALUES = {
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
0, 5 };
private static long[] padArray(int bitsPerEntry, long[] oldData, char valuesPerLong, int size) {
int magicIndex = (valuesPerLong - 1) * 3;
int divideShift = MAGIC_CHUNK_VALUES[magicIndex + 2];
long maxEntries = (1L << bitsPerEntry) - 1;
long[] data = new long[size];
for (int index = 0; index < 4096; index++) {
int startIndex = (index * bitsPerEntry) / 64;
int endIndex = ((index + 1) * bitsPerEntry - 1) / 64;
int startBitSubIndex = (index * bitsPerEntry) % 64;
int value;
if (startIndex != endIndex) {
value = (int) ((oldData[startIndex] >>> startBitSubIndex | oldData[endIndex] << (64 - startBitSubIndex)) & maxEntries);
} else {
value = (int) (oldData[startIndex] >>> startBitSubIndex & maxEntries);
}
int cellIndex = (int) (index * ((long) MAGIC_CHUNK_VALUES[magicIndex]) & 0xffffffffL + ((long) MAGIC_CHUNK_VALUES[magicIndex + 1]) & 0xffffffffL >> 32L >> divideShift);
int bitIndex = (index - cellIndex * valuesPerLong) * bitsPerEntry;
data[cellIndex] = data[cellIndex] & ~(maxEntries << bitIndex) | (value & maxEntries) << bitIndex;
}
return data;
}
}

View file

@ -25,8 +25,6 @@ public class ClientPlayerAbilitiesPacket implements Packet {
private boolean canFly;
private boolean flying;
private boolean creative;
private float flySpeed;
private float walkSpeed;
@Override
public void read(NetInput in) throws IOException {
@ -35,9 +33,6 @@ public class ClientPlayerAbilitiesPacket implements Packet {
this.canFly = (flags & FLAG_CAN_FLY) > 0;
this.flying = (flags & FLAG_FLYING) > 0;
this.creative = (flags & FLAG_CREATIVE) > 0;
this.flySpeed = in.readFloat();
this.walkSpeed = in.readFloat();
}
@Override
@ -60,9 +55,6 @@ public class ClientPlayerAbilitiesPacket implements Packet {
}
out.writeByte(flags);
out.writeFloat(this.flySpeed);
out.writeFloat(this.walkSpeed);
}
@Override

View file

@ -27,13 +27,14 @@ public class ClientPlayerInteractEntityPacket implements Packet {
private float targetY;
private float targetZ;
private @NonNull Hand hand;
private boolean unknown;
public ClientPlayerInteractEntityPacket(int entityId, InteractAction action) {
this(entityId, action, Hand.MAIN_HAND);
public ClientPlayerInteractEntityPacket(int entityId, InteractAction action, boolean unknown) {
this(entityId, action, Hand.MAIN_HAND, unknown);
}
public ClientPlayerInteractEntityPacket(int entityId, InteractAction action, Hand hand) {
this(entityId, action, 0, 0, 0, hand);
public ClientPlayerInteractEntityPacket(int entityId, InteractAction action, Hand hand, boolean unknown) {
this(entityId, action, 0, 0, 0, hand, unknown);
}
@Override
@ -49,6 +50,7 @@ public class ClientPlayerInteractEntityPacket implements Packet {
if(this.action == InteractAction.INTERACT || this.action == InteractAction.INTERACT_AT) {
this.hand = MagicValues.key(Hand.class, in.readVarInt());
}
this.unknown = in.readBoolean();
}
@Override
@ -64,6 +66,7 @@ public class ClientPlayerInteractEntityPacket implements Packet {
if(this.action == InteractAction.INTERACT || this.action == InteractAction.INTERACT_AT) {
out.writeVarInt(MagicValues.value(Integer.class, this.hand));
}
out.writeBoolean(this.unknown);
}
@Override

View file

@ -27,6 +27,7 @@ public class ServerJoinGamePacket implements Packet {
private int entityId;
private boolean hardcore;
private @NonNull GameMode gameMode;
private @NonNull GameMode gameMode2;
private int worldCount;
private String[] worldNames;
private @NonNull CompoundTag dimensionCodec;
@ -47,6 +48,7 @@ public class ServerJoinGamePacket implements Packet {
int gameMode = in.readUnsignedByte();
this.hardcore = (gameMode & GAMEMODE_FLAG_HARDCORE) != 0;
this.gameMode = MagicValues.key(GameMode.class, gameMode & GAMEMODE_MASK);
this.gameMode2 = MagicValues.key(GameMode.class, in.readUnsignedByte());
this.worldCount = in.readVarInt();
for (int i = 0; i < this.worldCount; i++) {
in.readString();
@ -73,6 +75,7 @@ public class ServerJoinGamePacket implements Packet {
}
out.writeByte(gameMode);
out.writeByte(MagicValues.value(Integer.class, this.gameMode2));
out.writeVarInt(this.worldCount);
for (String worldName : this.worldNames) {
out.writeString(worldName);

View file

@ -23,6 +23,7 @@ public class ServerRespawnPacket implements Packet {
private String worldName;
private long hashedSeed;
private @NonNull GameMode gamemode;
private @NonNull GameMode gamemode2;
private boolean debug;
private boolean flat;
private boolean copyMetadata;
@ -33,6 +34,7 @@ public class ServerRespawnPacket implements Packet {
this.worldName = in.readString();
this.hashedSeed = in.readLong();
this.gamemode = MagicValues.key(GameMode.class, in.readUnsignedByte());
this.gamemode2 = MagicValues.key(GameMode.class, in.readUnsignedByte());
this.debug = in.readBoolean();
this.flat = in.readBoolean();
this.copyMetadata = in.readBoolean();
@ -44,6 +46,7 @@ public class ServerRespawnPacket implements Packet {
out.writeString(this.worldName);
out.writeLong(this.hashedSeed);
out.writeByte(MagicValues.value(Integer.class, this.gamemode));
out.writeByte(MagicValues.value(Integer.class, this.gamemode2));
out.writeBoolean(this.debug);
out.writeBoolean(this.flat);
out.writeBoolean(this.copyMetadata);

View file

@ -32,6 +32,7 @@ public class ServerChunkDataPacket implements Packet {
int x = in.readInt();
int z = in.readInt();
boolean fullChunk = in.readBoolean();
boolean ignoreOldData = in.readBoolean();
int chunkMask = in.readVarInt();
CompoundTag heightMaps = NBT.read(in);
int[] biomeData = fullChunk ? in.readInts(1024) : null;
@ -49,7 +50,7 @@ public class ServerChunkDataPacket implements Packet {
}
}
this.column = new Column(x, z, chunks, tileEntities, heightMaps, biomeData);
this.column = new Column(x, z, ignoreOldData, chunks, tileEntities, heightMaps, biomeData);
}
@Override
@ -72,6 +73,7 @@ public class ServerChunkDataPacket implements Packet {
out.writeInt(this.column.getX());
out.writeInt(this.column.getZ());
out.writeBoolean(fullChunk);
out.writeBoolean(this.column.isIgnoreOldData());
out.writeVarInt(mask);
NBT.write(out, this.column.getHeightMaps());
if (fullChunk) {

View file

@ -23,10 +23,11 @@ public class ServerUpdateLightPacket implements Packet {
private int x;
private int z;
private boolean unknown; // TODO: Find what this value is
private @NonNull NibbleArray3d[] skyLight;
private @NonNull NibbleArray3d[] blockLight;
public ServerUpdateLightPacket(int x, int z, @NonNull NibbleArray3d[] skyLight, @NonNull NibbleArray3d[] blockLight) {
public ServerUpdateLightPacket(int x, int z, boolean unknown, @NonNull NibbleArray3d[] skyLight, @NonNull NibbleArray3d[] blockLight) {
if(skyLight.length != NUM_ENTRIES) {
throw new IllegalArgumentException("skyLight must have exactly " + NUM_ENTRIES + " entries (null entries are permitted)");
}
@ -37,6 +38,7 @@ public class ServerUpdateLightPacket implements Packet {
this.x = x;
this.z = z;
this.unknown = unknown;
this.skyLight = Arrays.copyOf(skyLight, skyLight.length);
this.blockLight = Arrays.copyOf(blockLight, blockLight.length);
}
@ -45,6 +47,7 @@ public class ServerUpdateLightPacket implements Packet {
public void read(NetInput in) throws IOException {
this.x = in.readVarInt();
this.z = in.readVarInt();
this.unknown = in.readBoolean();
int skyLightMask = in.readVarInt();
int blockLightMask = in.readVarInt();
@ -78,6 +81,7 @@ public class ServerUpdateLightPacket implements Packet {
public void write(NetOutput out) throws IOException {
out.writeVarInt(this.x);
out.writeVarInt(this.z);
out.writeBoolean(this.unknown);
int skyLightMask = 0;
int blockLightMask = 0;

View file

@ -9,7 +9,10 @@ import com.github.steveice10.mc.protocol.data.status.VersionInfo;
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoHandler;
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.FloatTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.packetlib.Client;
@ -47,7 +50,7 @@ public class MinecraftProtocolTest {
new TextMessage("Hello world!"),
null
);
private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "minecraft:overworld", "minecraft:world", 100, 0, 16, false, false, false, false);
private static final ServerJoinGamePacket JOIN_GAME_PACKET = new ServerJoinGamePacket(0, false, GameMode.SURVIVAL, GameMode.SURVIVAL, 1, new String[]{"minecraft:world"}, getDimensionTag(), "minecraft:overworld", "minecraft:world", 100, 0, 16, false, false, false, false);
private static Server server;
@ -147,10 +150,26 @@ public class MinecraftProtocolTest {
CompoundTag tag = new CompoundTag("");
ListTag dimensionTag = new ListTag("dimension");
CompoundTag overworldTag = new CompoundTag("");
overworldTag.put(new StringTag("key", "minecraft:overworld"));
overworldTag.put(new StringTag("element", "minecraft:overworld"));
overworldTag.put(new StringTag("name", "minecraft:overworld"));
overworldTag.put(new ByteTag("natural", (byte) 1));
overworldTag.put(new FloatTag("ambient_light", 0f));
overworldTag.put(new ByteTag("shrunk", (byte) 0));
overworldTag.put(new ByteTag("ultrawarm", (byte) 0));
overworldTag.put(new ByteTag("has_ceiling", (byte) 0));
overworldTag.put(new ByteTag("has_skylight", (byte) 1));
overworldTag.put(new ByteTag("piglin_safe", (byte) 0));
overworldTag.put(new ByteTag("natural", (byte) 1));
overworldTag.put(new FloatTag("ambient_light", 0));
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 ByteTag("has_raids", (byte) 1));
overworldTag.put(new IntTag("logical_height", 256));
overworldTag.put(new ByteTag("shrunk", (byte) 0));
overworldTag.put(new ByteTag("ultrawarm", (byte) 0));
dimensionTag.add(overworldTag);
tag.put(tag);
overworldTag.put(tag);
return tag;
}
}

View file

@ -15,13 +15,13 @@ public class ServerChunkDataPacketTest extends PacketTest {
this.setPackets(
new ServerChunkDataPacket(
new Column(0, 0, new Chunk[] {
new Column(0, 0, false, new Chunk[] {
null, null, null, null, null, null, null, chunk,
null, chunk, null, null, null, chunk, null, null
}, new CompoundTag[0], new CompoundTag("HeightMaps"))
),
new ServerChunkDataPacket(
new Column(1, 1, new Chunk[] {
new Column(1, 1, false, new Chunk[] {
chunk, chunk, chunk, chunk, chunk, chunk, chunk, chunk,
chunk, chunk, chunk, chunk, chunk, chunk, chunk, chunk
}, new CompoundTag[] {