for (int i = 0; i < inventory.length; i++) {
if(inventory[i] != null) {
NBTTagCompound itemStackNBT = new NBTTagCompound();
itemStackNBT.setByte("Slot", (byte) i);
inventory[i].writeToNBT(itemStackNBT);
itemList.appendTag(itemStackNBT);
}
}
nbtRoot.setTag("Items", itemList);
nbtRoot.setInteger("redstoneControlMode", redstoneControlMode.ordinal());