summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2014-05-12 23:56:37 -0500
committerTravis Watkins <amaranth@ubuntu.com>2014-05-13 00:01:23 -0500
commit65a6e9778506e02510424d60db31b50ce0430868 (patch)
tree117e0e488a2f68c99513b02fd49e13eda78222ab /src
parent5610337b4fa0ab7d8217ecfdc25231d10d572ab4 (diff)
downloadcraftbukkit-65a6e9778506e02510424d60db31b50ce0430868.tar
craftbukkit-65a6e9778506e02510424d60db31b50ce0430868.tar.gz
craftbukkit-65a6e9778506e02510424d60db31b50ce0430868.tar.lz
craftbukkit-65a6e9778506e02510424d60db31b50ce0430868.tar.xz
craftbukkit-65a6e9778506e02510424d60db31b50ce0430868.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/Container.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java
index 3443a192..73586455 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
}