Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show_item breaks if nbt input #314

Open
UncleThaodan opened this issue Jun 5, 2021 · 5 comments
Open

show_item breaks if nbt input #314

UncleThaodan opened this issue Jun 5, 2021 · 5 comments

Comments

@UncleThaodan
Copy link

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 UncleThaodan changed the title Double-quote-escapes break if show_item event show_item breaks if nbt input Jun 6, 2021
@ezfe
Copy link
Owner

ezfe commented Jun 8, 2021

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

@ezfe
Copy link
Owner

ezfe commented Jun 9, 2021

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 ezfe closed this as completed Jun 9, 2021
@UncleThaodan
Copy link
Author

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.

@ezfe ezfe reopened this Jun 9, 2021
@ezfe
Copy link
Owner

ezfe commented Jun 9, 2021

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.

@UncleThaodan
Copy link
Author

Thanks, that would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants