mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
commit
d4e40375e9
26 changed files with 1199 additions and 132 deletions
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.steveice10</groupId>
|
||||
<artifactId>mcprotocollib</artifactId>
|
||||
<version>1.11.2-3-SNAPSHOT</version>
|
||||
<version>1.12-1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MCProtocolLib</name>
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.github.steveice10.mc.protocol;
|
|||
|
||||
public class MinecraftConstants {
|
||||
// General Constants
|
||||
public static final String GAME_VERSION = "1.11.2";
|
||||
public static final int PROTOCOL_VERSION = 316;
|
||||
public static final String GAME_VERSION = "1.12";
|
||||
public static final int PROTOCOL_VERSION = 335;
|
||||
|
||||
// General Key Constants
|
||||
public static final String PROFILE_KEY = "profile";
|
||||
|
|
|
@ -19,10 +19,13 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlaye
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientAdvancementTabPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCraftingBookDataPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientEnchantItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientPrepareCraftingGridPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientWindowActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSpectatePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSteerBoatPacket;
|
||||
|
@ -30,6 +33,8 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSteerV
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientUpdateSignPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerAdvancementTabPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerAdvancementsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerBossBarPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerCombatPacket;
|
||||
|
@ -47,6 +52,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.ServerStatisticsPa
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerSwitchCameraPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerTabCompletePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerTitlePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerUnlockRecipesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityAnimationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityAttachPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityCollectItemPacket;
|
||||
|
@ -351,10 +357,10 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerIncoming(0x22, ServerSpawnParticlePacket.class);
|
||||
this.registerIncoming(0x23, ServerJoinGamePacket.class);
|
||||
this.registerIncoming(0x24, ServerMapDataPacket.class);
|
||||
this.registerIncoming(0x25, ServerEntityPositionPacket.class);
|
||||
this.registerIncoming(0x26, ServerEntityPositionRotationPacket.class);
|
||||
this.registerIncoming(0x27, ServerEntityRotationPacket.class);
|
||||
this.registerIncoming(0x28, ServerEntityMovementPacket.class);
|
||||
this.registerIncoming(0x25, ServerEntityMovementPacket.class);
|
||||
this.registerIncoming(0x26, ServerEntityPositionPacket.class);
|
||||
this.registerIncoming(0x27, ServerEntityPositionRotationPacket.class);
|
||||
this.registerIncoming(0x28, ServerEntityRotationPacket.class);
|
||||
this.registerIncoming(0x29, ServerVehicleMovePacket.class);
|
||||
this.registerIncoming(0x2A, ServerOpenTileEntityEditorPacket.class);
|
||||
this.registerIncoming(0x2B, ServerPlayerAbilitiesPacket.class);
|
||||
|
@ -362,98 +368,107 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerIncoming(0x2D, ServerPlayerListEntryPacket.class);
|
||||
this.registerIncoming(0x2E, ServerPlayerPositionRotationPacket.class);
|
||||
this.registerIncoming(0x2F, ServerPlayerUseBedPacket.class);
|
||||
this.registerIncoming(0x30, ServerEntityDestroyPacket.class);
|
||||
this.registerIncoming(0x31, ServerEntityRemoveEffectPacket.class);
|
||||
this.registerIncoming(0x32, ServerResourcePackSendPacket.class);
|
||||
this.registerIncoming(0x33, ServerRespawnPacket.class);
|
||||
this.registerIncoming(0x34, ServerEntityHeadLookPacket.class);
|
||||
this.registerIncoming(0x35, ServerWorldBorderPacket.class);
|
||||
this.registerIncoming(0x36, ServerSwitchCameraPacket.class);
|
||||
this.registerIncoming(0x37, ServerPlayerChangeHeldItemPacket.class);
|
||||
this.registerIncoming(0x38, ServerDisplayScoreboardPacket.class);
|
||||
this.registerIncoming(0x39, ServerEntityMetadataPacket.class);
|
||||
this.registerIncoming(0x3A, ServerEntityAttachPacket.class);
|
||||
this.registerIncoming(0x3B, ServerEntityVelocityPacket.class);
|
||||
this.registerIncoming(0x3C, ServerEntityEquipmentPacket.class);
|
||||
this.registerIncoming(0x3D, ServerPlayerSetExperiencePacket.class);
|
||||
this.registerIncoming(0x3E, ServerPlayerHealthPacket.class);
|
||||
this.registerIncoming(0x3F, ServerScoreboardObjectivePacket.class);
|
||||
this.registerIncoming(0x40, ServerEntitySetPassengersPacket.class);
|
||||
this.registerIncoming(0x41, ServerTeamPacket.class);
|
||||
this.registerIncoming(0x42, ServerUpdateScorePacket.class);
|
||||
this.registerIncoming(0x43, ServerSpawnPositionPacket.class);
|
||||
this.registerIncoming(0x44, ServerUpdateTimePacket.class);
|
||||
this.registerIncoming(0x45, ServerTitlePacket.class);
|
||||
this.registerIncoming(0x46, ServerPlayBuiltinSoundPacket.class);
|
||||
this.registerIncoming(0x47, ServerPlayerListDataPacket.class);
|
||||
this.registerIncoming(0x48, ServerEntityCollectItemPacket.class);
|
||||
this.registerIncoming(0x49, ServerEntityTeleportPacket.class);
|
||||
this.registerIncoming(0x4A, ServerEntityPropertiesPacket.class);
|
||||
this.registerIncoming(0x4B, ServerEntityEffectPacket.class);
|
||||
this.registerIncoming(0x30, ServerUnlockRecipesPacket.class);
|
||||
this.registerIncoming(0x31, ServerEntityDestroyPacket.class);
|
||||
this.registerIncoming(0x32, ServerEntityRemoveEffectPacket.class);
|
||||
this.registerIncoming(0x33, ServerResourcePackSendPacket.class);
|
||||
this.registerIncoming(0x34, ServerRespawnPacket.class);
|
||||
this.registerIncoming(0x35, ServerEntityHeadLookPacket.class);
|
||||
this.registerIncoming(0x36, ServerAdvancementTabPacket.class);
|
||||
this.registerIncoming(0x37, ServerWorldBorderPacket.class);
|
||||
this.registerIncoming(0x38, ServerSwitchCameraPacket.class);
|
||||
this.registerIncoming(0x39, ServerPlayerChangeHeldItemPacket.class);
|
||||
this.registerIncoming(0x3A, ServerDisplayScoreboardPacket.class);
|
||||
this.registerIncoming(0x3B, ServerEntityMetadataPacket.class);
|
||||
this.registerIncoming(0x3C, ServerEntityAttachPacket.class);
|
||||
this.registerIncoming(0x3D, ServerEntityVelocityPacket.class);
|
||||
this.registerIncoming(0x3E, ServerEntityEquipmentPacket.class);
|
||||
this.registerIncoming(0x3F, ServerPlayerSetExperiencePacket.class);
|
||||
this.registerIncoming(0x40, ServerPlayerHealthPacket.class);
|
||||
this.registerIncoming(0x41, ServerScoreboardObjectivePacket.class);
|
||||
this.registerIncoming(0x42, ServerEntitySetPassengersPacket.class);
|
||||
this.registerIncoming(0x43, ServerTeamPacket.class);
|
||||
this.registerIncoming(0x44, ServerUpdateScorePacket.class);
|
||||
this.registerIncoming(0x45, ServerSpawnPositionPacket.class);
|
||||
this.registerIncoming(0x46, ServerUpdateTimePacket.class);
|
||||
this.registerIncoming(0x47, ServerTitlePacket.class);
|
||||
this.registerIncoming(0x48, ServerPlayBuiltinSoundPacket.class);
|
||||
this.registerIncoming(0x49, ServerPlayerListDataPacket.class);
|
||||
this.registerIncoming(0x4A, ServerEntityCollectItemPacket.class);
|
||||
this.registerIncoming(0x4B, ServerEntityTeleportPacket.class);
|
||||
this.registerIncoming(0x4C, ServerAdvancementsPacket.class);
|
||||
this.registerIncoming(0x4D, ServerEntityPropertiesPacket.class);
|
||||
this.registerIncoming(0x4E, ServerEntityEffectPacket.class);
|
||||
|
||||
this.registerOutgoing(0x00, ClientTeleportConfirmPacket.class);
|
||||
this.registerOutgoing(0x01, ClientTabCompletePacket.class);
|
||||
this.registerOutgoing(0x02, ClientChatPacket.class);
|
||||
this.registerOutgoing(0x03, ClientRequestPacket.class);
|
||||
this.registerOutgoing(0x04, ClientSettingsPacket.class);
|
||||
this.registerOutgoing(0x05, ClientConfirmTransactionPacket.class);
|
||||
this.registerOutgoing(0x06, ClientEnchantItemPacket.class);
|
||||
this.registerOutgoing(0x07, ClientWindowActionPacket.class);
|
||||
this.registerOutgoing(0x08, ClientCloseWindowPacket.class);
|
||||
this.registerOutgoing(0x09, ClientPluginMessagePacket.class);
|
||||
this.registerOutgoing(0x0A, ClientPlayerInteractEntityPacket.class);
|
||||
this.registerOutgoing(0x0B, ClientKeepAlivePacket.class);
|
||||
this.registerOutgoing(0x0C, ClientPlayerPositionPacket.class);
|
||||
this.registerOutgoing(0x0D, ClientPlayerPositionRotationPacket.class);
|
||||
this.registerOutgoing(0x0E, ClientPlayerRotationPacket.class);
|
||||
this.registerOutgoing(0x0F, ClientPlayerMovementPacket.class);
|
||||
this.registerOutgoing(0x10, ClientVehicleMovePacket.class);
|
||||
this.registerOutgoing(0x11, ClientSteerBoatPacket.class);
|
||||
this.registerOutgoing(0x12, ClientPlayerAbilitiesPacket.class);
|
||||
this.registerOutgoing(0x13, ClientPlayerActionPacket.class);
|
||||
this.registerOutgoing(0x14, ClientPlayerStatePacket.class);
|
||||
this.registerOutgoing(0x15, ClientSteerVehiclePacket.class);
|
||||
this.registerOutgoing(0x16, ClientResourcePackStatusPacket.class);
|
||||
this.registerOutgoing(0x17, ClientPlayerChangeHeldItemPacket.class);
|
||||
this.registerOutgoing(0x18, ClientCreativeInventoryActionPacket.class);
|
||||
this.registerOutgoing(0x19, ClientUpdateSignPacket.class);
|
||||
this.registerOutgoing(0x1A, ClientPlayerSwingArmPacket.class);
|
||||
this.registerOutgoing(0x1B, ClientSpectatePacket.class);
|
||||
this.registerOutgoing(0x1C, ClientPlayerPlaceBlockPacket.class);
|
||||
this.registerOutgoing(0x1D, ClientPlayerUseItemPacket.class);
|
||||
this.registerOutgoing(0x01, ClientPrepareCraftingGridPacket.class);
|
||||
this.registerOutgoing(0x02, ClientTabCompletePacket.class);
|
||||
this.registerOutgoing(0x03, ClientChatPacket.class);
|
||||
this.registerOutgoing(0x04, ClientRequestPacket.class);
|
||||
this.registerOutgoing(0x05, ClientSettingsPacket.class);
|
||||
this.registerOutgoing(0x06, ClientConfirmTransactionPacket.class);
|
||||
this.registerOutgoing(0x07, ClientEnchantItemPacket.class);
|
||||
this.registerOutgoing(0x08, ClientWindowActionPacket.class);
|
||||
this.registerOutgoing(0x09, ClientCloseWindowPacket.class);
|
||||
this.registerOutgoing(0x0A, ClientPluginMessagePacket.class);
|
||||
this.registerOutgoing(0x0B, ClientPlayerInteractEntityPacket.class);
|
||||
this.registerOutgoing(0x0C, ClientKeepAlivePacket.class);
|
||||
this.registerOutgoing(0x0D, ClientPlayerMovementPacket.class);
|
||||
this.registerOutgoing(0x0E, ClientPlayerPositionPacket.class);
|
||||
this.registerOutgoing(0x0F, ClientPlayerPositionRotationPacket.class);
|
||||
this.registerOutgoing(0x10, ClientPlayerRotationPacket.class);
|
||||
this.registerOutgoing(0x11, ClientVehicleMovePacket.class);
|
||||
this.registerOutgoing(0x12, ClientSteerBoatPacket.class);
|
||||
this.registerOutgoing(0x13, ClientPlayerAbilitiesPacket.class);
|
||||
this.registerOutgoing(0x14, ClientPlayerActionPacket.class);
|
||||
this.registerOutgoing(0x15, ClientPlayerStatePacket.class);
|
||||
this.registerOutgoing(0x16, ClientSteerVehiclePacket.class);
|
||||
this.registerOutgoing(0x17, ClientCraftingBookDataPacket.class);
|
||||
this.registerOutgoing(0x18, ClientResourcePackStatusPacket.class);
|
||||
this.registerOutgoing(0x19, ClientAdvancementTabPacket.class);
|
||||
this.registerOutgoing(0x1A, ClientPlayerChangeHeldItemPacket.class);
|
||||
this.registerOutgoing(0x1B, ClientCreativeInventoryActionPacket.class);
|
||||
this.registerOutgoing(0x1C, ClientUpdateSignPacket.class);
|
||||
this.registerOutgoing(0x1D, ClientPlayerSwingArmPacket.class);
|
||||
this.registerOutgoing(0x1E, ClientSpectatePacket.class);
|
||||
this.registerOutgoing(0x1F, ClientPlayerPlaceBlockPacket.class);
|
||||
this.registerOutgoing(0x20, ClientPlayerUseItemPacket.class);
|
||||
}
|
||||
|
||||
private void initServerGame(Session session) {
|
||||
this.registerIncoming(0x00, ClientTeleportConfirmPacket.class);
|
||||
this.registerIncoming(0x01, ClientTabCompletePacket.class);
|
||||
this.registerIncoming(0x02, ClientChatPacket.class);
|
||||
this.registerIncoming(0x03, ClientRequestPacket.class);
|
||||
this.registerIncoming(0x04, ClientSettingsPacket.class);
|
||||
this.registerIncoming(0x05, ClientConfirmTransactionPacket.class);
|
||||
this.registerIncoming(0x06, ClientEnchantItemPacket.class);
|
||||
this.registerIncoming(0x07, ClientWindowActionPacket.class);
|
||||
this.registerIncoming(0x08, ClientCloseWindowPacket.class);
|
||||
this.registerIncoming(0x09, ClientPluginMessagePacket.class);
|
||||
this.registerIncoming(0x0A, ClientPlayerInteractEntityPacket.class);
|
||||
this.registerIncoming(0x0B, ClientKeepAlivePacket.class);
|
||||
this.registerIncoming(0x0C, ClientPlayerPositionPacket.class);
|
||||
this.registerIncoming(0x0D, ClientPlayerPositionRotationPacket.class);
|
||||
this.registerIncoming(0x0E, ClientPlayerRotationPacket.class);
|
||||
this.registerIncoming(0x0F, ClientPlayerMovementPacket.class);
|
||||
this.registerIncoming(0x10, ClientVehicleMovePacket.class);
|
||||
this.registerIncoming(0x11, ClientSteerBoatPacket.class);
|
||||
this.registerIncoming(0x12, ClientPlayerAbilitiesPacket.class);
|
||||
this.registerIncoming(0x13, ClientPlayerActionPacket.class);
|
||||
this.registerIncoming(0x14, ClientPlayerStatePacket.class);
|
||||
this.registerIncoming(0x15, ClientSteerVehiclePacket.class);
|
||||
this.registerIncoming(0x16, ClientResourcePackStatusPacket.class);
|
||||
this.registerIncoming(0x17, ClientPlayerChangeHeldItemPacket.class);
|
||||
this.registerIncoming(0x18, ClientCreativeInventoryActionPacket.class);
|
||||
this.registerIncoming(0x19, ClientUpdateSignPacket.class);
|
||||
this.registerIncoming(0x1A, ClientPlayerSwingArmPacket.class);
|
||||
this.registerIncoming(0x1B, ClientSpectatePacket.class);
|
||||
this.registerIncoming(0x1C, ClientPlayerPlaceBlockPacket.class);
|
||||
this.registerIncoming(0x1D, ClientPlayerUseItemPacket.class);
|
||||
this.registerIncoming(0x01, ClientPrepareCraftingGridPacket.class);
|
||||
this.registerIncoming(0x02, ClientTabCompletePacket.class);
|
||||
this.registerIncoming(0x03, ClientChatPacket.class);
|
||||
this.registerIncoming(0x04, ClientRequestPacket.class);
|
||||
this.registerIncoming(0x05, ClientSettingsPacket.class);
|
||||
this.registerIncoming(0x06, ClientConfirmTransactionPacket.class);
|
||||
this.registerIncoming(0x07, ClientEnchantItemPacket.class);
|
||||
this.registerIncoming(0x08, ClientWindowActionPacket.class);
|
||||
this.registerIncoming(0x09, ClientCloseWindowPacket.class);
|
||||
this.registerIncoming(0x0A, ClientPluginMessagePacket.class);
|
||||
this.registerIncoming(0x0B, ClientPlayerInteractEntityPacket.class);
|
||||
this.registerIncoming(0x0C, ClientKeepAlivePacket.class);
|
||||
this.registerIncoming(0x0D, ClientPlayerMovementPacket.class);
|
||||
this.registerIncoming(0x0E, ClientPlayerPositionPacket.class);
|
||||
this.registerIncoming(0x0F, ClientPlayerPositionRotationPacket.class);
|
||||
this.registerIncoming(0x10, ClientPlayerRotationPacket.class);
|
||||
this.registerIncoming(0x11, ClientVehicleMovePacket.class);
|
||||
this.registerIncoming(0x12, ClientSteerBoatPacket.class);
|
||||
this.registerIncoming(0x13, ClientPlayerAbilitiesPacket.class);
|
||||
this.registerIncoming(0x14, ClientPlayerActionPacket.class);
|
||||
this.registerIncoming(0x15, ClientPlayerStatePacket.class);
|
||||
this.registerIncoming(0x16, ClientSteerVehiclePacket.class);
|
||||
this.registerIncoming(0x17, ClientCraftingBookDataPacket.class);
|
||||
this.registerIncoming(0x18, ClientResourcePackStatusPacket.class);
|
||||
this.registerIncoming(0x19, ClientAdvancementTabPacket.class);
|
||||
this.registerIncoming(0x1A, ClientPlayerChangeHeldItemPacket.class);
|
||||
this.registerIncoming(0x1B, ClientCreativeInventoryActionPacket.class);
|
||||
this.registerIncoming(0x1C, ClientUpdateSignPacket.class);
|
||||
this.registerIncoming(0x1D, ClientPlayerSwingArmPacket.class);
|
||||
this.registerIncoming(0x1E, ClientSpectatePacket.class);
|
||||
this.registerIncoming(0x1F, ClientPlayerPlaceBlockPacket.class);
|
||||
this.registerIncoming(0x20, ClientPlayerUseItemPacket.class);
|
||||
|
||||
this.registerOutgoing(0x00, ServerSpawnObjectPacket.class);
|
||||
this.registerOutgoing(0x01, ServerSpawnExpOrbPacket.class);
|
||||
|
@ -492,10 +507,10 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerOutgoing(0x22, ServerSpawnParticlePacket.class);
|
||||
this.registerOutgoing(0x23, ServerJoinGamePacket.class);
|
||||
this.registerOutgoing(0x24, ServerMapDataPacket.class);
|
||||
this.registerOutgoing(0x25, ServerEntityPositionPacket.class);
|
||||
this.registerOutgoing(0x26, ServerEntityPositionRotationPacket.class);
|
||||
this.registerOutgoing(0x27, ServerEntityRotationPacket.class);
|
||||
this.registerOutgoing(0x28, ServerEntityMovementPacket.class);
|
||||
this.registerOutgoing(0x25, ServerEntityMovementPacket.class);
|
||||
this.registerOutgoing(0x26, ServerEntityPositionPacket.class);
|
||||
this.registerOutgoing(0x27, ServerEntityPositionRotationPacket.class);
|
||||
this.registerOutgoing(0x28, ServerEntityRotationPacket.class);
|
||||
this.registerOutgoing(0x29, ServerVehicleMovePacket.class);
|
||||
this.registerOutgoing(0x2A, ServerOpenTileEntityEditorPacket.class);
|
||||
this.registerOutgoing(0x2B, ServerPlayerAbilitiesPacket.class);
|
||||
|
@ -503,34 +518,37 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerOutgoing(0x2D, ServerPlayerListEntryPacket.class);
|
||||
this.registerOutgoing(0x2E, ServerPlayerPositionRotationPacket.class);
|
||||
this.registerOutgoing(0x2F, ServerPlayerUseBedPacket.class);
|
||||
this.registerOutgoing(0x30, ServerEntityDestroyPacket.class);
|
||||
this.registerOutgoing(0x31, ServerEntityRemoveEffectPacket.class);
|
||||
this.registerOutgoing(0x32, ServerResourcePackSendPacket.class);
|
||||
this.registerOutgoing(0x33, ServerRespawnPacket.class);
|
||||
this.registerOutgoing(0x34, ServerEntityHeadLookPacket.class);
|
||||
this.registerOutgoing(0x35, ServerWorldBorderPacket.class);
|
||||
this.registerOutgoing(0x36, ServerSwitchCameraPacket.class);
|
||||
this.registerOutgoing(0x37, ServerPlayerChangeHeldItemPacket.class);
|
||||
this.registerOutgoing(0x38, ServerDisplayScoreboardPacket.class);
|
||||
this.registerOutgoing(0x39, ServerEntityMetadataPacket.class);
|
||||
this.registerOutgoing(0x3A, ServerEntityAttachPacket.class);
|
||||
this.registerOutgoing(0x3B, ServerEntityVelocityPacket.class);
|
||||
this.registerOutgoing(0x3C, ServerEntityEquipmentPacket.class);
|
||||
this.registerOutgoing(0x3D, ServerPlayerSetExperiencePacket.class);
|
||||
this.registerOutgoing(0x3E, ServerPlayerHealthPacket.class);
|
||||
this.registerOutgoing(0x3F, ServerScoreboardObjectivePacket.class);
|
||||
this.registerOutgoing(0x40, ServerEntitySetPassengersPacket.class);
|
||||
this.registerOutgoing(0x41, ServerTeamPacket.class);
|
||||
this.registerOutgoing(0x42, ServerUpdateScorePacket.class);
|
||||
this.registerOutgoing(0x43, ServerSpawnPositionPacket.class);
|
||||
this.registerOutgoing(0x44, ServerUpdateTimePacket.class);
|
||||
this.registerOutgoing(0x45, ServerTitlePacket.class);
|
||||
this.registerOutgoing(0x46, ServerPlayBuiltinSoundPacket.class);
|
||||
this.registerOutgoing(0x47, ServerPlayerListDataPacket.class);
|
||||
this.registerOutgoing(0x48, ServerEntityCollectItemPacket.class);
|
||||
this.registerOutgoing(0x49, ServerEntityTeleportPacket.class);
|
||||
this.registerOutgoing(0x4A, ServerEntityPropertiesPacket.class);
|
||||
this.registerOutgoing(0x4B, ServerEntityEffectPacket.class);
|
||||
this.registerOutgoing(0x30, ServerUnlockRecipesPacket.class);
|
||||
this.registerOutgoing(0x31, ServerEntityDestroyPacket.class);
|
||||
this.registerOutgoing(0x32, ServerEntityRemoveEffectPacket.class);
|
||||
this.registerOutgoing(0x33, ServerResourcePackSendPacket.class);
|
||||
this.registerOutgoing(0x34, ServerRespawnPacket.class);
|
||||
this.registerOutgoing(0x35, ServerEntityHeadLookPacket.class);
|
||||
this.registerOutgoing(0x36, ServerAdvancementTabPacket.class);
|
||||
this.registerOutgoing(0x37, ServerWorldBorderPacket.class);
|
||||
this.registerOutgoing(0x38, ServerSwitchCameraPacket.class);
|
||||
this.registerOutgoing(0x39, ServerPlayerChangeHeldItemPacket.class);
|
||||
this.registerOutgoing(0x3A, ServerDisplayScoreboardPacket.class);
|
||||
this.registerOutgoing(0x3B, ServerEntityMetadataPacket.class);
|
||||
this.registerOutgoing(0x3C, ServerEntityAttachPacket.class);
|
||||
this.registerOutgoing(0x3D, ServerEntityVelocityPacket.class);
|
||||
this.registerOutgoing(0x3E, ServerEntityEquipmentPacket.class);
|
||||
this.registerOutgoing(0x3F, ServerPlayerSetExperiencePacket.class);
|
||||
this.registerOutgoing(0x40, ServerPlayerHealthPacket.class);
|
||||
this.registerOutgoing(0x41, ServerScoreboardObjectivePacket.class);
|
||||
this.registerOutgoing(0x42, ServerEntitySetPassengersPacket.class);
|
||||
this.registerOutgoing(0x43, ServerTeamPacket.class);
|
||||
this.registerOutgoing(0x44, ServerUpdateScorePacket.class);
|
||||
this.registerOutgoing(0x45, ServerSpawnPositionPacket.class);
|
||||
this.registerOutgoing(0x46, ServerUpdateTimePacket.class);
|
||||
this.registerOutgoing(0x47, ServerTitlePacket.class);
|
||||
this.registerOutgoing(0x48, ServerPlayBuiltinSoundPacket.class);
|
||||
this.registerOutgoing(0x49, ServerPlayerListDataPacket.class);
|
||||
this.registerOutgoing(0x4A, ServerEntityCollectItemPacket.class);
|
||||
this.registerOutgoing(0x4B, ServerEntityTeleportPacket.class);
|
||||
this.registerOutgoing(0x4C, ServerAdvancementsPacket.class);
|
||||
this.registerOutgoing(0x4D, ServerEntityPropertiesPacket.class);
|
||||
this.registerOutgoing(0x4E, ServerEntityEffectPacket.class);
|
||||
}
|
||||
|
||||
private void initClientStatus(Session session) {
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
|
|||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.data.game.MessageType;
|
||||
import com.github.steveice10.mc.protocol.data.game.ResourcePackStatus;
|
||||
import com.github.steveice10.mc.protocol.data.game.UnlockRecipesAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.EquipmentSlot;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.AttributeType;
|
||||
|
@ -29,7 +31,9 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
|
|||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.Achievement;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.ClickItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.CraftingBookDataType;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.CreativeGrabParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.ShiftClickItemParam;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.SpreadItemParam;
|
||||
|
@ -97,6 +101,7 @@ public class MagicValues {
|
|||
register(AttributeType.GENERIC_ARMOR, "generic.armor");
|
||||
register(AttributeType.GENERIC_ARMOR_TOUGHNESS, "generic.armorToughness");
|
||||
register(AttributeType.GENERIC_LUCK, "generic.luck");
|
||||
register(AttributeType.GENERIC_FLYING_SPEED, "generic.flyingSpeed");
|
||||
register(AttributeType.HORSE_JUMP_STRENGTH, "horse.jumpStrength");
|
||||
register(AttributeType.ZOMBIE_SPAWN_REINFORCEMENTS, "zombie.spawnReinforcements");
|
||||
|
||||
|
@ -140,13 +145,13 @@ public class MagicValues {
|
|||
register(MetadataType.BLOCK_FACE, 10);
|
||||
register(MetadataType.OPTIONAL_UUID, 11);
|
||||
register(MetadataType.BLOCK_STATE, 12);
|
||||
register(MetadataType.NBT_TAG, 13);
|
||||
|
||||
register(HandshakeIntent.STATUS, 1);
|
||||
register(HandshakeIntent.LOGIN, 2);
|
||||
|
||||
register(ClientRequest.RESPAWN, 0);
|
||||
register(ClientRequest.STATS, 1);
|
||||
register(ClientRequest.OPEN_INVENTORY, 2);
|
||||
|
||||
register(ChatVisibility.FULL, 0);
|
||||
register(ChatVisibility.SYSTEM, 1);
|
||||
|
@ -307,6 +312,8 @@ public class MagicValues {
|
|||
register(EntityStatus.LIVING_HURT_THORNS, 33);
|
||||
register(EntityStatus.IRON_GOLEM_EMPTY_HAND, 34);
|
||||
register(EntityStatus.TOTEM_OF_UNDYING_MAKE_SOUND, 35);
|
||||
register(EntityStatus.LIVING_DROWN, 36);
|
||||
register(EntityStatus.LIVING_BURN, 37);
|
||||
|
||||
register(PositionElement.X, 0);
|
||||
register(PositionElement.Y, 1);
|
||||
|
@ -329,6 +336,7 @@ public class MagicValues {
|
|||
register(MobType.EVOCATION_ILLAGER, 34);
|
||||
register(MobType.VEX, 35);
|
||||
register(MobType.VINDICATION_ILLAGER, 36);
|
||||
register(MobType.ILLUSION_ILLAGER, 37);
|
||||
register(MobType.CREEPER, 50);
|
||||
register(MobType.SKELETON, 51);
|
||||
register(MobType.SPIDER, 52);
|
||||
|
@ -363,6 +371,7 @@ public class MagicValues {
|
|||
register(MobType.RABBIT, 101);
|
||||
register(MobType.POLAR_BEAR, 102);
|
||||
register(MobType.LLAMA, 103);
|
||||
register(MobType.PARROT, 105);
|
||||
register(MobType.VILLAGER, 120);
|
||||
|
||||
register(ObjectType.BOAT, 1);
|
||||
|
@ -538,6 +547,7 @@ public class MagicValues {
|
|||
register(UpdatedTileType.END_GATEWAY, 8);
|
||||
register(UpdatedTileType.SIGN, 9);
|
||||
register(UpdatedTileType.SHULKER_BOX, 10);
|
||||
register(UpdatedTileType.BED, 11);
|
||||
|
||||
register(ClientNotification.INVALID_BED, 0);
|
||||
register(ClientNotification.START_RAIN, 2);
|
||||
|
@ -669,6 +679,11 @@ public class MagicValues {
|
|||
register(NoteBlockValueType.SNARE_DRUM, 2);
|
||||
register(NoteBlockValueType.HI_HAT, 3);
|
||||
register(NoteBlockValueType.BASS_DRUM, 4);
|
||||
register(NoteBlockValueType.FLUTE, 5);
|
||||
register(NoteBlockValueType.BELL, 6);
|
||||
register(NoteBlockValueType.GUITAR, 7);
|
||||
register(NoteBlockValueType.CHIME, 8);
|
||||
register(NoteBlockValueType.XYLOPHONE, 9);
|
||||
|
||||
register(PistonValueType.PUSHING, 0);
|
||||
register(PistonValueType.PULLING, 1);
|
||||
|
@ -779,6 +794,10 @@ public class MagicValues {
|
|||
register(ScoreType.INTEGER, "integer");
|
||||
register(ScoreType.HEARTS, "hearts");
|
||||
|
||||
register(Advancement.DisplayData.FrameType.TASK, 0);
|
||||
register(Advancement.DisplayData.FrameType.CHALLENGE, 1);
|
||||
register(Advancement.DisplayData.FrameType.GOAL, 2);
|
||||
|
||||
register(WorldBorderAction.SET_SIZE, 0);
|
||||
register(WorldBorderAction.LERP_SIZE, 1);
|
||||
register(WorldBorderAction.SET_CENTER, 2);
|
||||
|
@ -799,6 +818,16 @@ public class MagicValues {
|
|||
register(TitleAction.CLEAR, 4);
|
||||
register(TitleAction.RESET, 5);
|
||||
|
||||
register(UnlockRecipesAction.INIT, 0);
|
||||
register(UnlockRecipesAction.ADD, 1);
|
||||
register(UnlockRecipesAction.REMOVE, 2);
|
||||
|
||||
register(CraftingBookDataType.DISPLAYED_RECIPE, 0);
|
||||
register(CraftingBookDataType.CRAFTING_BOOK_STATUS, 1);
|
||||
|
||||
register(AdvancementTabAction.OPENED_TAB, 0);
|
||||
register(AdvancementTabAction.CLOSED_SCREEN, 1);
|
||||
|
||||
register(ResourcePackStatus.SUCCESSFULLY_LOADED, 0);
|
||||
register(ResourcePackStatus.DECLINED, 1);
|
||||
register(ResourcePackStatus.FAILED_DOWNLOAD, 2);
|
||||
|
@ -865,6 +894,8 @@ public class MagicValues {
|
|||
register(BuiltinSound.BLOCK_CHORUS_FLOWER_GROW, "block.chorus_flower.grow", true);
|
||||
register(BuiltinSound.BLOCK_ENCHANTMENT_TABLE_USE, "block.enchantment_table.use", true);
|
||||
register(BuiltinSound.BLOCK_END_GATEWAY_SPAWN, "block.end_gateway.spawn", true);
|
||||
register(BuiltinSound.BLOCK_END_PORTAL_SPAWN, "block.end_portal.spawn", true);
|
||||
register(BuiltinSound.BLOCK_END_PORTAL_FRAME_FILL, "block.end_portal_frame.fill", true);
|
||||
register(BuiltinSound.BLOCK_FENCE_GATE_CLOSE, "block.fence_gate.close", true);
|
||||
register(BuiltinSound.BLOCK_FENCE_GATE_OPEN, "block.fence_gate.open", true);
|
||||
register(BuiltinSound.BLOCK_FURNACE_FIRE_CRACKLE, "block.furnace.fire_crackle", true);
|
||||
|
@ -892,6 +923,8 @@ public class MagicValues {
|
|||
register(BuiltinSound.BLOCK_WOODEN_TRAPDOOR_CLOSE, "block.wooden_trapdoor.close", true);
|
||||
register(BuiltinSound.BLOCK_WOODEN_TRAPDOOR_CLOSE, "block.wooden_trapdoor.open", true);
|
||||
register(BuiltinSound.ENTITY_ARROW_HIT_PLAYER, "entity.arrow.hit_player", true);
|
||||
register(BuiltinSound.ENTITY_BOAT_PADDLE_LAND, "entity.boat.paddle_land", true);
|
||||
register(BuiltinSound.ENTITY_BOAT_PADDLE_WATER, "entity.boat.paddle_water", true);
|
||||
register(BuiltinSound.ENTITY_ELDER_GUARDIAN_AMBIENT, "entity.elder_guardian.ambient", true);
|
||||
register(BuiltinSound.ENTITY_ELDER_GUARDIAN_AMBIENT_LAND, "entity.elder_guardian.ambient_land", true);
|
||||
register(BuiltinSound.ENTITY_ELDER_GUARDIAN_CURSE, "entity.elder_guardian.curse", true);
|
||||
|
@ -924,10 +957,27 @@ public class MagicValues {
|
|||
register(BuiltinSound.ENTITY_HORSE_STEP_WOOD, "entity.horse.step_wood", true);
|
||||
register(BuiltinSound.ENTITY_HOSTILE_BIG_FALL, "entity.hostile.big_fall", true);
|
||||
register(BuiltinSound.ENTITY_HOSTILE_SMALL_FALL, "entity.hostile.small_fall", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_AMBIENT, "entity.illusion_illager.ambient", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_CAST_SPELL, "entity.illusion_illager.cast_spell", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_DEATH, "entity.illusion_illager.death", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_HURT, "entity.illusion_illager.hury", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE, "entity.illusion_illager.mirror_move", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS, "entity.illusion_illager.prepare_blindness", true);
|
||||
register(BuiltinSound.ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR, "entity.illusion_illager.prepare_mirror", true);
|
||||
register(BuiltinSound.ENTITY_ITEMFRAME_ADD_ITEM, "entity.itemframe.add_item", true);
|
||||
register(BuiltinSound.ENTITY_ITEMFRAME_REMOVE_ITEM, "entity.itemframe.remove_item", true);
|
||||
register(BuiltinSound.ENTITY_ITEMFRAME_ROTATE_ITEM, "entity.itemframe.rotate_item", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_ELDER_GUARDIAN, "entity.parrot.imitate.elder_guardian", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_EVOCATION_ILLAGER, "entity.parrot.imitate.evocation_illager", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_ILLUSION_ILLAGER, "entity.parrot.imitate.illusion_illager", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_POLAR_BEAR, "entity.parrot.imitate.polar_bear", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_VINDICATION_ILLAGER, "entity.parrot.imitate.vindication_illager", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_WITHER_SKELETON, "entity.parrot.imitate.wither_skeleton", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN, "entity.parrot.imitate.zombie_pigman", true);
|
||||
register(BuiltinSound.ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER, "entity.parrot.imitate.zombie_villager", true);
|
||||
register(BuiltinSound.ENTITY_PLAYER_BIG_FALL, "entity.player.big_fall", true);
|
||||
register(BuiltinSound.ENTITY_PLAYER_HURT_DROWN, "entity.player.hurt_drown", true);
|
||||
register(BuiltinSound.ENTITY_PLAYER_HURT_ON_FIRE, "entity.player.hurt_on_fire", true);
|
||||
register(BuiltinSound.ENTITY_PLAYER_SMALL_FALL, "entity.player.small_fall", true);
|
||||
register(BuiltinSound.ENTITY_POLAR_BEAR_AMBIENT, "entity.polar_bear.ambient", true);
|
||||
register(BuiltinSound.ENTITY_POLAR_BEAR_BABY_AMBIENT, "entity.polar_bear.baby_ambient", true);
|
||||
|
@ -985,6 +1035,7 @@ public class MagicValues {
|
|||
register(BuiltinSound.ITEM_BUCKET_EMPTY_LAVA, "item.bucket.empty_lava", true);
|
||||
register(BuiltinSound.ITEM_BUCKET_FILL_LAVA, "item.bucket.fill_lava", true);
|
||||
register(BuiltinSound.ITEM_CHORUS_FRUIT_TELEPORT, "item.chorus_fruit.teleport", true);
|
||||
register(BuiltinSound.UI_TOAST_CHALLENGE_COMPLETE, "ui.toast.challenge_complete", true);
|
||||
}
|
||||
|
||||
private static void register(Enum<?> key, Object value) {
|
||||
|
|
|
@ -2,6 +2,5 @@ package com.github.steveice10.mc.protocol.data.game;
|
|||
|
||||
public enum ClientRequest {
|
||||
RESPAWN,
|
||||
STATS,
|
||||
OPEN_INVENTORY;
|
||||
STATS;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.github.steveice10.mc.protocol.data.game;
|
||||
|
||||
public enum UnlockRecipesAction {
|
||||
INIT,
|
||||
ADD,
|
||||
REMOVE;
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.advancement;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Advancement {
|
||||
private String id;
|
||||
private String parentId;
|
||||
private DisplayData displayData;
|
||||
private List<String> criteria;
|
||||
private List<List<String>> requirements;
|
||||
|
||||
public Advancement(String id, String parentId, List<String> criteria, List<List<String>> requirements) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
this.criteria = criteria;
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public Advancement(String id, String parentId, List<String> criteria, List<List<String>> requirements, DisplayData displayData) {
|
||||
this(id, parentId, criteria, requirements);
|
||||
this.displayData = displayData;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public DisplayData getDisplayData() {
|
||||
return displayData;
|
||||
}
|
||||
|
||||
public List<String> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<List<String>> getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Advancement)) return false;
|
||||
Advancement that = (Advancement) o;
|
||||
return Objects.equals(this.id, that.id) &&
|
||||
Objects.equals(this.parentId, that.parentId) &&
|
||||
Objects.equals(this.displayData, that.displayData) &&
|
||||
Objects.equals(this.criteria, that.criteria) &&
|
||||
Objects.equals(this.requirements, that.requirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, parentId, displayData, criteria, requirements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
|
||||
public static class DisplayData {
|
||||
public enum FrameType {
|
||||
TASK,
|
||||
CHALLENGE,
|
||||
GOAL;
|
||||
}
|
||||
|
||||
private Message title;
|
||||
private Message description;
|
||||
private ItemStack icon;
|
||||
private FrameType frameType;
|
||||
private boolean showToast;
|
||||
private boolean hidden;
|
||||
private String backgroundTexture;
|
||||
private float posX, posY;
|
||||
|
||||
public DisplayData(Message title, Message description, ItemStack icon, FrameType frameType,
|
||||
boolean showToast, boolean hidden, float posX, float posY) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.icon = icon;
|
||||
this.frameType = frameType;
|
||||
this.showToast = showToast;
|
||||
this.hidden = hidden;
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
}
|
||||
|
||||
public DisplayData(Message title, Message description, ItemStack icon, FrameType frameType,
|
||||
boolean showToast, boolean hidden, float posX, float posY, String backgroundTexture) {
|
||||
this(title, description, icon, frameType, showToast, hidden, posX, posY);
|
||||
this.backgroundTexture = backgroundTexture;
|
||||
}
|
||||
|
||||
public Message getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public Message getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public ItemStack getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public FrameType getFrameType() {
|
||||
return frameType;
|
||||
}
|
||||
|
||||
public boolean doesShowToast() {
|
||||
return showToast;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public String getBackgroundTexture() {
|
||||
return backgroundTexture;
|
||||
}
|
||||
|
||||
public float getPosX() {
|
||||
return posX;
|
||||
}
|
||||
|
||||
public float getPosY() {
|
||||
return posY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof DisplayData)) return false;
|
||||
DisplayData that = (DisplayData) o;
|
||||
return this.showToast == that.showToast &&
|
||||
this.hidden == that.hidden &&
|
||||
Float.compare(that.posX, this.posX) == 0 &&
|
||||
Float.compare(that.posY, this.posY) == 0 &&
|
||||
Objects.equals(this.title, that.title) &&
|
||||
Objects.equals(this.description, that.description) &&
|
||||
Objects.equals(this.icon, that.icon) &&
|
||||
this.frameType == that.frameType &&
|
||||
Objects.equals(this.backgroundTexture, that.backgroundTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(title, description, icon, frameType, showToast, hidden, backgroundTexture, posX, posY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,5 +35,7 @@ public enum EntityStatus {
|
|||
ARMOR_STAND_HIT,
|
||||
LIVING_HURT_THORNS,
|
||||
IRON_GOLEM_EMPTY_HAND,
|
||||
TOTEM_OF_UNDYING_MAKE_SOUND;
|
||||
TOTEM_OF_UNDYING_MAKE_SOUND,
|
||||
LIVING_DROWN,
|
||||
LIVING_BURN;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ public enum AttributeType {
|
|||
GENERIC_ARMOR(0, 0, 30),
|
||||
GENERIC_ARMOR_TOUGHNESS(0, 0, 20),
|
||||
GENERIC_LUCK(0, -1024, 1024),
|
||||
GENERIC_FLYING_SPEED(0.4000000059604645, 0, 1024),
|
||||
HORSE_JUMP_STRENGTH(0.7, 0, 2),
|
||||
ZOMBIE_SPAWN_REINFORCEMENTS(0, 0, 1);
|
||||
|
||||
|
|
|
@ -13,5 +13,6 @@ public enum MetadataType {
|
|||
OPTIONAL_POSITION,
|
||||
BLOCK_FACE,
|
||||
OPTIONAL_UUID,
|
||||
BLOCK_STATE;
|
||||
BLOCK_STATE,
|
||||
NBT_TAG;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ public enum MobType {
|
|||
EVOCATION_ILLAGER,
|
||||
VEX,
|
||||
VINDICATION_ILLAGER,
|
||||
ILLUSION_ILLAGER,
|
||||
CREEPER,
|
||||
SKELETON,
|
||||
SPIDER,
|
||||
|
@ -48,5 +49,6 @@ public enum MobType {
|
|||
RABBIT,
|
||||
POLAR_BEAR,
|
||||
LLAMA,
|
||||
PARROT,
|
||||
VILLAGER;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
public enum AdvancementTabAction {
|
||||
OPENED_TAB,
|
||||
CLOSED_SCREEN;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
public enum CraftingBookDataType {
|
||||
DISPLAYED_RECIPE,
|
||||
CRAFTING_BOOK_STATUS;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.window;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PrepareCraftingGridEntry {
|
||||
private ItemStack item;
|
||||
private byte craftingGridSlot;
|
||||
private byte playerInventorySlot;
|
||||
|
||||
public PrepareCraftingGridEntry(ItemStack item, byte craftingGridSlot, byte playerInventorySlot) {
|
||||
this.item = item;
|
||||
this.craftingGridSlot = craftingGridSlot;
|
||||
this.playerInventorySlot = playerInventorySlot;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public byte getCraftingGridSlot() {
|
||||
return this.craftingGridSlot;
|
||||
}
|
||||
|
||||
public byte getPlayerInventorySlot() {
|
||||
return this.playerInventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof PrepareCraftingGridEntry)) return false;
|
||||
PrepareCraftingGridEntry that = (PrepareCraftingGridEntry) o;
|
||||
return this.craftingGridSlot == that.craftingGridSlot &&
|
||||
this.playerInventorySlot == that.playerInventorySlot &&
|
||||
Objects.equals(this.item, that.item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(item, craftingGridSlot, playerInventorySlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -10,5 +10,6 @@ public enum UpdatedTileType {
|
|||
STRUCTURE_BLOCK,
|
||||
END_GATEWAY,
|
||||
SIGN,
|
||||
SHULKER_BOX;
|
||||
SHULKER_BOX,
|
||||
BED;
|
||||
}
|
||||
|
|
|
@ -5,5 +5,10 @@ public enum NoteBlockValueType implements BlockValueType {
|
|||
DOUBLE_BASS,
|
||||
SNARE_DRUM,
|
||||
HI_HAT,
|
||||
BASS_DRUM;
|
||||
BASS_DRUM,
|
||||
FLUTE,
|
||||
BELL,
|
||||
GUITAR,
|
||||
CHIME,
|
||||
XYLOPHONE;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public enum BuiltinSound implements Sound {
|
|||
BLOCK_DISPENSER_LAUNCH,
|
||||
BLOCK_ENCHANTMENT_TABLE_USE,
|
||||
BLOCK_END_GATEWAY_SPAWN,
|
||||
BLOCK_END_PORTAL_SPAWN,
|
||||
BLOCK_END_PORTAL_FRAME_FILL,
|
||||
BLOCK_ENDERCHEST_CLOSE,
|
||||
BLOCK_ENDERCHEST_OPEN,
|
||||
BLOCK_FENCE_GATE_CLOSE,
|
||||
|
@ -71,10 +73,15 @@ public enum BuiltinSound implements Sound {
|
|||
BLOCK_METAL_PRESSUREPLATE_CLICK_ON,
|
||||
BLOCK_NOTE_BASEDRUM,
|
||||
BLOCK_NOTE_BASS,
|
||||
BLOCK_NOTE_BELL,
|
||||
BLOCK_NOTE_CHIME,
|
||||
BLOCK_NOTE_FLUTE,
|
||||
BLOCK_NOTE_GUITAR,
|
||||
BLOCK_NOTE_HARP,
|
||||
BLOCK_NOTE_HAT,
|
||||
BLOCK_NOTE_PLING,
|
||||
BLOCK_NOTE_SNARE,
|
||||
BLOCK_NOTE_XYLOPHONE,
|
||||
BLOCK_PISTON_CONTRACT,
|
||||
BLOCK_PISTON_EXTEND,
|
||||
BLOCK_PORTAL_AMBIENT,
|
||||
|
@ -144,6 +151,9 @@ public enum BuiltinSound implements Sound {
|
|||
ENTITY_BLAZE_DEATH,
|
||||
ENTITY_BLAZE_HURT,
|
||||
ENTITY_BLAZE_SHOOT,
|
||||
ENTITY_BOAT_PADDLE_LAND,
|
||||
ENTITY_BOAT_PADDLE_WATER,
|
||||
ENTITY_BOBBER_RETRIEVE,
|
||||
ENTITY_BOBBER_SPLASH,
|
||||
ENTITY_BOBBER_THROW,
|
||||
ENTITY_CAT_AMBIENT,
|
||||
|
@ -186,6 +196,7 @@ public enum BuiltinSound implements Sound {
|
|||
ENTITY_ENDERDRAGON_HURT,
|
||||
ENTITY_ENDERDRAGON_SHOOT,
|
||||
ENTITY_ENDERDRAGON_FIREBALL_EXPLODE,
|
||||
ENTITY_ENDEREYE_DEATH,
|
||||
ENTITY_ENDEREYE_LAUNCH,
|
||||
ENTITY_ENDERMEN_AMBIENT,
|
||||
ENTITY_ENDERMEN_DEATH,
|
||||
|
@ -264,6 +275,13 @@ public enum BuiltinSound implements Sound {
|
|||
ENTITY_HUSK_DEATH,
|
||||
ENTITY_HUSK_HURT,
|
||||
ENTITY_HUSK_STEP,
|
||||
ENTITY_ILLUSION_ILLAGER_AMBIENT,
|
||||
ENTITY_ILLUSION_ILLAGER_CAST_SPELL,
|
||||
ENTITY_ILLUSION_ILLAGER_DEATH,
|
||||
ENTITY_ILLUSION_ILLAGER_HURT,
|
||||
ENTITY_ILLUSION_ILLAGER_MIRROR_MOVE,
|
||||
ENTITY_ILLUSION_ILLAGER_PREPARE_BLINDNESS,
|
||||
ENTITY_ILLUSION_ILLAGER_PREPARE_MIRROR,
|
||||
ENTITY_IRONGOLEM_ATTACK,
|
||||
ENTITY_IRONGOLEM_DEATH,
|
||||
ENTITY_IRONGOLEM_HURT,
|
||||
|
@ -302,6 +320,39 @@ public enum BuiltinSound implements Sound {
|
|||
ENTITY_MULE_HURT,
|
||||
ENTITY_PAINTING_BREAK,
|
||||
ENTITY_PAINTING_PLACE,
|
||||
ENTITY_PARROT_AMBIENT,
|
||||
ENTITY_PARROT_DEATH,
|
||||
ENTITY_PARROT_EAT,
|
||||
ENTITY_PARROT_FLY,
|
||||
ENTITY_PARROT_HURT,
|
||||
ENTITY_PARROT_IMITATE_BLAZE,
|
||||
ENTITY_PARROT_IMITATE_CREEPER,
|
||||
ENTITY_PARROT_IMITATE_ELDER_GUARDIAN,
|
||||
ENTITY_PARROT_IMITATE_ENDERDRAGON,
|
||||
ENTITY_PARROT_IMITATE_ENDERMAN,
|
||||
ENTITY_PARROT_IMITATE_ENDERMITE,
|
||||
ENTITY_PARROT_IMITATE_EVOCATION_ILLAGER,
|
||||
ENTITY_PARROT_IMITATE_GHAST,
|
||||
ENTITY_PARROT_IMITATE_HUSK,
|
||||
ENTITY_PARROT_IMITATE_ILLUSION_ILLAGER,
|
||||
ENTITY_PARROT_IMITATE_MAGMACUBE,
|
||||
ENTITY_PARROT_IMITATE_POLAR_BEAR,
|
||||
ENTITY_PARROT_IMITATE_SHULKER,
|
||||
ENTITY_PARROT_IMITATE_SILVERFISH,
|
||||
ENTITY_PARROT_IMITATE_SKELETON,
|
||||
ENTITY_PARROT_IMITATE_SLIME,
|
||||
ENTITY_PARROT_IMITATE_SPIDER,
|
||||
ENTITY_PARROT_IMITATE_STRAY,
|
||||
ENTITY_PARROT_IMITATE_VEX,
|
||||
ENTITY_PARROT_IMITATE_VINDICATION_ILLAGER,
|
||||
ENTITY_PARROT_IMITATE_WITCH,
|
||||
ENTITY_PARROT_IMITATE_WITHER,
|
||||
ENTITY_PARROT_IMITATE_WITHER_SKELETON,
|
||||
ENTITY_PARROT_IMITATE_WOLF,
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE,
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN,
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER,
|
||||
ENTITY_PARROT_STEP,
|
||||
ENTITY_PIG_AMBIENT,
|
||||
ENTITY_PIG_DEATH,
|
||||
ENTITY_PIG_HURT,
|
||||
|
@ -318,6 +369,8 @@ public enum BuiltinSound implements Sound {
|
|||
ENTITY_PLAYER_BURP,
|
||||
ENTITY_PLAYER_DEATH,
|
||||
ENTITY_PLAYER_HURT,
|
||||
ENTITY_PLAYER_HURT_DROWN,
|
||||
ENTITY_PLAYER_HURT_ON_FIRE,
|
||||
ENTITY_PLAYER_LEVELUP,
|
||||
ENTITY_PLAYER_SMALL_FALL,
|
||||
ENTITY_PLAYER_SPLASH,
|
||||
|
@ -492,6 +545,9 @@ public enum BuiltinSound implements Sound {
|
|||
RECORD_WAIT,
|
||||
RECORD_WARD,
|
||||
UI_BUTTON_CLICK,
|
||||
UI_TOAST_IN,
|
||||
UI_TOAST_OUT,
|
||||
UI_TOAST_CHALLENGE_COMPLETE,
|
||||
WEATHER_RAIN,
|
||||
WEATHER_RAIN_ABOVE;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.github.steveice10.mc.protocol.data.message;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class KeybindMessage extends Message {
|
||||
private String keybind;
|
||||
|
||||
public KeybindMessage(String keybind) {
|
||||
this.keybind = keybind;
|
||||
}
|
||||
|
||||
public String getKeybind() {
|
||||
return this.keybind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return this.keybind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeybindMessage clone() {
|
||||
return (KeybindMessage) new KeybindMessage(this.getKeybind()).setStyle(this.getStyle().clone()).setExtra(this.getExtra());
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement toJson() {
|
||||
JsonElement e = super.toJson();
|
||||
if(e.isJsonObject()) {
|
||||
JsonObject json = e.getAsJsonObject();
|
||||
json.addProperty("keybind", this.keybind);
|
||||
return json;
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof KeybindMessage && super.equals(o) && this.keybind.equals(((KeybindMessage) o).keybind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() * 31 + keybind.hashCode();
|
||||
}
|
||||
}
|
|
@ -159,6 +159,8 @@ public abstract class Message implements Cloneable {
|
|||
}
|
||||
|
||||
msg = new TranslationMessage(json.get("translate").getAsString(), with);
|
||||
} else if (json.has("keybind")) {
|
||||
msg = new KeybindMessage(json.get("keybind").getAsString());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown message type in json: " + json.toString());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.client.window;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClientAdvancementTabPacket implements Packet {
|
||||
|
||||
private AdvancementTabAction action;
|
||||
private String tabId;
|
||||
|
||||
public ClientAdvancementTabPacket() {
|
||||
this.action = AdvancementTabAction.CLOSED_SCREEN;
|
||||
}
|
||||
|
||||
public ClientAdvancementTabPacket(String tabId) {
|
||||
this.action = AdvancementTabAction.OPENED_TAB;
|
||||
this.tabId = tabId;
|
||||
}
|
||||
|
||||
public String getTabId() {
|
||||
if (this.action != AdvancementTabAction.OPENED_TAB) {
|
||||
throw new IllegalStateException("tabId is only set if action is " + AdvancementTabAction.OPENED_TAB
|
||||
+ " but it was " + this.action);
|
||||
}
|
||||
return tabId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
switch (this.action = MagicValues.key(AdvancementTabAction.class, in.readVarInt())) {
|
||||
case CLOSED_SCREEN:
|
||||
break;
|
||||
case OPENED_TAB:
|
||||
this.tabId = in.readString();
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown advancement tab action: " + this.action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.action));
|
||||
switch (this.action) {
|
||||
case CLOSED_SCREEN:
|
||||
break;
|
||||
case OPENED_TAB:
|
||||
out.writeString(this.tabId);
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown advancement tab action: " + this.action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.client.window;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.CraftingBookDataType;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ClientCraftingBookDataPacket implements Packet {
|
||||
|
||||
private CraftingBookDataType type;
|
||||
private int recipeId;
|
||||
private boolean craftingBookOpen;
|
||||
private boolean filterActive;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ClientCraftingBookDataPacket() {
|
||||
}
|
||||
|
||||
public ClientCraftingBookDataPacket(int recipeId) {
|
||||
this.type = CraftingBookDataType.DISPLAYED_RECIPE;
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
|
||||
public ClientCraftingBookDataPacket(boolean craftingBookOpen, boolean filterActive) {
|
||||
this.type = CraftingBookDataType.CRAFTING_BOOK_STATUS;
|
||||
this.craftingBookOpen = craftingBookOpen;
|
||||
this.filterActive = filterActive;
|
||||
}
|
||||
|
||||
public CraftingBookDataType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
private void ensureType(CraftingBookDataType type, String what) {
|
||||
if (this.type != type) {
|
||||
throw new IllegalStateException(what + " is only set when type is " + type + " but it is " + this.type);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRecipeId() {
|
||||
ensureType(CraftingBookDataType.DISPLAYED_RECIPE, "recipeId");
|
||||
return recipeId;
|
||||
}
|
||||
|
||||
public boolean isCraftingBookOpen() {
|
||||
ensureType(CraftingBookDataType.CRAFTING_BOOK_STATUS, "craftingBookOpen");
|
||||
return craftingBookOpen;
|
||||
}
|
||||
|
||||
public boolean isFilterActive() {
|
||||
ensureType(CraftingBookDataType.CRAFTING_BOOK_STATUS, "filterActive");
|
||||
return filterActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
switch (this.type = MagicValues.key(CraftingBookDataType.class, in.readVarInt())) {
|
||||
case DISPLAYED_RECIPE:
|
||||
this.recipeId = in.readInt();
|
||||
break;
|
||||
case CRAFTING_BOOK_STATUS:
|
||||
this.craftingBookOpen = in.readBoolean();
|
||||
this.filterActive = in.readBoolean();
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown crafting book data type: " + this.type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.type));
|
||||
switch (this.type) {
|
||||
case DISPLAYED_RECIPE:
|
||||
out.writeInt(this.recipeId);
|
||||
break;
|
||||
case CRAFTING_BOOK_STATUS:
|
||||
out.writeBoolean(this.craftingBookOpen);
|
||||
out.writeBoolean(this.filterActive);
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown crafting book data type: " + this.type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.client.window;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.PrepareCraftingGridEntry;
|
||||
import com.github.steveice10.mc.protocol.util.NetUtil;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientPrepareCraftingGridPacket implements Packet {
|
||||
|
||||
private int windowId;
|
||||
private int actionId;
|
||||
private List<PrepareCraftingGridEntry> returnEntries;
|
||||
private List<PrepareCraftingGridEntry> prepareEntries;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ClientPrepareCraftingGridPacket() {
|
||||
}
|
||||
|
||||
public ClientPrepareCraftingGridPacket(int windowId, int actionId, List<PrepareCraftingGridEntry> returnEntries,
|
||||
List<PrepareCraftingGridEntry> prepareEntries) {
|
||||
this.windowId = windowId;
|
||||
this.actionId = actionId;
|
||||
this.returnEntries = returnEntries;
|
||||
this.prepareEntries = prepareEntries;
|
||||
}
|
||||
|
||||
public int getWindowId() {
|
||||
return this.windowId;
|
||||
}
|
||||
|
||||
public int getActionId() {
|
||||
return this.actionId;
|
||||
}
|
||||
|
||||
public List<PrepareCraftingGridEntry> getReturnEntries() {
|
||||
return this.returnEntries;
|
||||
}
|
||||
|
||||
public List<PrepareCraftingGridEntry> getPrepareEntries() {
|
||||
return this.prepareEntries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
this.windowId = in.readByte();
|
||||
this.actionId = in.readShort();
|
||||
this.returnEntries = readEntries(in);
|
||||
this.prepareEntries = readEntries(in);
|
||||
}
|
||||
|
||||
private static List<PrepareCraftingGridEntry> readEntries(NetInput in) throws IOException {
|
||||
List<PrepareCraftingGridEntry> entries = new ArrayList<>();
|
||||
for (int i = in.readShort(); i > 0; i--) {
|
||||
ItemStack item = NetUtil.readItem(in);
|
||||
byte craftingGridSlot = in.readByte();
|
||||
byte playerInventorySlot = in.readByte();
|
||||
entries.add(new PrepareCraftingGridEntry(item, craftingGridSlot, playerInventorySlot));
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeByte(this.windowId);
|
||||
out.writeShort(actionId);
|
||||
writeEntries(out, this.returnEntries);
|
||||
writeEntries(out, this.prepareEntries);
|
||||
}
|
||||
|
||||
private static void writeEntries(NetOutput out, List<PrepareCraftingGridEntry> entries) throws IOException {
|
||||
out.writeShort(entries.size());
|
||||
for (PrepareCraftingGridEntry entry : entries) {
|
||||
NetUtil.writeItem(out, entry.getItem());
|
||||
out.writeByte(entry.getCraftingGridSlot());
|
||||
out.writeByte(entry.getPlayerInventorySlot());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
||||
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ServerAdvancementTabPacket implements Packet {
|
||||
private String tabId;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ServerAdvancementTabPacket() {
|
||||
}
|
||||
|
||||
public ServerAdvancementTabPacket(String tabId) {
|
||||
this.tabId = tabId;
|
||||
}
|
||||
|
||||
public String getTabId() {
|
||||
return this.tabId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
if (in.readBoolean()) {
|
||||
this.tabId = in.readString();
|
||||
} else {
|
||||
this.tabId = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
if (this.tabId != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeString(this.tabId);
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement.DisplayData;
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement.DisplayData.FrameType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.util.NetUtil;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ServerAdvancementsPacket implements Packet {
|
||||
private boolean reset;
|
||||
private List<Advancement> advancements;
|
||||
private List<String> removedAdvancements;
|
||||
private Map<String, Map<String, Long>> progress;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ServerAdvancementsPacket() {
|
||||
}
|
||||
|
||||
public ServerAdvancementsPacket(boolean reset, List<Advancement> advancements, List<String> removedAdvancements,
|
||||
Map<String, Map<String, Long>> progress) {
|
||||
this.reset = reset;
|
||||
this.advancements = advancements;
|
||||
this.removedAdvancements = removedAdvancements;
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public boolean doesReset() {
|
||||
return this.reset;
|
||||
}
|
||||
|
||||
public List<Advancement> getAdvancements() {
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
public List<String> getRemovedAdvancements() {
|
||||
return this.removedAdvancements;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, Long>> getProgress() {
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
public Map<String, Long> getProgress(String advancementId) {
|
||||
return getProgress().get(advancementId);
|
||||
}
|
||||
|
||||
public Long getAchievedDate(String advancementId, String criterionId) {
|
||||
return getProgress(advancementId).get(criterionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
this.reset = in.readBoolean();
|
||||
|
||||
this.advancements = new ArrayList<>();
|
||||
for (int i = in.readVarInt(); i > 0; i--) {
|
||||
String id = in.readString();
|
||||
String parentId = in.readBoolean() ? in.readString() : null;
|
||||
DisplayData displayData = null;
|
||||
if (in.readBoolean()) {
|
||||
Message title = Message.fromString(in.readString());
|
||||
Message description = Message.fromString(in.readString());
|
||||
ItemStack icon = NetUtil.readItem(in);
|
||||
FrameType frameType = MagicValues.key(FrameType.class, in.readVarInt());
|
||||
int flags = in.readInt();
|
||||
boolean hasBackgroundTexture = (flags & 0x1) != 0;
|
||||
boolean showToast = (flags & 0x2) != 0;
|
||||
boolean hidden = (flags & 0x4) != 0;
|
||||
String backgroundTexture = hasBackgroundTexture ? in.readString() : null;
|
||||
float posX = in.readFloat(), posY = in.readFloat();
|
||||
displayData = new DisplayData(title, description, icon, frameType, showToast, hidden, posX, posY, backgroundTexture);
|
||||
}
|
||||
|
||||
List<String> criteria = new ArrayList<>();
|
||||
for (int j = in.readVarInt(); j > 0; j--) {
|
||||
criteria.add(in.readString());
|
||||
}
|
||||
|
||||
List<List<String>> requirements = new ArrayList<>();
|
||||
for (int j = in.readVarInt(); j > 0; j--) {
|
||||
List<String> requirement = new ArrayList<>();
|
||||
for (int k = in.readVarInt(); k > 0; k--) {
|
||||
requirement.add(in.readString());
|
||||
}
|
||||
requirements.add(requirement);
|
||||
}
|
||||
this.advancements.add(new Advancement(id, parentId, criteria, requirements, displayData));
|
||||
}
|
||||
|
||||
this.removedAdvancements = new ArrayList<>();
|
||||
for (int i = in.readVarInt(); i > 0; i--) {
|
||||
this.removedAdvancements.add(in.readString());
|
||||
}
|
||||
|
||||
this.progress = new HashMap<>();
|
||||
for (int i = in.readVarInt(); i > 0; i--) {
|
||||
String advancementId = in.readString();
|
||||
Map<String, Long> advancementProgress = new HashMap<>();
|
||||
for (int j = in.readVarInt(); j > 0; j--) {
|
||||
String criterionId = in.readString();
|
||||
Long achievedDate = in.readBoolean() ? in.readLong() : null;
|
||||
advancementProgress.put(criterionId, achievedDate);
|
||||
}
|
||||
this.progress.put(advancementId, advancementProgress);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeBoolean(this.reset);
|
||||
|
||||
out.writeVarInt(this.advancements.size());
|
||||
for (Advancement advancement : this.advancements) {
|
||||
out.writeString(advancement.getId());
|
||||
if (advancement.getParentId() != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeString(advancement.getParentId());
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
DisplayData displayData = advancement.getDisplayData();
|
||||
if (displayData != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeString(displayData.getTitle().toJsonString());
|
||||
out.writeString(displayData.getDescription().toJsonString());
|
||||
NetUtil.writeItem(out, displayData.getIcon());
|
||||
out.writeVarInt(MagicValues.value(Integer.class, displayData.getFrameType()));
|
||||
String backgroundTexture = displayData.getBackgroundTexture();
|
||||
int flags = 0;
|
||||
if (backgroundTexture != null) flags |= 0x1;
|
||||
if (displayData.doesShowToast()) flags |= 0x2;
|
||||
if (displayData.isHidden()) flags |= 0x4;
|
||||
out.writeInt(flags);
|
||||
if (backgroundTexture != null) {
|
||||
out.writeString(backgroundTexture);
|
||||
}
|
||||
out.writeFloat(displayData.getPosX());
|
||||
out.writeFloat(displayData.getPosY());
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
|
||||
out.writeVarInt(advancement.getCriteria().size());
|
||||
for (String criterion : advancement.getCriteria()) {
|
||||
out.writeString(criterion);
|
||||
}
|
||||
|
||||
out.writeVarInt(advancement.getRequirements().size());
|
||||
for (List<String> requirement : advancement.getRequirements()) {
|
||||
out.writeVarInt(requirement.size());
|
||||
for (String criterion : requirement) {
|
||||
out.writeString(criterion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.writeVarInt(this.removedAdvancements.size());
|
||||
for (String id : this.removedAdvancements) {
|
||||
out.writeString(id);
|
||||
}
|
||||
|
||||
out.writeVarInt(this.progress.size());
|
||||
for (Map.Entry<String, Map<String, Long>> advancement : this.progress.entrySet()) {
|
||||
out.writeString(advancement.getKey());
|
||||
Map<String, Long> advancementProgress = advancement.getValue();
|
||||
out.writeVarInt(advancementProgress.size());
|
||||
for (Map.Entry<String, Long> criterion : advancementProgress.entrySet()) {
|
||||
out.writeString(criterion.getKey());
|
||||
if (criterion.getValue() != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeLong(criterion.getValue());
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.UnlockRecipesAction;
|
||||
import com.github.steveice10.mc.protocol.util.ReflectionToString;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUnlockRecipesPacket implements Packet {
|
||||
private UnlockRecipesAction action;
|
||||
|
||||
private List<Integer> recipes;
|
||||
private List<Integer> alreadyKnownRecipes;
|
||||
|
||||
private boolean openCraftingBook;
|
||||
private boolean activateFiltering;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ServerUnlockRecipesPacket() {
|
||||
}
|
||||
|
||||
private ServerUnlockRecipesPacket(boolean openCraftingBook, boolean activateFiltering, List<Integer> recipes) {
|
||||
this.openCraftingBook = openCraftingBook;
|
||||
this.activateFiltering = activateFiltering;
|
||||
this.recipes = recipes;
|
||||
}
|
||||
|
||||
public ServerUnlockRecipesPacket(boolean openCraftingBook, boolean activateFiltering, List<Integer> recipes, List<Integer> alreadyKnownRecipes) {
|
||||
this(openCraftingBook, activateFiltering, recipes);
|
||||
this.action = UnlockRecipesAction.INIT;
|
||||
this.alreadyKnownRecipes = alreadyKnownRecipes;
|
||||
}
|
||||
|
||||
public ServerUnlockRecipesPacket(boolean openCraftingBook, boolean activateFiltering, List<Integer> recipes, UnlockRecipesAction action) {
|
||||
this(openCraftingBook, activateFiltering, recipes);
|
||||
if (action != UnlockRecipesAction.ADD && action != UnlockRecipesAction.REMOVE) {
|
||||
throw new IllegalArgumentException("action must be ADD or REMOVE");
|
||||
}
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public UnlockRecipesAction getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public List<Integer> getRecipes() {
|
||||
return this.recipes;
|
||||
}
|
||||
|
||||
public List<Integer> getAlreadyKnownRecipes() {
|
||||
if (this.action != UnlockRecipesAction.INIT) {
|
||||
throw new IllegalStateException("alreadyKnownRecipes is only set if action is " + UnlockRecipesAction.INIT
|
||||
+ " but it was " + this.action);
|
||||
}
|
||||
return this.alreadyKnownRecipes;
|
||||
}
|
||||
|
||||
public boolean getOpenCraftingBook() {
|
||||
return this.openCraftingBook;
|
||||
}
|
||||
|
||||
public boolean getActivateFiltering() {
|
||||
return this.activateFiltering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
this.action = MagicValues.key(UnlockRecipesAction.class, in.readVarInt());
|
||||
|
||||
this.openCraftingBook = in.readBoolean();
|
||||
this.activateFiltering = in.readBoolean();
|
||||
|
||||
if (this.action == UnlockRecipesAction.INIT) {
|
||||
int size = in.readVarInt();
|
||||
this.alreadyKnownRecipes = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
this.alreadyKnownRecipes.add(in.readVarInt());
|
||||
}
|
||||
}
|
||||
|
||||
int size = in.readVarInt();
|
||||
this.recipes = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
this.recipes.add(in.readVarInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.action));
|
||||
|
||||
out.writeBoolean(this.openCraftingBook);
|
||||
out.writeBoolean(this.activateFiltering);
|
||||
|
||||
if (this.action == UnlockRecipesAction.INIT) {
|
||||
out.writeVarInt(this.alreadyKnownRecipes.size());
|
||||
for (Integer recipeId : this.alreadyKnownRecipes) {
|
||||
out.writeVarInt(recipeId);
|
||||
}
|
||||
}
|
||||
|
||||
out.writeVarInt(this.recipes.size());
|
||||
for (Integer recipeId : this.recipes) {
|
||||
out.writeVarInt(recipeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPriority() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToString.toString(this);
|
||||
}
|
||||
}
|
|
@ -164,6 +164,9 @@ public class NetUtil {
|
|||
case BLOCK_STATE:
|
||||
value = readBlockState(in);
|
||||
break;
|
||||
case NBT_TAG:
|
||||
value = readNBT(in);
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown metadata type id: " + typeId);
|
||||
}
|
||||
|
@ -226,6 +229,9 @@ public class NetUtil {
|
|||
case BLOCK_STATE:
|
||||
writeBlockState(out, (BlockState) meta.getValue());
|
||||
break;
|
||||
case NBT_TAG:
|
||||
writeNBT(out, (CompoundTag) meta.getValue());
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Unknown metadata type: " + meta.getType());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue