Posted January 18, 20178 yr Does anyone knows how I can call ItemStack.loadItemStackFromNBT(); in 1.11.2? It seems like something has changed.
January 18, 20178 yr Does anyone knows how I can call ItemStack.loadItemStackFromNBT(); in 1.11.2? It seems like something has changed. Look at ItemStackHandler#deserializeNBT for how it loads an ItemStack from NBT and ItemStackHandler#serializeNBT for writing of ItemStacks. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
January 18, 20178 yr ItemStack.loadItemStackFromNBT was replaced by the ItemStack(NBTTagCompound) constructor. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
January 18, 20178 yr Author And how can I implement that? I also got an error for the void return type of public void writeToNBT @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); compressorItemStackArray = new ItemStack[getSizeInventory()]; for(int i = 0; i < nbttaglist.tagCount(); i++){ NBTTagCompound nbtTagCompound = nbttaglist.getCompoundTagAt(i); byte b0 = nbtTagCompound.getByte("Slot"); if(b0 >= 0 && b0 < compressorItemStackArray.length){ compressorItemStackArray[b0] = ItemStack.loadItemStackFromNBT(nbtTagCompound); } } timeCanWork = compound.getShort("WorkTime"); ticksCompressingItemSoFar = compound.getShort("CompressTime"); ticksPerItem = compound.getShort("CompressTimeTotal"); if(compound.hasKey("CustomName", ){ compressorCustomName = compound.getString("CustomName"); } } @Override public void writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); compound.setShort("WorkTime", (short)timeCanWork); compound.setShort("CompressTime", (short)ticksCompressingItemSoFar); compound.setShort("ticksPerItem", (short)ticksPerItem); NBTTagList nbttaglist = new NBTTagList(); for(int i = 0; i < compressorItemStackArray.length; i++){ if(compressorItemStackArray[i] != null){ NBTTagCompound nbtTagCompound = new NBTTagCompound(); nbtTagCompound.setByte("Slot", (byte)i); compressorItemStackArray[i].writeToNBT(nbtTagCompound); nbttaglist.appendTag(nbtTagCompound); } } compound.setTag("Items", nbttaglist); if(hasCustomName()){ compound.setString("CustomName", compressorCustomName); } }
January 18, 20178 yr If you are saving an inventory to a TE, you should just be able to do itemStackHandlerField.serialize/deserialize. Have you switched over to the new Capability system? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.