From e7ee69fb3efb84a0136756dda1a5975d6185ab79 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 4 Aug 2017 08:46:46 +0200 Subject: [PATCH] Update to MC 1.12.1 --- pom.xml | 2 +- .../mc/protocol/MinecraftConstants.java | 4 +- .../mc/protocol/MinecraftProtocol.java | 219 +++++++++--------- .../game/window/PrepareCraftingGridEntry.java | 50 ---- .../ClientPrepareCraftingGridPacket.java | 60 ++--- .../ServerPreparedCraftingGridPacket.java | 53 +++++ 6 files changed, 180 insertions(+), 208 deletions(-) delete mode 100644 src/main/java/com/github/steveice10/mc/protocol/data/game/window/PrepareCraftingGridEntry.java create mode 100644 src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/window/ServerPreparedCraftingGridPacket.java diff --git a/pom.xml b/pom.xml index e9210e10..8cc50130 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.steveice10 mcprotocollib - 1.12-1 + 1.12.1-1-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 838d25c8..68ac9fd2 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.12"; - public static final int PROTOCOL_VERSION = 335; + public static final String GAME_VERSION = "1.12.1"; + public static final int PROTOCOL_VERSION = 338; // 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 5bbc42cd..419742c2 100644 --- a/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java +++ b/src/main/java/com/github/steveice10/mc/protocol/MinecraftProtocol.java @@ -87,6 +87,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.Serve import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerCloseWindowPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerPreparedCraftingGridPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerWindowPropertyPacket; @@ -363,62 +364,63 @@ public class MinecraftProtocol extends PacketProtocol { this.registerIncoming(0x28, ServerEntityRotationPacket.class); this.registerIncoming(0x29, ServerVehicleMovePacket.class); this.registerIncoming(0x2A, ServerOpenTileEntityEditorPacket.class); - this.registerIncoming(0x2B, ServerPlayerAbilitiesPacket.class); - this.registerIncoming(0x2C, ServerCombatPacket.class); - this.registerIncoming(0x2D, ServerPlayerListEntryPacket.class); - this.registerIncoming(0x2E, ServerPlayerPositionRotationPacket.class); - this.registerIncoming(0x2F, ServerPlayerUseBedPacket.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.registerIncoming(0x2B, ServerPreparedCraftingGridPacket.class); + this.registerIncoming(0x2C, ServerPlayerAbilitiesPacket.class); + this.registerIncoming(0x2D, ServerCombatPacket.class); + this.registerIncoming(0x2E, ServerPlayerListEntryPacket.class); + this.registerIncoming(0x2F, ServerPlayerPositionRotationPacket.class); + this.registerIncoming(0x30, ServerPlayerUseBedPacket.class); + this.registerIncoming(0x31, ServerUnlockRecipesPacket.class); + this.registerIncoming(0x32, ServerEntityDestroyPacket.class); + this.registerIncoming(0x33, ServerEntityRemoveEffectPacket.class); + this.registerIncoming(0x34, ServerResourcePackSendPacket.class); + this.registerIncoming(0x35, ServerRespawnPacket.class); + this.registerIncoming(0x36, ServerEntityHeadLookPacket.class); + this.registerIncoming(0x37, ServerAdvancementTabPacket.class); + this.registerIncoming(0x38, ServerWorldBorderPacket.class); + this.registerIncoming(0x39, ServerSwitchCameraPacket.class); + this.registerIncoming(0x3A, ServerPlayerChangeHeldItemPacket.class); + this.registerIncoming(0x3B, ServerDisplayScoreboardPacket.class); + this.registerIncoming(0x3C, ServerEntityMetadataPacket.class); + this.registerIncoming(0x3D, ServerEntityAttachPacket.class); + this.registerIncoming(0x3E, ServerEntityVelocityPacket.class); + this.registerIncoming(0x3F, ServerEntityEquipmentPacket.class); + this.registerIncoming(0x40, ServerPlayerSetExperiencePacket.class); + this.registerIncoming(0x41, ServerPlayerHealthPacket.class); + this.registerIncoming(0x42, ServerScoreboardObjectivePacket.class); + this.registerIncoming(0x43, ServerEntitySetPassengersPacket.class); + this.registerIncoming(0x44, ServerTeamPacket.class); + this.registerIncoming(0x45, ServerUpdateScorePacket.class); + this.registerIncoming(0x46, ServerSpawnPositionPacket.class); + this.registerIncoming(0x47, ServerUpdateTimePacket.class); + this.registerIncoming(0x48, ServerTitlePacket.class); + this.registerIncoming(0x49, ServerPlayBuiltinSoundPacket.class); + this.registerIncoming(0x4A, ServerPlayerListDataPacket.class); + this.registerIncoming(0x4B, ServerEntityCollectItemPacket.class); + this.registerIncoming(0x4C, ServerEntityTeleportPacket.class); + this.registerIncoming(0x4D, ServerAdvancementsPacket.class); + this.registerIncoming(0x4E, ServerEntityPropertiesPacket.class); + this.registerIncoming(0x4F, ServerEntityEffectPacket.class); this.registerOutgoing(0x00, ClientTeleportConfirmPacket.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(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, ClientPlayerMovementPacket.class); + this.registerOutgoing(0x0D, ClientPlayerPositionPacket.class); + this.registerOutgoing(0x0E, ClientPlayerPositionRotationPacket.class); + this.registerOutgoing(0x0F, ClientPlayerRotationPacket.class); + this.registerOutgoing(0x10, ClientVehicleMovePacket.class); + this.registerOutgoing(0x11, ClientSteerBoatPacket.class); + this.registerOutgoing(0x12, ClientPrepareCraftingGridPacket.class); this.registerOutgoing(0x13, ClientPlayerAbilitiesPacket.class); this.registerOutgoing(0x14, ClientPlayerActionPacket.class); this.registerOutgoing(0x15, ClientPlayerStatePacket.class); @@ -437,24 +439,24 @@ public class MinecraftProtocol extends PacketProtocol { private void initServerGame(Session session) { this.registerIncoming(0x00, ClientTeleportConfirmPacket.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(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, ClientPlayerMovementPacket.class); + this.registerIncoming(0x0D, ClientPlayerPositionPacket.class); + this.registerIncoming(0x0E, ClientPlayerPositionRotationPacket.class); + this.registerIncoming(0x0F, ClientPlayerRotationPacket.class); + this.registerIncoming(0x10, ClientVehicleMovePacket.class); + this.registerIncoming(0x11, ClientSteerBoatPacket.class); + this.registerIncoming(0x12, ClientPrepareCraftingGridPacket.class); this.registerIncoming(0x13, ClientPlayerAbilitiesPacket.class); this.registerIncoming(0x14, ClientPlayerActionPacket.class); this.registerIncoming(0x15, ClientPlayerStatePacket.class); @@ -513,42 +515,43 @@ public class MinecraftProtocol extends PacketProtocol { this.registerOutgoing(0x28, ServerEntityRotationPacket.class); this.registerOutgoing(0x29, ServerVehicleMovePacket.class); this.registerOutgoing(0x2A, ServerOpenTileEntityEditorPacket.class); - this.registerOutgoing(0x2B, ServerPlayerAbilitiesPacket.class); - this.registerOutgoing(0x2C, ServerCombatPacket.class); - this.registerOutgoing(0x2D, ServerPlayerListEntryPacket.class); - this.registerOutgoing(0x2E, ServerPlayerPositionRotationPacket.class); - this.registerOutgoing(0x2F, ServerPlayerUseBedPacket.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); + this.registerOutgoing(0x2B, ServerPreparedCraftingGridPacket.class); + this.registerOutgoing(0x2C, ServerPlayerAbilitiesPacket.class); + this.registerOutgoing(0x2D, ServerCombatPacket.class); + this.registerOutgoing(0x2E, ServerPlayerListEntryPacket.class); + this.registerOutgoing(0x2F, ServerPlayerPositionRotationPacket.class); + this.registerOutgoing(0x30, ServerPlayerUseBedPacket.class); + this.registerOutgoing(0x31, ServerUnlockRecipesPacket.class); + this.registerOutgoing(0x32, ServerEntityDestroyPacket.class); + this.registerOutgoing(0x33, ServerEntityRemoveEffectPacket.class); + this.registerOutgoing(0x34, ServerResourcePackSendPacket.class); + this.registerOutgoing(0x35, ServerRespawnPacket.class); + this.registerOutgoing(0x36, ServerEntityHeadLookPacket.class); + this.registerOutgoing(0x37, ServerAdvancementTabPacket.class); + this.registerOutgoing(0x38, ServerWorldBorderPacket.class); + this.registerOutgoing(0x39, ServerSwitchCameraPacket.class); + this.registerOutgoing(0x3A, ServerPlayerChangeHeldItemPacket.class); + this.registerOutgoing(0x3B, ServerDisplayScoreboardPacket.class); + this.registerOutgoing(0x3C, ServerEntityMetadataPacket.class); + this.registerOutgoing(0x3D, ServerEntityAttachPacket.class); + this.registerOutgoing(0x3E, ServerEntityVelocityPacket.class); + this.registerOutgoing(0x3F, ServerEntityEquipmentPacket.class); + this.registerOutgoing(0x40, ServerPlayerSetExperiencePacket.class); + this.registerOutgoing(0x41, ServerPlayerHealthPacket.class); + this.registerOutgoing(0x42, ServerScoreboardObjectivePacket.class); + this.registerOutgoing(0x43, ServerEntitySetPassengersPacket.class); + this.registerOutgoing(0x44, ServerTeamPacket.class); + this.registerOutgoing(0x45, ServerUpdateScorePacket.class); + this.registerOutgoing(0x46, ServerSpawnPositionPacket.class); + this.registerOutgoing(0x47, ServerUpdateTimePacket.class); + this.registerOutgoing(0x48, ServerTitlePacket.class); + this.registerOutgoing(0x49, ServerPlayBuiltinSoundPacket.class); + this.registerOutgoing(0x4A, ServerPlayerListDataPacket.class); + this.registerOutgoing(0x4B, ServerEntityCollectItemPacket.class); + this.registerOutgoing(0x4C, ServerEntityTeleportPacket.class); + this.registerOutgoing(0x4D, ServerAdvancementsPacket.class); + this.registerOutgoing(0x4E, ServerEntityPropertiesPacket.class); + this.registerOutgoing(0x4F, ServerEntityEffectPacket.class); } private void initClientStatus(Session session) { 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 deleted file mode 100644 index ba02a15e..00000000 --- a/src/main/java/com/github/steveice10/mc/protocol/data/game/window/PrepareCraftingGridEntry.java +++ /dev/null @@ -1,50 +0,0 @@ -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/packet/ingame/client/window/ClientPrepareCraftingGridPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/client/window/ClientPrepareCraftingGridPacket.java index c3695284..c4688905 100644 --- 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 @@ -1,86 +1,52 @@ 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; + private int recipeId; + private boolean makeAll; @SuppressWarnings("unused") private ClientPrepareCraftingGridPacket() { } - public ClientPrepareCraftingGridPacket(int windowId, int actionId, List returnEntries, - List prepareEntries) { + public ClientPrepareCraftingGridPacket(int windowId, int recipeId, boolean makeAll) { this.windowId = windowId; - this.actionId = actionId; - this.returnEntries = returnEntries; - this.prepareEntries = prepareEntries; + this.recipeId = recipeId; + this.makeAll = makeAll; } public int getWindowId() { return this.windowId; } - public int getActionId() { - return this.actionId; + public int getRecipeId() { + return this.recipeId; } - public List getReturnEntries() { - return this.returnEntries; - } - - public List getPrepareEntries() { - return this.prepareEntries; + public boolean doesMakeAll() { + return makeAll; } @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; + this.recipeId = in.readVarInt(); + this.makeAll = in.readBoolean(); } @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()); - } + out.writeVarInt(this.recipeId); + out.writeBoolean(this.makeAll); } @Override diff --git a/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/window/ServerPreparedCraftingGridPacket.java b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/window/ServerPreparedCraftingGridPacket.java new file mode 100644 index 00000000..c9fb0f3f --- /dev/null +++ b/src/main/java/com/github/steveice10/mc/protocol/packet/ingame/server/window/ServerPreparedCraftingGridPacket.java @@ -0,0 +1,53 @@ +package com.github.steveice10.mc.protocol.packet.ingame.server.window; + +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 ServerPreparedCraftingGridPacket implements Packet { + + private int windowId; + private int recipeId; + + @SuppressWarnings("unused") + private ServerPreparedCraftingGridPacket() { + } + + public ServerPreparedCraftingGridPacket(int windowId, int recipeId) { + this.windowId = windowId; + this.recipeId = recipeId; + } + + public int getWindowId() { + return this.windowId; + } + + public int getRecipeId() { + return this.recipeId; + } + + @Override + public void read(NetInput in) throws IOException { + this.windowId = in.readByte(); + this.recipeId = in.readVarInt(); + } + + @Override + public void write(NetOutput out) throws IOException { + out.writeByte(this.windowId); + out.writeVarInt(this.recipeId); + } + + @Override + public boolean isPriority() { + return false; + } + + @Override + public String toString() { + return ReflectionToString.toString(this); + } +}