Posted July 6, 20196 yr In previous versions of Minecraft (1.13-), I was able to create an NBTTagCompound and then run .setTag on the EntityData to set my compound to the entity. However, in 1.14, it appears this is different. How do I set a compound tag to the entity data via NBT? Old code: public void saveToPlayer(EntityPlayer player) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("minHealth", this.defHealth); tag.setDouble("modifier", this.modifier); tag.setByte("heartContainers", this.heartContainers); tag.setShort("levelRampPosition", this.levelRampPosition); player.getEntityData().setTag(LevelHearts.NBT_ID, tag); } New (attempt) code: public void saveToPlayer(PlayerEntity player) { CompoundNBT tag = new CompoundNBT(); tag.putByte("minHealth", this.defHealth); tag.putDouble("modifier", this.modifier); tag.putByte("heartContainers", this.heartContainers); tag.putShort("levelRampPosition", this.levelRampPosition); player.getEntityData().setTag(LevelHearts.NBT_ID, tag); // There is no "setTag" option here, what do I do? } I am on my journey of making a remake of matmos, as explained here.
July 6, 20196 yr Author Just now, diesieben07 said: For a start, do not use getEntityData. Use capabilities. The method you want has been replaced by put. You could have easily found this out yourself by looking at the code for 2 seconds. My apologies, I was looking within the code but somehow happened to miss this entirely. So sorry, thanks! I am on my journey of making a remake of matmos, as explained here.
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.