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
Summon an armor stand with a nested custom name
/summon armor_stand ~ ~ ~ {CustomName:"{\"text\":\"test\",\"extra\":[\"_test\"]}"}
→ ✔ The armor stand is named "test_test"
Try to select the armor stand by that name
/say @e[type=armor_stand,name=test_test]
→ ❌ It fails
Linked issues
Comments 7
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:
/summon armor_stand ~ ~1 ~ {CustomName:"{\"extra\":[\"_test\"],\"text\":\"test\"}",CustomNameVisible:1}
/summon armor_stand ~ ~1 ~ {CustomName:"{\"extra\":[\"_test\"],\"translate\":\"test%s\"}",CustomNameVisible:1}
/summon armor_stand ~ ~1 ~ {CustomName:"[{\"text\":\"test\"},{\"text\":\"_test\"}]",CustomNameVisible:1}
/say @e[type=armor_stand,limit=1,sort=nearest,name=test]
/summon armor_stand ~ ~1 ~ {CustomName:"{\"with\":[\"_test\"],\"translate\":\"test%s\"}",CustomNameVisible:1}
/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.
Is this also the case if you quote the value in the selector?