for (int i = 0; i < inv.length; i++) {
if(inv[i] != null) {
NBTTagCompound itemStackNBT = new NBTTagCompound();
itemStackNBT.setByte("Slot", (byte) i);
inv[i].writeToNBT(itemStackNBT);
itemList.appendTag(itemStackNBT);
}
}
root.setTag("Items", itemList);
root.setShort("facing", facing);
}