diff --git a/pom.xml b/pom.xml
index 2c3a65d4..3fbbe584 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.github.steveice10
mcprotocollib
- 1.11.2-3-SNAPSHOT
+ 1.12-SNAPSHOT
jar
MCProtocolLib
diff --git a/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java b/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java
index 04ee8409..838d25c8 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftConstants.java
@@ -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";
diff --git a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java
index 2c7a1e21..c7c31033 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java
@@ -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.ServerAdvancementProgressPacket;
+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, ServerAdvancementProgressPacket.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, ClientPlayerPositionPacket.class);
+ this.registerOutgoing(0x0E, ClientPlayerPositionRotationPacket.class);
+ this.registerOutgoing(0x0F, ClientPlayerRotationPacket.class);
+ this.registerOutgoing(0x10, ClientPlayerMovementPacket.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, ClientPlayerPositionPacket.class);
+ this.registerIncoming(0x0E, ClientPlayerPositionRotationPacket.class);
+ this.registerIncoming(0x0F, ClientPlayerRotationPacket.class);
+ this.registerIncoming(0x10, ClientPlayerMovementPacket.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, ServerAdvancementProgressPacket.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) {
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java
index 6d445ba3..87842810 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/MagicValues.java
@@ -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;
@@ -140,13 +144,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);
@@ -538,6 +542,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 +674,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 +789,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 +813,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);
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/ClientRequest.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/ClientRequest.java
index 1e2ef0ba..ae4e6e28 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/data/game/ClientRequest.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/ClientRequest.java
@@ -2,6 +2,5 @@ package com.github.steveice10.mc.protocol.data.game;
public enum ClientRequest {
RESPAWN,
- STATS,
- OPEN_INVENTORY;
+ STATS;
}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/UnlockRecipesAction.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/UnlockRecipesAction.java
new file mode 100644
index 00000000..d2ab5bc0
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/UnlockRecipesAction.java
@@ -0,0 +1,7 @@
+package com.github.steveice10.mc.protocol.data.game;
+
+public enum UnlockRecipesAction {
+ INIT,
+ ADD,
+ REMOVE;
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java
new file mode 100644
index 00000000..cf20cb41
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/advancement/Advancement.java
@@ -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 criteria;
+ private List> requirements;
+
+ public Advancement(String id, String parentId, List criteria, List> requirements) {
+ this.id = id;
+ this.parentId = parentId;
+ this.criteria = criteria;
+ this.requirements = requirements;
+ }
+
+ public Advancement(String id, String parentId, List criteria, List> 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 getCriteria() {
+ return criteria;
+ }
+
+ public List> 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);
+ }
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java
index 95b035c5..9ab15fd9 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/entity/metadata/MetadataType.java
@@ -13,5 +13,6 @@ public enum MetadataType {
OPTIONAL_POSITION,
BLOCK_FACE,
OPTIONAL_UUID,
- BLOCK_STATE;
+ BLOCK_STATE,
+ NBT_TAG;
}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/window/AdvancementTabAction.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/window/AdvancementTabAction.java
new file mode 100644
index 00000000..16914524
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/window/AdvancementTabAction.java
@@ -0,0 +1,6 @@
+package com.github.steveice10.mc.protocol.data.game.window;
+
+public enum AdvancementTabAction {
+ OPENED_TAB,
+ CLOSED_SCREEN;
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/window/CraftingBookDataType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/window/CraftingBookDataType.java
new file mode 100644
index 00000000..196583b6
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/window/CraftingBookDataType.java
@@ -0,0 +1,6 @@
+package com.github.steveice10.mc.protocol.data.game.window;
+
+public enum CraftingBookDataType {
+ DISPLAYED_RECIPE,
+ CRAFTING_BOOK_STATUS;
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/window/PrepareCraftingGridEntry.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/window/PrepareCraftingGridEntry.java
new file mode 100644
index 00000000..ba02a15e
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/window/PrepareCraftingGridEntry.java
@@ -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);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java
index 92750a03..c2d2cc68 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/UpdatedTileType.java
@@ -10,5 +10,6 @@ public enum UpdatedTileType {
STRUCTURE_BLOCK,
END_GATEWAY,
SIGN,
- SHULKER_BOX;
+ SHULKER_BOX,
+ BED;
}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/value/NoteBlockValueType.java b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/value/NoteBlockValueType.java
index 34971d19..7790d920 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/value/NoteBlockValueType.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/game/world/block/value/NoteBlockValueType.java
@@ -5,5 +5,10 @@ public enum NoteBlockValueType implements BlockValueType {
DOUBLE_BASS,
SNARE_DRUM,
HI_HAT,
- BASS_DRUM;
+ BASS_DRUM,
+ FLUTE,
+ BELL,
+ GUITAR,
+ CHIME,
+ XYLOPHONE;
}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/message/KeybindMessage.java b/src/main/java/com/github/steveice10/mc/protocol/data/message/KeybindMessage.java
new file mode 100644
index 00000000..0f5f13b3
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/message/KeybindMessage.java
@@ -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();
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/data/message/Message.java b/src/main/java/com/github/steveice10/mc/protocol/data/message/Message.java
index cf43ab61..aa06d375 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/data/message/Message.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/data/message/Message.java
@@ -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());
}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientAdvancementTabPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientAdvancementTabPacket.java
new file mode 100644
index 00000000..42aaf737
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientAdvancementTabPacket.java
@@ -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);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookDataPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookDataPacket.java
new file mode 100644
index 00000000..63d2bf39
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientCraftingBookDataPacket.java
@@ -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);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientPrepareCraftingGridPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientPrepareCraftingGridPacket.java
new file mode 100644
index 00000000..c3695284
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientPrepareCraftingGridPacket.java
@@ -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 returnEntries;
+ private List prepareEntries;
+
+ @SuppressWarnings("unused")
+ private ClientPrepareCraftingGridPacket() {
+ }
+
+ public ClientPrepareCraftingGridPacket(int windowId, int actionId, List returnEntries,
+ List 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 getReturnEntries() {
+ return this.returnEntries;
+ }
+
+ public List 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 readEntries(NetInput in) throws IOException {
+ List 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 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);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerAdvancementProgressPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerAdvancementProgressPacket.java
new file mode 100644
index 00000000..18eee60c
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerAdvancementProgressPacket.java
@@ -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 ServerAdvancementProgressPacket implements Packet {
+ private String id;
+
+ @SuppressWarnings("unused")
+ private ServerAdvancementProgressPacket() {
+ }
+
+ public ServerAdvancementProgressPacket(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ @Override
+ public void read(NetInput in) throws IOException {
+ if (in.readBoolean()) {
+ this.id = in.readString();
+ } else {
+ this.id = null;
+ }
+ }
+
+ @Override
+ public void write(NetOutput out) throws IOException {
+ if (this.id != null) {
+ out.writeBoolean(true);
+ out.writeString(this.id);
+ } else {
+ out.writeBoolean(false);
+ }
+ }
+
+ @Override
+ public boolean isPriority() {
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return ReflectionToString.toString(this);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerAdvancementsPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerAdvancementsPacket.java
new file mode 100644
index 00000000..62f69f8b
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerAdvancementsPacket.java
@@ -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 advancements;
+ private List removedAdvancements;
+ private Map> progress;
+
+ @SuppressWarnings("unused")
+ private ServerAdvancementsPacket() {
+ }
+
+ public ServerAdvancementsPacket(boolean reset, List advancements, List removedAdvancements,
+ Map> progress) {
+ this.reset = reset;
+ this.advancements = advancements;
+ this.removedAdvancements = removedAdvancements;
+ this.progress = progress;
+ }
+
+ public boolean doesReset() {
+ return this.reset;
+ }
+
+ public List getAdvancements() {
+ return this.advancements;
+ }
+
+ public List getRemovedAdvancements() {
+ return this.removedAdvancements;
+ }
+
+ public Map> getProgress() {
+ return this.progress;
+ }
+
+ public Map 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 criteria = new ArrayList<>();
+ for (int j = in.readVarInt(); j > 0; j--) {
+ criteria.add(in.readString());
+ }
+
+ List> requirements = new ArrayList<>();
+ for (int j = in.readVarInt(); j > 0; j--) {
+ List 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 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 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> advancement : this.progress.entrySet()) {
+ out.writeString(advancement.getKey());
+ Map advancementProgress = advancement.getValue();
+ out.writeVarInt(advancementProgress.size());
+ for (Map.Entry 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);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerUnlockRecipesPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerUnlockRecipesPacket.java
new file mode 100644
index 00000000..169f6691
--- /dev/null
+++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/ServerUnlockRecipesPacket.java
@@ -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 recipes;
+ private List alreadyKnownRecipes;
+
+ private boolean openCraftingBook;
+ private boolean activateFiltering;
+
+ @SuppressWarnings("unused")
+ private ServerUnlockRecipesPacket() {
+ }
+
+ private ServerUnlockRecipesPacket(boolean openCraftingBook, boolean activateFiltering, List recipes) {
+ this.openCraftingBook = openCraftingBook;
+ this.activateFiltering = activateFiltering;
+ this.recipes = recipes;
+ }
+
+ public ServerUnlockRecipesPacket(boolean openCraftingBook, boolean activateFiltering, List recipes, List alreadyKnownRecipes) {
+ this(openCraftingBook, activateFiltering, recipes);
+ this.action = UnlockRecipesAction.INIT;
+ this.alreadyKnownRecipes = alreadyKnownRecipes;
+ }
+
+ public ServerUnlockRecipesPacket(boolean openCraftingBook, boolean activateFiltering, List 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 getRecipes() {
+ return this.recipes;
+ }
+
+ public List 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.alreadyKnownRecipes = new ArrayList<>(size);
+ for (int i = 0; i < size; i++) {
+ this.alreadyKnownRecipes.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);
+ }
+}
diff --git a/src/main/java/com/github/steveice10/mc/protocol/util/NetUtil.java b/src/main/java/com/github/steveice10/mc/protocol/util/NetUtil.java
index cfb4d268..d2045ba8 100644
--- a/src/main/java/com/github/steveice10/mc/protocol/util/NetUtil.java
+++ b/src/main/java/com/github/steveice10/mc/protocol/util/NetUtil.java
@@ -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,8 @@ public class NetUtil {
case BLOCK_STATE:
writeBlockState(out, (BlockState) meta.getValue());
break;
+ case NBT_TAG:
+ writeNBT(out, (CompoundTag) meta.getValue());
default:
throw new IOException("Unknown metadata type: " + meta.getType());
}