mojira.dev
MC-226676

Unable to copy block nbt string to entity display name.

Custom loot table not copying nbt string to display name.
This setup outputs a blank display name ( {display:{Name:'{"text":""}'}} ) and was expecting the name to be "minecraft:pig".
Manually spawning the item works just fine.
/give @s minecraft:spawner{display:{Name:'{"text":"minecraft:pig"}'}}

File format attached:

Attachments

Comments 11

⚠️ Please do not mark Unreleased Versions as affected. You don't have access to them yet.

-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit

Entity names need to be JSON text components

I'm not quite sure what you're trying to say. It really seems like you haven't looked at the attached file. "SpawnData.id" has the JSON output of "minecraft:pig".

No, thatvs just a string output, JSON would be

'{"text":"..."}'

My apologies, let me take a closer look

1 more comments

I've also found a second issue to naming. This command executes successfully but not everything was applied.

[media]


It seems that the text ends after a colon.

– Correction –
This command does work:

[media]

Alright got it. This works as intended.
Explanation:
When using "entity":"this", the player that mined the block is used as context to evaluate the text component. Therefore, the coordinates ~ ~ ~ refer to the player's position. Therefore, if the player is standing in a block entity, you can access that information.
(As an aside, in 1.18, the path changed to SpawnData.entity.id)
To copy NBT from the block entity that was broken, you should use copy_nbt with "source":"block_entity". Check out the vanilla shulker box for how to use it. Of course, that won't allow you to wrap it in a text component, so you'll have to copy somewhere other than display.Name and work out the rest of the details some other way. Frankly, I am not convinced this is possible as-is with a loot table alone.

As for your question about armor stands...
123 is a number, and therefore is a valid JSON object. minecraft:pig is not a valid JSON object, because it is not a number, quoted string, boolean value, object, or list.
1:23 is valid until the colon, where the remainder is discarded.

Thank you very much for taking the time to explain this. You've been very helpful. ♥

Sure thing, best of luck with your creations 🙂

Nicholas

(Unassigned)

Unconfirmed

(Unassigned)

1.16.5, 1.17 Pre-release 1

Retrieved