JiFish / babel

A customisable pre-written book loot datapack for Minecraft
Other
7 stars 1 forks source link

Customization doesn't seem to work? #1

Closed thereddduke closed 2 years ago

thereddduke commented 2 years ago

Hello,

I'm currently working on a modpack and I was planning to add lore books to the dungeon loot tables I've made some attempts to customize this datapack with the said books but its doesn't seem to work. Starting with what said in the readme, I've just pasted the minecraft's command without the first part, but babel.exe closes immediately without leaving any message and it fails on generating the datapack. I've then tried to replicate the syntax on the classing books since those seem to work but, again, although the babel.zip datapack generates successfully, once installed in my minecraft world it doesn't do anything.

I would be really happy with this datapack, its really nice and basically exactly what I was searching, but currently I seem to be exerimenting some troubles.

The minecraft version is 1.16.5. The vanilla datapack (with all the Project's Gutenberg books) works perfectly, but as soon as I try to customize it is fails. I've also tried both with the windows version and the python one.

I'll leave here both the syntaxes used in the .json versions and in the books.json generated with the datapack.

First attempt (using https://minecraft.tools/en/book.php)

{pages:['{"text":"\nQuando le arche del nord giunsero\n\ne i nostri padri sulla terra tiepida\n\nposarono i primi passi della nostra storia\n\nRhelica era già dimora di altre forze\n "}','{"text":"\nben più antiche e potenti,\n\nemissari del vortice della creazione\n\nYingr, il grande Dio che risiedeva\n\nnel maelstrom sopra il grande monte.\n "}'],title:Kalakenheim,author:Ignoti}

Second attempt (replicating datapack's syntax)

{ "author": "Kalakenheim I", "title": "Ignoti", "pages": [ "{\"text\":\"Quando le arche del nord giunsero \\"ed i nostri padri sulla terra tiepida \\"posarono i primi passi della nostra storia \\"Rhelica era già dimora di altre forze\"}", "{\"text\":\"ben più antiche e potenti,\\"emissari del vortice della creazione \\"Yingr, il grande Dio che risiedeva \\"nel maelstrom sopra il grande monte.\"}" ] }

books.json result with second attempt (sorry, there are some other books that I've not included in the previous examples)

{"pools": [{"rolls": 1, "entries": [{"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim I\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"Quando le arche del nord giunsero \\\\"ed i nostri padri sulla terra tiepida \\\\"posarono i primi passi della nostra storia \\\\"Rhelica era gi\u00c3\u00a0 dimora di altre forze\\"}\", \"{\\"text\\":\\"ben pi\u00c3\u00b9 antiche e potenti,\\\\"emissari del vortice della creazione \\\\"Yingr, il grande Dio che risiedeva \\\\"nel maelstrom sopra il grande monte.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim X\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"La stella delle sabbie allora, carico \\\\"della volont\u00c3\u00a0 di una stirpe intera \\\\"e del rancore di un Dio che troppo a lungo \\\\"aveva sopportato la parentela con un essere\\"}\", \"{\\"text\\":\\"tanto disgustoso ed empio, sferro l\u00e2\u20ac\u2122ultimo colpo \\\\"aprendo e squarciando il cielo e la terra stesse \\\\"dilaniando le carni della bestia ed esiliandola \\\\"nella faglia dell\u00e2\u20ac\u2122un tempo monte del Dio.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim XI\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"Allora, la faglia dell Yiggdrevel \\\\"rivel\u00c3\u00b2 il mondo alle profondit\u00c3\u00a0 abissali \\\\"ove il dio lurido continua a belare e gridare.\\\\"Noi Aesir vivemmo finalmente in pace\\"}\", \"{\\"text\\":\\"e ci riunimmo vincitori, ormai non pi\u00c3\u00b9 \\\\"spaventati dalla stirpe del cielo.\\\\"Aeriathel fond\u00c3\u00b2 il suo grande impero \\\\"nelle terre ora pacifiche e pie.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim II\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"I suoi figli, che noi chiamammo El\u00e2\u20ac\u2122Yit \\\\"popolavano le rive bagnate dei fiumi,\\\\"le calde camere ardenti dei vulcani,\\\\"le rigogliose foreste ed i verdi prati,\\"}\", \"{\\"text\\":\\"cos\u00c3\u00ac come i bui anfratti delle caverne.\\\\"Non ci davano pace, poich\u00c3\u00a9 cos\u00c3\u00ac \\\\"il destino aveva mosso i suoi fili \\\\"Himinn, madre della creazione e tessitrice.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim III\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"E cos\u00c3\u00ac come i fratelli che mai smisero \\\\"di darsi battaglia, sulle coste impetuose \\\\"e sulle ripide e gelide montagne. Cos\u00c3\u00ac \\\\"noi, figli del Dio del mare V\u00c3\u00ad\u00c3\u00b0ir,\\"}\", \"{\\"text\\":\\"sfidammo la stirpe di Yingr.\\\\"Ma le forze della stirpe del cielo \\\\"erano ben superiori, e noi, poveri mortali \\\\"venimmo scacciati e colpiti, feriti e uccisi.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim IV\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"Fu allora che, come un astro che illumina \\\\"la via ai marinai dispersi, cos\u00c3\u00ac un grande re \\\\"pos\u00c3\u00b2 la mano sulla lama, indoss\u00c3\u00b2 l\u00e2\u20ac\u2122armatura \\\\"e guid\u00c3\u00b2 verso il destino il popolo prediletto.\\"}\", \"{\\"text\\":\\"Il suo nome era Aeriathel, figlio di Aerias,\\\\"re di un piccolo ma coraggioso popolo del deserto.\\\\"La stella delle sabbie, cos\u00c3\u00ac lo chiamammo,\\\\"solc\u00c3\u00b2 il mare, sterminando l\u00e2\u20ac\u2122odiata stirpe\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim V\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"e circondandosi di alleati e seguaci \\\\"ovunque il suo cammino posasse passo.\\\\"Con una grande flotta, incalzato dal vento dello \\\\"stesso dio padre, la stella delle sabbie mosse\\"}\", \"{\\"text\\":\\"verso la grande montagna celeste, Yiggdrevel \\\\"ove il Dio vigliacco, nemico e fratello \\\\"sedeva in attesa della nostra fine, cibandosi \\\\"delle anime delle nostri mogli e dei nostri figli.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim VI\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"La stella delle sabbie allora, seguito \\\\"dalla nostra stirpe intera, compagni e fratelli,\\\\"mogli e madri, padri e amici, scal\u00c3\u00b2 \\\\"la montagna gelida ed infame, e l\u00c3\u00ac\\"}\", \"{\\"text\\":\\"diede battaglia ad un Dio. I figli del creato \\\\"Aesir e El\u00e2\u20ac\u2122Yit, combatterono allora \\\\"in quella che ricorderanno tutti,\\\\"finch\u00c3\u00a8 il tempo stesso scorrer\u00c3\u00a0,\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim VII\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"come la guerra delle ere, il Kalakenheim.\\\\"Allora lo stesso dio padre V\u00c3\u00ad\u00c3\u00b0ir ascolt\u00c3\u00b2 \\\\"la chiamata dei suoi figli, lo sforzo \\\\"di un intera stirpe. Scese, ed impugnato\\"}\", \"{\\"text\\":\\"il corpo intero della stella delle sabbie \\\\"il nostro re, faccia a faccia con l\u00e2\u20ac\u2122immondo \\\\"re del cielo, squarci\u00c3\u00b2 e trafisse le carni,\\\\"mostrando che anche un Dio pu\u00c3\u00b2 sanguinare.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim VIII\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"Il mostro era orrendo. Accecato dall\u00e2\u20ac\u2122arroganza \\\\"di chi vive troppo a lungo bagnato \\\\"dalla luce del paradiso, il suo viso era quello \\\\"di una capra di montagna alla quale\\"}\", \"{\\"text\\":\\"erano stati cavati gli occhi. Le corna erano lunghe \\\\"seghettate, appuntite. La bava colava dalle fauci \\\\"crudeli, era rossa come il sangue.\\\\"Il suo corpo, grasso e putrescente.\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}, {"type": "item", "name": "minecraft:written_book", "weight": 1, "functions": [{"function": "minecraft:set_nbt", "tag": "{\"author\": \"Kalakenheim IX\", \"title\": \"Ignoti\", \"pages\": [\"{\\"text\\":\\"Era armato di una lunga spada arrugginita \\\\"E con essa, ributtante e immondo,\\\\"sferzava goffamente colpo dopo colpo \\\\"tentando con ogni sforzo e belando\\"}\", \"{\\"text\\":\\"di frustrazione, nel tentativo di uccidere \\\\"l\u00e2\u20ac\u2122avatar del potente e imperioso \\\\"Dio del mare e delle tempeste.\\\\"La sua sola esistenza insultava il luogo in cui dimorava\\"}\"], \"generation\": 3}"}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 2}", "conditions": [{"condition": "random_chance", "chance": 0.3}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 1}", "conditions": [{"condition": "random_chance", "chance": 0.01}]}, {"function": "minecraft:set_nbt", "tag": "{\"generation\": 0}", "conditions": [{"condition": "random_chance", "chance": 0.003}]}]}]}]}

Thank you dearly for your help.

:)

JiFish commented 2 years ago

I'll look in to it. Thanks for the report.

JiFish commented 2 years ago

There are two issues here:

  1. Babel doesn't report invalid JSON. #2
  2. Minecraft book editor outputs invalid JSON. Although minecraft reads it fine, python does not. #3

I will fix the first issue. I'd also like to fix the second, but can make no promises.

In the meantime, custom books do work so long as the JSON is strictly valid. You can use a service like https://jsonformatter.curiousconcept.com/ to fix the JSON for you. Paste the JSON in the box, hit 'Process' then click the 'Copy to clipboard' button next to the output to copy the valid JSON.

I have fixed up the first example you provided using this method, which now works. (Tested in latest version)

{
    "pages":[
        "{\"text\":\"\nQuando le arche del nord giunsero\n\ne i nostri padri sulla terra tiepida\n\nposarono i primi passi della nostra storia\n\nRhelica era già dimora di altre forze\n \"}",
        "{\"text\":\"\nben più antiche e potenti,\n\nemissari del vortice della creazione\n\nYingr, il grande Dio che risiedeva\n\nnel maelstrom sopra il grande monte.\n \"}"
    ],
    "title":"Kalakenheim",
    "author":"Ignoti"
}
thereddduke commented 2 years ago

Thank you dearly for your answer :)

Unfortunately this still appears to have not solved the problem. I dont really know what I'm missing. I've pasted the command as you told me to in the JSON validator, then downloaded directly from there the JSON file and renamed it. Babel ran correctly but, when I tested the datapack, the books were not spawning. I tried this process on the master version and the windows versione 0.4. I'll leave here the JSON used.

{ "pages":[ "{\"text\":\"Quando le arche del nord giunsero\n\ne i nostri padri sulla terra tiepida\n\nposarono i primi passi della nostra storia\n\nRhelica era già dimora di altre forze\n \"}", "{\"text\":\"ben più antiche e potenti,\n\nemissari del vortice della creazione\n\nYingr, il grande Dio che risiedeva\n\nnel maelstrom sopra il grande monte.\"}" ], "title":"Kalakenheim", "author":"Ignoti" }

Thank you dearly for you help :)

JiFish commented 2 years ago

The JSON you posted is still invalid. Compare the version you posted to the one I posted.

thereddduke commented 2 years ago

I've also tried with yours and it doesn't really make any difference. The book just doesn't want to spawn.

JiFish commented 2 years ago

Do they spawn with the orginal library?

thereddduke commented 2 years ago

Yesterday they spawned. I'll do a quick check right now

thereddduke commented 2 years ago

They do spawn with the original library.

I dont know if this might be the case but could it be that its just really rare for a book to spawn if there's only on the library? At the moment I'm testing with 1/5 books at most.

JiFish commented 2 years ago

No, the number of books in the library shouldn't effect the spawn rate.

OK, there must be something else going on. Could you please attach your output zip file to a comment? I will take a deeper look in to it over the weekend.

thereddduke commented 2 years ago

Sure, I'll attach both the babel.zip and the original book. Thank you dearly for your help :)

babel.zip books.zip

thereddduke commented 2 years ago

Hello JiFish, how are you? I just wanted to ask if there were any update on the issue. I dont want to press you, just as we spoke of looking further into it in the weekend I was wondering if you maybe had the time. Thank you dearly for your help :)

JiFish commented 2 years ago

OK, I've had a chance to look in to this. There are two additional problems.

Firstly, the JSON validator I pointed you to didn't do a great job of fixing up the JSON. The newlines didn't have enough escape characters. It should look like this. (Note \\n instead of \n.)

{
    "pages":[
        "{\"text\":\"\\nQuando le arche del nord giunsero\\n\\ne i nostri padri sulla terra tiepida\\n\\nposarono i primi passi della nostra storia\\n\\nRhelica era già dimora di altre forze\\n \"}",
        "{\"text\":\"\\nben più antiche e potenti,\\n\\nemissari del vortice della creazione\\n\\nYingr, il grande Dio che risiedeva\\n\\nnel maelstrom sopra il grande monte.\\n \"}"
    ],
    "title":"Kalakenheim",
    "author":"Ignoti"
}

Secondly, Babel isn't handling non-ASCII characters properly. This is a bug #4 . I have already written a fix for this. Here it is fully working:

2022-03-13_23 26 55

Thank you for letting me know about the bugs. I am hopefully going to find time to release a new version with fixes for all the problems during next week. Then everything ought to work as described in the readme. But please keep in mind: this is a hobby. I can't make any promises as real life comes first.

If you're absolutely desperate and can't wait you could work around the problems by:

  1. Ensuring that \n are changed to \\n in your book files
  2. Download the development version and use that instead: https://github.com/JiFish/babel/archive/refs/heads/0.5-dev.zip (Python required.)

I will keep this issue open so I can let you know when version 0.5 is released.

thereddduke commented 2 years ago

Hello,

Thank you really much for all the effort and help, its really nice to see mod developers caring about their projects. Since the issue is solvable I should be able to go on with the developing of the modpack with the indication you've given to me. To be honest I kinda am in a hurry (our project should be released in the near future so as soon as I get these books done its ready to go), but I perfectly understand that its an hobby, and I'm really grateful for all the effort you've putted nontheless.

Thank you very much, really :) I will update you if I discover something new.

Have a nice week!

thereddduke commented 2 years ago

It works...

I just cant describe how happy I am atm :, )

JiFish commented 2 years ago

I have released version 0.5, which now properly supports json copied directly from https://minecraft.tools/en/book.php - no need for any fixes or modifications. It also includes the other fixes from the thread.

Thank you again for bringing the problems to my attention. If you get a chance, please give the new version a go and let me know how you get on with it. :)

JiFish commented 2 years ago

Oh, and please link me to your mod-pack when it's finished. I'd be interested to see it!

thereddduke commented 2 years ago

Of course, the books are in Italian but maybe we will be able to do something about the localization. As soon as its ready I will post it here :)

Thank you dearly for all the support :)