Ah I see, this tutorial gives some insight in NBT
http://www.minecraftforge.net/wiki/Tile_Entities
Your whole code should be like this:
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.inv.length; ++i)
{
if (this.inv[i] != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("slot", (byte)i);
this.inv[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
}
public void readFromNBT(NBTTagCompound p_145839_1_)
{
super.readFromNBT(p_145839_1_);
NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10);
this.inv = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("slot") & 255;
if (j >= 0 && j < this.inv.length)
{
this.inv[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
}
If that code doesn't work the problem lies elsewhere. Did you register the TileEntity in the GameRegistry?