mojira.dev
MC-124596

name selector parameter does not work for children of text components

The bug

When you use the name selector parameter you would expect that you select entities by the name you see in the chat or above their head (except if you use translations). However it looks like the parameter does not test nested text components.

Note: This works correctly for the Lock tag of containers, see also MC-123932.

How to reproduce

  1. Summon an armor stand with a nested custom name

    /summon armor_stand ~ ~ ~ {CustomName:"{\"text\":\"test\",\"extra\":[\"_test\"]}"}

    → ✔ The armor stand is named "test_test"

  2. Try to select the armor stand by that name

    /say @e[type=armor_stand,name=test_test]

    → ❌ It fails

Linked issues

Comments 7

Is this also the case if you quote the value in the selector?

Yes, /say @e[type=armor_stand,name="test_test"] fails as well

Running

/say @e[nbt={CustomName:"{\"extra\":[{\"text\":\"_test\"}],\"text\":\"test\"}"}]

is the only way I have gotten it to output test_test in console. I have tried many different attempts so far and nothing has worked. Is there no way to see what the name parameter resolves to in the selector? It makes no sense that /say @e[type=armor_stand,limit=1,sort=nearest] will output test_test in console, but /say @e[name=test_test] fails.

Can partially confirm that the nested text components are ignored. These are some of the commands I have tested:

  1. /summon armor_stand ~ ~1 ~ {CustomName:"{\"extra\":[\"_test\"],\"text\":\"test\"}",CustomNameVisible:1}
  2. /summon armor_stand ~ ~1 ~ {CustomName:"{\"extra\":[\"_test\"],\"translate\":\"test%s\"}",CustomNameVisible:1}
  3. /summon armor_stand ~ ~1 ~ {CustomName:"[{\"text\":\"test\"},{\"text\":\"_test\"}]",CustomNameVisible:1}
  4. /say @e[type=armor_stand,limit=1,sort=nearest,name=test]
  5. /summon armor_stand ~ ~1 ~ {CustomName:"{\"with\":[\"_test\"],\"translate\":\"test%s\"}",CustomNameVisible:1}
  6. /say @e[type=armor_stand,limit=1,sort=nearest,name=test_test]

Running (1), (2), and (3) on separate trials then activating (4) will output 'test_test' in chat all three times, and the name displayed above the armor stands in each case shows up as 'test_test'. Running (5) and then activating (6) will output 'test_test' in chat, the same as the name displayed above the armor stand. (2) demonstrates a peculiar behavior in which using translate and %s do not bypass the issue of extra text being ignored.

Would it be more correct to state that the name parameter only accepts parent text components and ignores child text components? In which case it might relate to issues with inheritance. The name parameter should be parsing the JSON text as an amalgamation of each text component, but only the parent text component is accepted and the rest are ignored and treated as separate entities.

this appears to be fixed as of 1.16. Can anyone confirm?

OK so I followed the steps to reproduce in 1.16 and 1.16.1, and it appears as though this bug has been fixed.

However, this has caused other problems, in particular for translate components. The name parameter now resolves translate components by interpreting them literally (as opposed to ignoring them in previous versions), which means that commands can now resolve differently depending on the client language, which should not happen. On multiplayer servers, however, translation components are interpreted literally as in US English.

Ok so the translation issue existed prior to 1.16. It appears as this bug is fixed in 1.16+ though.

Can confirm fixed in 20w17a.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

selector, text-component

Minecraft 18w03b, Minecraft 18w06a, Minecraft 1.13, Minecraft 18w30b, Minecraft 1.13.1, 1.14.4, 19w37a, 1.15.2, 20w10a

20w17a

Retrieved