From 65a6e9778506e02510424d60db31b50ce0430868 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Mon, 12 May 2014 23:56:37 -0500 Subject: [PATCH] Handle inventory max stack sizes even better. Fixes BUKKIT-5595 In 7e37cf96 we modified the container logic to handle custom max stack sizes better and ensure the client stays in sync with this scenario. This had the effect of sending an extra set slot packet for every inventory click a player did which was not wanted. These extra packets also cause the client to recalculate recipes which breaks the result slot for custom recipes. To avoid the extra packets in general we now only send them if the max stack is not the one we started with. In the case of a setting a custom max stack size on a workbench this is still not enough so we also now send another extra packet to make sure the result slot is always correct. --- src/main/java/net/minecraft/server/Container.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java index 3443a1921c..7358645520 100644 --- a/src/main/java/net/minecraft/server/Container.java +++ b/src/main/java/net/minecraft/server/Container.java @@ -13,6 +13,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.Event.Result; import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.InventoryView; // CraftBukkit end @@ -346,8 +347,12 @@ public abstract class Container { slot2.f(); // CraftBukkit start - Make sure the client has the right slot contents - if (entityhuman instanceof EntityPlayer) { + if (entityhuman instanceof EntityPlayer && slot2.getMaxStackSize() != 64) { ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, slot2.rawSlotIndex, slot2.getItem())); + // Updating a crafting inventory makes the client reset the result slot, have to send it again + if (this.getBukkitView().getType() == InventoryType.WORKBENCH || this.getBukkitView().getType() == InventoryType.CRAFTING) { + ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSetSlot(this.windowId, 0, this.getSlot(0).getItem())); + } } // CraftBukkit end }