scores in JSON for CustomName don't display
The bug
CustomName values have been changed to support JSON text. Part of JSON text is the ability to display scores, via syntax such as `{"score":{"name":"@s", "objective":"SomeObjective"}}` . But if you use this in a CustomName for an entity, it doesn't work. It also doesn't error; it just displays as an empty string.
Reproduction steps
- Create a dummy scoreboard objective called HP (for this example):
/scoreboard objectives add HP dummy
- Summon a cow with that HP objective in its JSON name:
/summon minecraft:cow ~ ~ ~ {CustomName:"{\"score\":{\"name\":\"@s\",\"objective\":\"HP\"}}", CustomNameVisible:1b} - Set the cow's HP score via something like
/scoreboard players set @e[type=cow,limit=1,sort=nearest] HP 10
Watch as the name remains empty instead of showing 10. Changing the selector in the JSON from @s to @e[type=cow,limit=1,sort=nearest] doesn't fix it, either.
Workarounds
Use other means to resolve the text component and then use the /data command to copy the text component.
2018-01-07, 09:16 AM
2021-01-16, 02:51 AM
2021-01-16, 02:51 AM
1
8
-