Posted July 14, 20196 yr Hello I'm trying to learn how to use NBT tags in order to store data on items, but I got stuck on one problem. Data is being stored and whatnot but it isn't stored in the instance of an item, but the item itself @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if(playerIn.getActiveItemStack().getTagCompound()==null) playerIn.getActiveItemStack().setTagCompound(new NBTTagCompound()); if(playerIn.getActiveItemStack().getTagCompound().hasKey("TestVal")==false) { playerIn.getActiveItemStack().getTagCompound().setInteger("TestVal", 1); } int curVal = playerIn.getActiveItemStack().getTagCompound().getInteger("TestVal"); playerIn.getActiveItemStack().getTagCompound().setInteger("TestVal", curVal+1); System.out.println(playerIn.getActiveItemStack().getTagCompound().getInteger("TestVal")); return super.onItemRightClick(worldIn, playerIn, handIn); }
July 14, 20196 yr Author Thanks! I found this information somewhere too, and i also found some helpful links for people that may also have this problem Usage of capabilities: https://tutorials.darkhax.net/tutorials/custom_entity_data/ Usage of subCompounds(I find it helpful a bit):
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.