Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • FireController1847 changed the title to [1.14.3] Replacement for NBTTagCompound#setTag?
  • 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.

  • FireController1847 changed the title to [1.14.3] [Solved] Replacement for NBTTagCompound#setTag?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.