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) {