Posted November 16, 20168 yr In 1.10.2 => ItemStack.loadItemStackFromNBT and in 1.11? Here is my Code. Error in Red below. Thanks package ... import ... public class InventoryBackpack extends InventoryBasic { private final ItemStack stack; public InventoryBackpack(ItemStack stack) { //super(I18n.format("lang.backpack1", new Object[0]), false, 9); super("Level 1", false, 9); this.stack = stack; } @Override public void openInventory(EntityPlayer player){ readFromNBT(); super.openInventory(player); } @Override public void closeInventory(EntityPlayer player){ writeToNBT(); super.closeInventory(player); } @Override public void markDirty(){ writeToNBT(); super.markDirty(); } public void writeToNBT() { NBTTagCompound tag = stack.getTagCompound(); if(tag == null){ tag = new NBTTagCompound(); stack.setTagCompound(tag); } NBTTagList list = new NBTTagList(); for(int i = 0; i < getSizeInventory(); i++){ ItemStack stack = getStackInSlot(i); if(stack != null){ NBTTagCompound slottag = new NBTTagCompound(); slottag.setInteger("slotindex", i); stack.writeToNBT(slottag); list.appendTag(slottag); } } tag.setTag("inventory", list); } public void readFromNBT() { NBTTagCompound tag = stack.getTagCompound(); if(tag == null){ writeToNBT(); return; } NBTTagList list = tag.getTagList("inventory", Constants.NBT.TAG_COMPOUND);//10 if(list == null){ writeToNBT(); return; } for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound slottag = list.getCompoundTagAt(i); int index = slottag.getInteger("slotindex"); ItemStack stack = ItemStack.loadItemStackFromNBT(slottag); setInventorySlotContents(index, stack); } } }
June 21, 20196 yr On 11/16/2016 at 8:48 PM, Keks said: In 1.10.2 => ItemStack.loadItemStackFromNBT and in 1.11? Here is my Code. Error in Red below. Thanks Reveal hidden contents package ... import ... public class InventoryBackpack extends InventoryBasic { private final ItemStack stack; public InventoryBackpack(ItemStack stack) { //super(I18n.format("lang.backpack1", new Object[0]), false, 9); super("Level 1", false, 9); this.stack = stack; } @Override public void openInventory(EntityPlayer player){ readFromNBT(); super.openInventory(player); } @Override public void closeInventory(EntityPlayer player){ writeToNBT(); super.closeInventory(player); } @Override public void markDirty(){ writeToNBT(); super.markDirty(); } public void writeToNBT() { NBTTagCompound tag = stack.getTagCompound(); if(tag == null){ tag = new NBTTagCompound(); stack.setTagCompound(tag); } NBTTagList list = new NBTTagList(); for(int i = 0; i < getSizeInventory(); i++){ ItemStack stack = getStackInSlot(i); if(stack != null){ NBTTagCompound slottag = new NBTTagCompound(); slottag.setInteger("slotindex", i); stack.writeToNBT(slottag); list.appendTag(slottag); } } tag.setTag("inventory", list); } public void readFromNBT() { NBTTagCompound tag = stack.getTagCompound(); if(tag == null){ writeToNBT(); return; } NBTTagList list = tag.getTagList("inventory", Constants.NBT.TAG_COMPOUND);//10 if(list == null){ writeToNBT(); return; } for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound slottag = list.getCompoundTagAt(i); int index = slottag.getInteger("slotindex"); ItemStack stack = ItemStack.loadItemStackFromNBT(slottag); setInventorySlotContents(index, stack); } } } What´s about 1.12? How can I replace loadItemStackFromNBT there?
June 21, 20196 yr So I recently wrote a code for a custom backpack, but noticed that the function: loadItemStackFromNBT doesn´t exist anymore. Can anyone tell me with which code I have to replace this? Thanks
June 22, 20196 yr 20 hours ago, Screamer said: So I recently wrote a code for a custom backpack, but noticed that the function: loadItemStackFromNBT doesn´t exist anymore. Can anyone tell me with which code I have to replace this? Thanks ItemStack(NBTTagCompound)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.