0

I'm trying to update the text of signs but seem to be missing something.

The following command will report that the sign's data was updated:

/data merge block 3 -59 -3 {Text2:'{text:"SYSTEM STATUS:"}',Text3:'{text:"Busy"}'}

Unfortunately the text on the sign doesn't change, neither does the data of the block (F3+I)

1 Answer 1

2

The values of Text1, Text2, Text3 and Text4 are supposed to be JSON. This means that you should use quoted key names.

So this:

{text:"SYSTEM STATUS:"}

Should be changed to this:

{"text":"SYSTEM STATUS:"}
5
  • 1
    Good job figuring this one out! Notice that in {Text2:'{"text":"SYSTEM STATUS:"}'}, there are single quotation marks around the JSON text. This is because, to the NBT processor, Text2: ' ' is just a string, and it doesn't know that it contains JSON. It is only when the sign is loaded from that NBT that the string's contents are taken and parsed as JSON. Be careful not to make the mistake of thinking that NBT has intrinsic support for inner JSON, or vice versa.
    – One 2 Many
    Commented Nov 4, 2022 at 1:59
  • Yeah, I had to figure that out the hard way. Do you happen to know why it consumes a string? Because this seems to be out of line with the NBT of other blocks/entities as far as I've seen (with my limited Minecraft scripting knowledge)
    – Niekvb
    Commented Nov 4, 2022 at 9:06
  • With a very limited set of exceptions, NBT and JSON are not cross-compatible with each other. Everywhere JSON is embedded in NBT, it is done within an NBT string, and vice versa. The most common experiences of this is for custom item names, custom item lores, and custom entity names. I'm not sure which examples you are referring to, as everything I've seen so far follows that format, but I'm curious to see where you're coming from. I'd be happy to continue this discussion in the Minecraft talk chatroom.
    – One 2 Many
    Commented Nov 5, 2022 at 3:42
  • As far as I've seen, JSON strings are strictly used for visual text elements. Eg: CustomName for mobs, TextX for signs, Lore on some items and text to send in chat. This seems out of line because you can specify multi-dimensional objects within NBTs, so why not allow this for said properties? In other words: What would be the advantage of specifying {Text1:'{"text":"ABC123","color":"#ffffff"}'} instead of {Text1:{text:"ABC123",color:"#ffffff"}}
    – Niekvb
    Commented Nov 5, 2022 at 15:43
  • This isn't a question of advantages: it's a question of history and systems. This is too much to explain in a comment, so let us continue this discussion in chat.
    – One 2 Many
    Commented Nov 5, 2022 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.