tellraw icon indicating copy to clipboard operation
tellraw copied to clipboard

show_item breaks if nbt input

Open UncleThaodan opened this issue 3 years ago • 5 comments

As the title says, the show_item tooltip is currently broken. Adding show_item {id:"minecraft:stone"} breaks the output so the json appears in plain-text in the final book.

Test: {"jformat":7,"jobject":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"none","insertion":"","click_event_type":"0","click_event_value":"2","hover_event_type":"2","hover_event_value":"{id:\"minecraft:stone\"}","hover_event_object":{},"hover_event_children":[],"text":"Test"}],"command":"/give @p written_book{pages:%s,title:\"Custom Book\",author:\"Player\"}","jtemplate":"book"}

What it could/should look like, without needless escape symbols: /give @p written_book{pages:['{"text":"Test","hoverEvent":{"action":"show_item","contents":{"id":"minecraft:stone"}}}'],title:"Custom Book",author:"Player"}

What it actually generates: /give @p written_book{pages:["{\"text\":\"Test\",\"hoverEvent\":{\"action\":\"show_item\",\"contents\":\"{id:\\\"minecraft:stone\\\"}\"}}"],title:"Custom Book",author:"Player"}

Not only are there way more \" than necessary, it's also not functioning. Tested in Chrome on Windows 10, both for 1.16.5 and 1.17 pre-release 1.

UncleThaodan avatar Jun 05 '21 22:06 UncleThaodan

Thank you - I’ll take a look at this as soon as I get a chance

ezfe avatar Jun 08 '21 02:06 ezfe

This should be all sorted. It was due to a change in 1.16. Now it expects the JSON object, rather than NBT string. I've just pushed new code and it should be live shortly. You should enter JSON in the field, and will see an error generated by my program if it is invalid JSON:

{"id":"minecraft:stone"}

ezfe avatar Jun 09 '21 00:06 ezfe

Bit flawed, but it mostly works

The following does get compiled, but minecraft refuses to run it, as it expects "tag" to be followed by a string.

{"jformat":7,"jobject":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"gold","insertion":"","click_event_type":"0","click_event_value":"","hover_event_type":"2","hover_event_value":"{"id":"minecraft:cake","tag":{}}","hover_event_object":{},"hover_event_children":[],"text":"Test"}],"command":"/give @p written_book{pages:%s,title:"Custom Book",author:Player}","jtemplate":"book"}

Whereas this does not get compiled, even though minecraft would consider it valid, as id and tag do not need to be in quotes.

{"jformat":7,"jobject":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"font":null,"color":"gold","insertion":"","click_event_type":"0","click_event_value":"","hover_event_type":"2","hover_event_value":"{id:"minecraft:cake",tag:"{}"}","hover_event_object":{},"hover_event_children":[],"text":"Test"}],"command":"/give @p written_book{pages:%s,title:"Custom Book",author:Player}","jtemplate":"book"}

It would also be nice to get feedback on the editing page directly, rather than having to input the generated command into minecraft just to figure out something the website already knew. A red border around the field if it can't be validated for example would make it way more intuitive.

Ideally inputting a `/give command would extract all the info it needs and format it in a way minecraft accepts, but that's well inside "Feature Request" territory. Would be amazing though.

UncleThaodan avatar Jun 09 '21 09:06 UncleThaodan

I'll investigate the tag issue and see what I can do there. For error handling, I'll see about getting an indicator on the text field itself - but longer term I'd like to switch it to a basic item builder to avoid ambiguity.

ezfe avatar Jun 09 '21 14:06 ezfe

Thanks, that would be much appreciated.

UncleThaodan avatar Jun 09 '21 18:06 UncleThaodan