compare stack tags as well as item id

This commit is contained in:
Porter Westling 2014-09-22 13:34:50 -07:00
parent 1523b402b3
commit 93f5c8a797
2 changed files with 13 additions and 9 deletions

View file

@ -126,7 +126,7 @@ public class TransporterManager
testInv[i] = toInsert; testInv[i] = toInsert;
return; 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()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
@ -182,7 +182,7 @@ public class TransporterManager
testInv[slotID] = toInsert; testInv[slotID] = toInsert;
return; 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()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
@ -282,7 +282,7 @@ public class TransporterManager
{ {
return null; 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()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
@ -325,7 +325,7 @@ public class TransporterManager
{ {
return null; 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()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {

View file

@ -82,7 +82,7 @@ public final class InventoryUtils
inventory.setInventorySlotContents(i, toInsert); inventory.setInventorySlotContents(i, toInsert);
return null; 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()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
@ -138,7 +138,7 @@ public final class InventoryUtils
inventory.setInventorySlotContents(slotID, toInsert); inventory.setInventorySlotContents(slotID, toInsert);
return null; 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()) if(inSlot.stackSize + toInsert.stackSize <= inSlot.getMaxStackSize())
{ {
@ -169,7 +169,11 @@ public final class InventoryUtils
return toInsert; 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); inventory = checkChestInv(inventory);
@ -381,7 +385,7 @@ public final class InventoryUtils
{ {
return true; 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()) if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
{ {
@ -427,7 +431,7 @@ public final class InventoryUtils
{ {
return true; 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()) if(inSlot.stackSize + itemStack.stackSize <= inSlot.getMaxStackSize())
{ {