1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-28 18:04:47 +00:00

Make upgrade crafting even more lenient

This now allows items with empty tags to equal those with no tag.
This commit is contained in:
SquidDev 2019-03-16 00:39:16 +00:00
parent 105c66127c
commit 54b9966feb

View File

@ -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