mojira.dev
MC-131328

The "score" and "selector", and "nbt" text component content types do not get resolved if the text component is the name of an item, entity or scoreboard objective

Technically it's valid JSON, but the problem is that it doesn't seem to be able to grab a score from the scoreboard. My idea is that I was thinking it'd be neat if you could have a number variable for something like RPG levels displayed alongside a name. For example, the following command should work for this, but doesn't:

/summon husk ~ ~ ~ {Invulnerable:1,NoAI:1,CustomName:"[{\"text\":\"Level \"},{\"score\":{\"name\":\"@s\",\"objective\":\"rpglevel\"}}]"}

For the record, this functionally identical one doesn't either:

/summon husk ~ ~ ~ {Invulnerable:1,NoAI:1,CustomName:"{\"text\":\"Level \",\"extra\":[{\"score\":{\"name\":\"@s\",\"objective\":\"rpglevel\"}}]}"}

This just summons a husk named "Level " with nothing at the end of it instead of a number equal to my "rpglevel" score. Using my actual player name or a fake player name (or even @p) doesn't change this fact.

Looking at its data through "/data get" shows that the "value" argument gets added to the "score" section, but it'll always be empty by default. You can manually set the value to whatever you want it to be and it'll show up in the name, but the expected behaviour in this context is that "value" should be automatically determined upon running the command. Otherwise it's no different than having another "text" section.

I dunno how difficult it is to implement, but the simplest-sounding solution would be adding what I just described in that last bit: A way for the game to grab a score and automatically apply it to the "value" section of a CustomName's "score" component upon running the command instead of always leaving it blank like it currently does. Maybe the problem is that it's not properly recognizing the "name" section of "score" when used in CustomName? Because the entity data shows that it uses the literal text when writing things like @s, @p, etc.. Thinking about it that way, maybe it's best if CustomName just immediately converts "score" components into "text" ones that match up with what the "value" would have been? I imagine one of the potential drawbacks of doing it the other way is a custom name that'd be endlessly checking itself for score updates (maybe this is a main reason why it's not already in the game), whereas immediately converting a "score" component into a "text" one wouldn't have that issue.

Linked issues

MC-278055 Storage text component does not work on item name and lore Resolved MC-278227 The text component's selector can't work in entities' nbt data Resolved MC-230273 Advancement title and description json ignore targets and selectors Resolved MC-241138 Score cannot be included in item lore Resolved MC-144357 data modify ignores selectors in text Resolved

Comments 5

Scores and selectors only apply to signs, title/tellraw and book pages, they are special cases.

Fine but this sucks...

you are literally trying to pass a bug off as a feature

You can achieve this with loot tables, or sign evaluation

Yeah no this is just unnecessarily limiting what we are allowed to do with the pre-existing raw text format that has well-defined rules. Like, the command block is perfectly happy with me making an item with an item_name component that references a score, why doesn't the game respect that?

I'd understand if there was some back-end justification for why this is difficult to implement, but this is just saying, "Just do it a different way" as if this wouldn't actually add depth to item components and entity names.

Remin

(Unassigned)

Unconfirmed

Minecraft 1.13-pre1

Retrieved