mojira.dev
MC-87252

Optional tags gets removed when set to false/0/empty

The Bug

When the CustomNameVisible tag is set to false (0b) the game automatically removes the tag from the NBT data of the Entity. This also affects newly summoned Entities which do not have it by default if it is not true.
This is a big problem as you cannot test for it then.

Steps to Reproduce

  • Summon a husk with its "CustomNameVisible" tag set to "0b".

    /summon minecraft:husk ~ ~ ~ {CustomNameVisible:0b}
  • Use the data command on the husk to inspect the value of its "CustomNameVisible" tag.

    /data get entity @e[type=minecraft:husk,limit=1,sort=nearest] CustomNameVisible

    ❌ → Notice how the error message, "Found no elements matching CustomNameVisible" is displayed in the chat, therefore indicating that optional NBT data tags get removed when set to "0", "false", or "empty".

Expected Behavior

The expected behavior would be that optional NBT data tags would not get removed when set to "0", "false", or "empty".

Linked issues

Attachments

Comments 12

Might be intended because this tag is optional and its default value is 0.
Moreover the same seems to happen with the Silent tag

happens with all optional tags, IsBaby, IsVillager, VillagerProfession and NoAI are also effected.
in my opinion these should exist if you specify them in the summon/entitydata, regardless of value

Tested it further, /summon minecraft:zombie ~ ~ ~ {IsBaby:0} actually does guarantee that it won't be a baby (while normally there's a small chance that it will be), which is further evidence that this is a bug.

@@unknown no this is no evidence for that. If you just provide an empty compound it would already prevent the randomization.

2 more comments

Confirmed for 1.16.1.

I am able to confirm this behavior in both 1.17.1 and 21w38a. Here are some extra details regarding this problem.

The Bug:

Optional NBT data tags get removed when set to "0", "false", or "empty".

Steps to Reproduce:

  • Summon a husk with its "CustomNameVisible" tag set to "0b".

/summon minecraft:husk ~ ~ ~ {CustomNameVisible:0b}
  • Use the data command on the husk to inspect the value of its "CustomNameVisible" tag.

/data get entity @e[type=minecraft:husk,limit=1,sort=nearest] CustomNameVisible
  • → ❌  Notice how the error message, "Found no elements matching CustomNameVisible" is displayed in the chat, therefore indicating that optional NBT data tags get removed when set to "0", "false", or "empty".

Expected Behavior:

The expected behavior would be that optional NBT data tags would not get removed when set to "0", "false", or "empty".

Can confirm for 1.18.1 and 22w05.

Can confirm in 1.18.2 and 22w19a.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

CustomNameVisible, entity, false

Minecraft 15w35b, Minecraft 1.10.2, Minecraft 16w43a, Minecraft 16w44a, Minecraft 1.11.2, ..., 22w05a, 1.18.2, 22w19a, 1.20.4, 1.21.4

Retrieved