@Override public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("rotation", rotation.ordinal()); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } nbtTagCompound.setTag(Names.NBT.ITEMS, tagList); NBTTagCompound energyValueTagCompound = new NBTTagCompound(); if (storedEnergyValue != null) { storedEnergyValue.writeToNBT(energyValueTagCompound); } nbtTagCompound.setTag("storedEnergyValue", energyValueTagCompound); }