From 59effe8131b454c99e9b9f6bf8bc5a88ac48a4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salom=C3=A3o?= Date: Mon, 14 Jun 2021 11:51:17 -0300 Subject: [PATCH] save NBT properly --- src/main/java/appeng/util/item/AEItemStack.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/appeng/util/item/AEItemStack.java b/src/main/java/appeng/util/item/AEItemStack.java index b1d5ee4e0..b6a2e4e2a 100644 --- a/src/main/java/appeng/util/item/AEItemStack.java +++ b/src/main/java/appeng/util/item/AEItemStack.java @@ -79,17 +79,21 @@ public final class AEItemStack extends AEStack implements IAEItemS return new AEItemStack(AEItemStackRegistry.getRegisteredStack(stack), stack.getCount()); } - public static IAEItemStack fromNBT(final NBTTagCompound i) { - if (i == null) { + public static IAEItemStack fromNBT( final NBTTagCompound i ) + { + if( i == null ) + { return null; } - final ItemStack itemstack = new ItemStack(i); - final AEItemStack item = AEItemStack.fromItemStack(itemstack); - if (item == null) { + final ItemStack itemstack = new ItemStack( i ); + if( itemstack.isEmpty() ) + { return null; } + final AEItemStack item = AEItemStack.fromItemStack( itemstack ); + item.setStackSize(i.getLong(NBT_STACKSIZE)); item.setCountRequestable(i.getLong(NBT_REQUESTABLE)); item.setCraftable(i.getBoolean(NBT_CRAFTABLE)); @@ -98,8 +102,7 @@ public final class AEItemStack extends AEStack implements IAEItemS @Override public void writeToNBT(final NBTTagCompound i) { - final NBTTagCompound itemStack = new NBTTagCompound(); - this.getDefinition().writeToNBT(itemStack); + this.getDefinition().writeToNBT( i ); i.setLong(NBT_STACKSIZE, this.getStackSize()); i.setLong(NBT_REQUESTABLE, this.getCountRequestable());