From 0788f8e7d0344e086c484deda9630b8e13d6ec1a Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 8 Feb 2011 19:37:53 -0500 Subject: [PATCH] inventory fixes By: Tahg --- .../bukkit/craftbukkit/inventory/CraftInventory.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 264d6284a7..a723e1480c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -179,7 +179,14 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { } public int firstPartial(ItemStack item) { - return firstPartial(item.getTypeId()); + CraftItemStack[] inventory = getContents(); + for (int i = 0; i < inventory.length; i++) { + CraftItemStack cItem = inventory[i]; + if (item != null && cItem.getTypeId() == item.getTypeId() && cItem.getAmount() < cItem.getMaxStackSize() && cItem.getDurability() == item.getDurability()) { + return i; + } + } + return -1; } public HashMap addItem(ItemStack... items) { @@ -195,7 +202,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { ItemStack item = items[i]; while (true) { // Do we already have a stack of it? - int firstPartial = firstPartial( item.getTypeId() ); + int firstPartial = firstPartial(item); // Drat! no partial stack if (firstPartial == -1) {