From 93f5c8a79725d87ca67feb5222e698bdee173bd5 Mon Sep 17 00:00:00 2001 From: Porter Westling Date: Mon, 22 Sep 2014 13:34:50 -0700 Subject: [PATCH] compare stack tags as well as item id --- .../common/transporter/TransporterManager.java | 8 ++++---- .../java/mekanism/common/util/InventoryUtils.java | 14 +++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/mekanism/common/transporter/TransporterManager.java b/src/main/java/mekanism/common/transporter/TransporterManager.java index 291859282..427c09d2d 100644 --- a/src/main/java/mekanism/common/transporter/TransporterManager.java +++ b/src/main/java/mekanism/common/transporter/TransporterManager.java @@ -126,7 +126,7 @@ public class TransporterManager testInv[i] = toInsert; return; } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { @@ -182,7 +182,7 @@ public class TransporterManager testInv[slotID] = toInsert; return; } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { @@ -282,7 +282,7 @@ public class TransporterManager { return null; } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { @@ -325,7 +325,7 @@ public class TransporterManager { return null; } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { diff --git a/src/main/java/mekanism/common/util/InventoryUtils.java b/src/main/java/mekanism/common/util/InventoryUtils.java index 7b6d6edf8..60329ed61 100644 --- a/src/main/java/mekanism/common/util/InventoryUtils.java +++ b/src/main/java/mekanism/common/util/InventoryUtils.java @@ -82,7 +82,7 @@ public final class InventoryUtils inventory.setInventorySlotContents(i, toInsert); return null; } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { @@ -138,7 +138,7 @@ public final class InventoryUtils inventory.setInventorySlotContents(slotID, toInsert); return null; } - else if(inSlot.isItemEqual(toInsert) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize()) { @@ -169,7 +169,11 @@ public final class InventoryUtils return toInsert; } - public static InvStack takeTopItem(IInventory inventory, int side) + public static boolean areItemsStackable(ItemStack toInsert, ItemStack inSlot) { + return inSlot.isItemEqual(toInsert) && ItemStack.areItemStackTagsEqual(inSlot, toInsert); + } + + public static InvStack takeTopItem(IInventory inventory, int side) { inventory = checkChestInv(inventory); @@ -381,7 +385,7 @@ public final class InventoryUtils { return true; } - else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) { @@ -427,7 +431,7 @@ public final class InventoryUtils { return true; } - else if(inSlot.isItemEqual(itemStack) && inSlot.stackSize < inSlot.getMaxStackSize()) + else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < inSlot.getMaxStackSize()) { if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize()) {