Thanks. So I followed the tutorial and modified very little, but for some reason every time I reopen the inventory my Items are deleted. I posted areas I thought would be possible culprits but I don't know whats wrong. Any suggestions for disappearing items?
public class ModGuiHandler implements IGuiHandler{
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){
BlockPos pos = new BlockPos(x, y, z);
switch(ID){
case Constants.ITEM_GAUNTLET:
return new ContainerGauntlet(player, player.inventory, new InventoryGauntlet(player.getHeldItem()));
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){
BlockPos pos = new BlockPos(x, y, z);
switch (ID){
case Constants.ITEM_GAUNTLET:
return new GuiItemGauntlet((ContainerGauntlet) new ContainerGauntlet(player, player.inventory, new InventoryGauntlet(player.getHeldItem())));
}
return null;
}
}
thats my guiHandler^^
public void writeToNBT(NBTTagCompound tagcompound){
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.getSizeInventory(); ++i)
{
if (this.getStackInSlot(i) != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
this.getStackInSlot(i).writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tagcompound.setTag(tagName, nbttaglist);
}
public void readFromNBT(NBTTagCompound compound) {
NBTTagList items = compound.getTagList(tagName, compound.getId());
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
byte slot = item.getByte("Slot");
if (slot >= 0 && slot < getSizeInventory()) {
setInventorySlotContents(slot,
ItemStack.loadItemStackFromNBT(item));
}
}
}
read and write nbt^^
Thanks for any help