Enchiridion

Enchiridion

7M Downloads

ENH: Add library support for mods using written vanilla books as user guide

ScottKillen opened this issue ยท 4 comments

commented

Better Chests provides a stack with custom NBT as its user guide. See this code for details.

It would be great if this book was found in the library automatically and if there were a way to add others like it in library_books.json.

commented

The data is the text of the book, localized dynamically. See the source code link I posted.

commented

OK...I think I see how you would do it...

commented

I struck out. In the case of this particular book, it is a written vanilla book. The mod formats it dynamically. It uses the standard vanilla gui and the pages and physical text of the book are in the item's NBT data.

It is probably not practical to have all of that in the json file. I would think, if you wanted to support this kind of book, it would mean using reflection obtain the itemstack directly from the mod.

If you did this, the library copy would actually be superior to the mod's version, because the library would have any updates, as the library's book would be regenerated at the start of each game.

Maybe have a new book type "reflection" and the have the json provide the class and member that takes no params but returns an itemstack?

commented

You can already add books with NBT.
Example:

data.addBook(new ModBookData("Botania", "Botania:lexicon 0 {knowledge.minecraft:1b,knowledge.alfheim:1b}", "network").setOpenGuiClass("vazkii.botania.client.gui.lexicon.GuiLexiconIndex").setOpenGuiNBT("knowledge.alfheim").setOverwrites("Botania:lexicon 0"));

There's the botania alfheim book. Though granted it wouldn't be easy, working out all the nbt data you would need.

Unless I misunderstood the request.