mojira.dev
MC-137697

NBT list using "interpret" not comma delimited

Background

When a list of NBT values is displayed using the NBT component, the entries in the list are separated by commas, like so [<item 1>, <item 2>, <item 3>, ...].

The bug

When the items in the list are interpreted as text components using "interpret":true, the entries are no longer comma delimited: [<item 1><item 2><item 3>...].

[media]

Steps to Recreate

  1. Create a container with 2+ items with custom names

    /summon chest_minecart ~ ~ ~ {Items:[{id:stone,Count:1b,tag:{display:{Name:"\"A\""}},Slot:0b},{id:stone,Count:1b,tag:{display:{Name:"\"B\""}},Slot:1b},{id:stone,Count:1b,tag:{display:{Name:"\"C\""}},Slot:2b}]}
  2. Use the NBT text component to display the names of the items

    /tellraw @s {"nbt":"Items[].tag.display.Name","entity":"@e[type=chest_minecart]"}

    → ✔ The raw text components are comma delimited

  3. Now use "interpret":true on the same items

    /tellraw @s {"nbt":"Items[].tag.display.Name","entity":"@e[type=chest_minecart]","interpret":true}

    → ❌ The interpreted components are not comma delimited

Disclaimer

Since interpret changes the nature of the text, I am unsure whether this is intended behavior.

Attachments

Comments 3

Is the custom name of the item a list of components? For example something like the following

/give @s stone{display:{Name:"[\"a\",\"b\"]"}}

In that case this is likely intended, because (if I understand it correctly) the value is interpreted as chat component and for them list elements are joined without any delimiter.

Otherwise please provide the exact commands you used.

No, sorry it is multiple custom items each with a single component as their name.

It has to be multiple items to have a list of NBT values, and they must have custom names because otherwise the display.Name value won't exist and the NBT component will resolve to [].

  1. Give yourself some items with custom names. (The color has been omitted to shorten command length.)

    /give @s stone{display:{Name:"\"Simple Stone\""}}
    /give @s oak_planks{display:{Name:"\"Pretty Planks\""}}
    /give @s birch_leaves{display:{Name:"\"Luscious Leaves\""}}
    /give @s fire_coral_block{display:{Name:"\"Capricious Coral\""}}
  2. Then put all the items into a chest, and display their display.Name value using an NBT component.

    /tellraw @a {"nbt":"Items[].tag.display.Name","block":{"x":<x>,"y":<y>,"z":<z>}}

    But of course replace the xyz values with the chest block coordinates.
    The entries in the list of NBT values have ", " between the items and have [] around them.

    ["Simple Stone", "Pretty Planks", "Luscious Leaves", "Capricious Coral"]
  3. Then instead interpret the data as text components (using "interpret":true).

    /tellraw @a {"nbt":"Items[].tag.display.Name","interpret":true,"block":{"x":<z>,"y":<y>,"z":<z>}}

    And now this time it is just the raw name values without any ", " between them, but still with [] around them.

    [Simple StonePretty PlanksLuscious LeavesCapricious Coral]

I colored the first item in the list and the color did not cascade to the other items, so if anything it may just be adding each item name as extra text to a text component. In which case it is intended insofar as text components do not delimit between children. But perhaps it is not intended for the command output.

Thank you for the steps. I added commands to the reproduction steps, I hope you are fine with the changes.

Tedstar (Curtis Anderson)

boq

Confirmed

NBT, comma, list, nbt, nbt-component, nbt-path, text, text-component

Minecraft 18w43a, Minecraft 18w43b

Minecraft 18w43c

Retrieved