Text components currently have support to display and interpret NBT paths.
Example: storage custom:test has following NBT: {text:'{"text": "test", "bold": true}'}
The command /tellraw @a {"storage": "custom:test", "nbt": "text", "interpret": true} would now print the word "test" in bold.
However, this is currently not very dynamic. The reason for that is, that SNBT usually does not produce any valid JSON.
The only exception to that is a String list. If the text tag from above was set to ["Hello ", "world!"] and we were to use the same tellraw command, we would see "Hello world!" in the chat.
This, however, would not work: ['{"text": "Hello", "color": "red"}', '{"text": "Hello", "color": "blue"}'].
The first one only works because the SNBT ["Hello ", "world!"] happens to be valid JSON as well. Since Minecraft always uses single ticks when stringifying SNBT when the text contains a quotation mark, the other one is not valid JSON and therefore cannot be parsed as a text component.
If we go further with this and set our text in the storage to something like {text: "Test", color: "blue"}, this obviously also will never parse.
My suggestion is therefore that NBT gets a method along the lines of toJsonString() which is used when an NBT path is interpreted as a text component, which always returns a valid JSON string instead of SNBT. That would make NBT much more easy and more flexible when being parsed as a text component.
Please sign in to leave a comment.
1 Comments