Entities which are transformed from one type to another (e.g. a pig to a zombified piglin after being struck by lightning) do not retain their custom_data component (data NBT tag).
These entities do retain other data such as command tags and equipment, which are ways of storing arbitrary data.
This feature (all entities storing custom_data) was partly added to prevent the janky workaround of using items to store data on mobs. This bug causes a big issue thereā¦
Steps to Reproduce:
Run the command
/summon pig ~ ~ ~ {data:{foo:1}}to summon a pig with acustom_datacomponent of{foo:1}Summon a lightning bolt next to it with
/summon lightning_boltRun
/data get entity @n[type=zombified_piglin] datato observe that the data is now gone.
Observed Behaviour:
The custom_data component (data tag) is deleted when an entity is transformed to a different entity type.
Expected Behaviour:
The component (data tag) is retained when an entity is transformed to a different entity type, just like many other customisation tags.
Can confirm: