save NBT properly

This commit is contained in:
Salomão
2021-06-14 11:51:17 -03:00
parent 6f42876963
commit 59effe8131
@@ -79,17 +79,21 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
return new AEItemStack(AEItemStackRegistry.getRegisteredStack(stack), stack.getCount()); return new AEItemStack(AEItemStackRegistry.getRegisteredStack(stack), stack.getCount());
} }
public static IAEItemStack fromNBT(final NBTTagCompound i) { public static IAEItemStack fromNBT( final NBTTagCompound i )
if (i == null) { {
if( i == null )
{
return null; return null;
} }
final ItemStack itemstack = new ItemStack(i); final ItemStack itemstack = new ItemStack( i );
final AEItemStack item = AEItemStack.fromItemStack(itemstack); if( itemstack.isEmpty() )
if (item == null) { {
return null; return null;
} }
final AEItemStack item = AEItemStack.fromItemStack( itemstack );
item.setStackSize(i.getLong(NBT_STACKSIZE)); item.setStackSize(i.getLong(NBT_STACKSIZE));
item.setCountRequestable(i.getLong(NBT_REQUESTABLE)); item.setCountRequestable(i.getLong(NBT_REQUESTABLE));
item.setCraftable(i.getBoolean(NBT_CRAFTABLE)); item.setCraftable(i.getBoolean(NBT_CRAFTABLE));
@@ -98,8 +102,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
@Override @Override
public void writeToNBT(final NBTTagCompound i) { public void writeToNBT(final NBTTagCompound i) {
final NBTTagCompound itemStack = new NBTTagCompound(); this.getDefinition().writeToNBT( i );
this.getDefinition().writeToNBT(itemStack);
i.setLong(NBT_STACKSIZE, this.getStackSize()); i.setLong(NBT_STACKSIZE, this.getStackSize());
i.setLong(NBT_REQUESTABLE, this.getCountRequestable()); i.setLong(NBT_REQUESTABLE, this.getCountRequestable());