Skip to content

JSON page deserialization in PrintingPlateJSONRecipe so plates render…#924

Open
mousebites wants to merge 1 commit into
CivMC:mainfrom
mousebites:fix/json-printing-plate-render
Open

JSON page deserialization in PrintingPlateJSONRecipe so plates render…#924
mousebites wants to merge 1 commit into
CivMC:mainfrom
mousebites:fix/json-printing-plate-render

Conversation

@mousebites
Copy link
Copy Markdown

Fixes #923

Fix made and tested before @Ameliorate suggested the more comprehensive re-write. Seems to solve the bug on cases I tested and may be sufficient to fix the plates being completely busted in the interim.

Changed

Converted the text content from books into strings that can be deserialized before the content is added to the page Component.

Why

If the data isn't deserialized, the serialized JSON just ends up as plaintext.

Tests

Tested existing behavior vs post-fix on a locally hosted Civ server.

# Case Expected Result
1 Pre-fix, any valid JSON book Raw JSON verbatim Bug reproduced
2 Object JSON {"text":"X","color":"gold","bold":true} Gold + bold "X" Pass (fixed)
3 Array JSON ["",{"text":"We"},{"text":"lco","italic":true},{"text":"me t"},{"text":"o Minec","color":"aqua"},{"text":"raft To","bold":true,"color":"aqua"},{"text":"ols","color":"aqua"}] Styled render Pass (fixed)
4 Hex + all decorations {"text":"Hex ","color":"#55FF55","extra":[{"text":"B","bold":true},{"text":"I","italic":true}{"text":" U","underlined":true},{"text":"S","strikethrough":true},{"text":" O","obfuscated":true}]} Styled render Pass (fixed)
5 Keybind + translate ["",{"keybind":"key.jump"},{"text":" / "},{"translate":"menu.singleplayer"}] Correct linkage Pass (fixed)
6 Hover/click {"text":"hover me","hoverEvent":{"action":"show_text","contents":{"text":"hi","color":"gold"}},"clickEvent":{"action":"suggest_command","value":"/help"}} Hover & clickable text Semi-passing (hover only)*
7 Multi-page JSON page1 {"text":"Hello + page2 World"} "HelloWorld" Pass (fixed)
8 Malformed JSON {"text":"oops" "JSON Syntax Error" button, no output Pass (validator intact)
9 Banned key input: {"score":{"name":"@p","objective":"x"}} Banned Tag Error Pass (expected error)
10 Plain prose hello world "JSON Syntax Error" button Pass (expected error)

*Not sure why click events aren't working, didn't investigate. Could be neat to pre-fill chatbox with /dest locations if it did but also not why I'm here.

LLM Disclosure

Used claude-opus-4-7, verified changes and tested outcomes in client on a locally hosted Civ instance.

@mousebites
Copy link
Copy Markdown
Author

Let me know if there is anything else I can do to help with this, no pressure though if this is low priority!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[BUG] JSON Printing Plates don't parse JSON into formatted text

1 participant