How can I store an Entity's NBT data on an item, and then apply it to an entity?

Started by GushyGwar on

Topic category: Help with modding (Java Edition)

Last seen on 11:34, 1. Sep 2024
Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I store an Entity's NBT data on an item, and then apply it to an entity?

Hello! I'm trying to create a mob that can be picked up with a pot, similar to how fish can be picked up with a water bucket, but I'm having one problem. I can't figure out how to store the NBT data of the entity that despawns and apply it to the one that spawns in later. I need this so the entity can keep it's name, ID, health, potion effects, etc. 

How can I modify the procedures I've made to make this happen? 

Picking up procedurePlace down procedure

Last seen on 04:42, 9. Sep 2024
Joined Oct 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here I contribute my grain…
Mon, 08/19/2024 - 18:38

Here I contribute my grain of sand.

I know you can call things using a command, the name can be stored in a player-persistent variable, grabbed using the "get display name" block. The rest of the text NBTs, I don't know how to grab them, I only find blocks to grab custom NBTs.

You will have to add a little to the coordinates to correct the offset.

https://i.ibb.co/D87HmMH/image.png

 

I think there are blocks to take the NBTs you mentioned, although if by ID you mean the UUID, I don't think it's necessary to keep it. I just tested and vanilla axolotls don't keep it either.

 

https://i.ibb.co/dtRdhDV/image.png

 

But health and potions can be taken (in the case of potions I only see the option to take one by one, so potion effects from other mods would not be kept, I suppose). I hope someone else responds with a better solution, because I'm sure I'll need it at some point too.