Translating Written Books from command blocks into withTag() doesn't work
Ferrocn opened this issue ยท 3 comments
Intro:
Found a bug while trying to create a crafting guide book using the vanilla written book mechanics.
Using ZenScript I was trying to make the guide book craft-able.
Issue Description:
When .withTag() translates \ inside nbt, it converts it to \ as in the actual backslash character.
Problems occur with written book nbt format, as " is used to create the text in the book.
Hence, " gets converted to \" and breaks the entire book!
What happens:
Using this ZenScript:
print("Ferrocn> Begin: BugTest.zs =====");
val bugBook = <minecraft:written_book>.withTag({pages: ["{\"text\":\"A book to demonstrate the nbt format bug!\"}"], author: "Ferrocn", title: "bug report", resolved: 1 as byte});
recipes.addShapeless(bugBook, [<minecraft:book>, <minecraft:monster_egg:*>]);
mods.jei.JEI.addItem(bugBook);
print("Ferrocn> Done: BugTest.zs ======");
Gives this nbt to the written book ingame ( again obtained using /ct hand ):
<minecraft:written_book>.withTag({pages: ["{\\\"text\\\":\\\"A book to demonstrate the nbt format bug!\\\"}"], author: "Ferrocn", title: "bug report", resolved: 1 as byte})
Reading the book is actually like reading the original nbt tag..
What you expected to happen:
Below is out from /ct hand with the original book
<minecraft:written_book>.withTag({pages: ["{\"text\":\"A book to demonstrate the nbt format bug!\"}"], author: "Ferrocn", title: "bug report", resolved: 1 as byte})
This is what the .withTag(...) should produce..
Crafttweaker.log file:
Its pretty short, so I will put it here.. I hope that's OK
[INITIALIZATION][CLIENT][INFO] CraftTweaker: Building registry
[INITIALIZATION][CLIENT][INFO] CraftTweaker: Successfully built item registry
[INITIALIZATION][CLIENT][INFO] Loading scripts
[INITIALIZATION][CLIENT][INFO] [crafttweaker | SIDE_CLIENT]: Loading Script: {[0:crafttweaker]: BugTest.zs}
[INITIALIZATION][CLIENT][INFO] Ferrocn> Begin: BugTest.zs =====
[INITIALIZATION][CLIENT][INFO] Ferrocn> Done: BugTest.zs ======
[POSTINITIALIZATION][CLIENT][INFO] 0 really removed
[POSTINITIALIZATION][CLIENT][INFO] Adding shapeless recipe for bug report with name ct_shapeless422431868
[AVAILABLE][CLIENT][INFO] Adding <minecraft:written_book>.withTag({pages: ["{\\\"text\\\":\\\"A book to demonstrate the nbt format bug!\\\"}"], author: "Ferrocn", title: "bug report", resolved: 1 as byte}) to JEI
Affected Versions:
- Minecraft: 1.12.2
- Forge: 14.23.2.2611
- Crafttweaker2: 1.12 4.1.2 (4.1.2)
In the latest version of Crafttweaker2 (1.12 4.1.3) another similar case has popped now.
Where '\n' is used in nbt for a book, it is translated to \ \ \n by ZenScript.
Otherwise, the previous fix 69c2012 has worked fine!