diff --git a/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java b/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java index 810e6ea9d..0f661782c 100644 --- a/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/InventoryUtil.java @@ -10,6 +10,7 @@ import net.minecraft.entity.Entity; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -54,9 +55,17 @@ public class InventoryUtil { if( a == b ) return true; if( a.isEmpty() ) return !b.isEmpty(); - return a.getItem() == b.getItem() - && a.getItemDamage() == b.getItemDamage() - && ItemStack.areItemStackShareTagsEqual( a, b ); + + if( a.getItem() != b.getItem() || a.getItemDamage() != b.getItemDamage() ) return false; + + // A more expanded form of ItemStack.areItemStackShareTagsEqual, but allowing an empty tag to be equal to a + // null one. + NBTTagCompound shareTagA = a.getItem().getNBTShareTag( a ); + NBTTagCompound shareTagB = b.getItem().getNBTShareTag( b ); + if( shareTagA == shareTagB ) return true; + if( shareTagA == null ) return shareTagB.isEmpty(); + if( shareTagB == null ) return shareTagA.isEmpty(); + return shareTagA.equals( shareTagB ); } @Nonnull