Old 1. Adding New Books To The Mod (Api And Resource Packs)
Guidebook has 3 ways to declare new books, designed for different purposes:
Afterward, you can give the books to the player by using the creative menu, or using a command (command-block) with
/give @p gbook:guidebook 1 0 {Book:"gbook:xml/book.xml"}
When using Guidebook for your mod, the preferred way to access the registry is through the BookRegistryEvent.
@Optional.Method(modid="gbook")
@SubscribeEvent
public static void registerBook(BookRegistryEvent event) {
event.register(new ResourceLocation("modid:xml/book.xml"));
}The @Optional annotation is needed to prevent a hard-dependency on the mod. The event parameter has a register method, that can be used to perform the registration.
In order for this event to run, you need to annotate the class with @Mod.EventBusSubscriber.
Remember to declare a dependency for Guidebook in the @Mod annotation of your main class (the same place you declare modid, name, and version). Add dependencies = "after:gbook" to the annotation, such that the whole thing looks something like this:
@Mod(modid = "modid", name = "name", version = "version", dependencies = "after:gbook")
If you are a modpack author, you may want to add custom books available to everyone using your pack. This can be done by placing the book xml files in the config/books/ folder. If you want to use images or cover pictures, you can place them inside the config/books/resources folder. Note that the filenames must be lowercase and contain no spaces.
For an example of this, click here.
The final way to provide books is to use a resource pack. This is useful for adventure map developers, and users who just want some extra books without unnecessary hassle.
The most important resource will be the books.json file, which will have to reside at the root of any resource domain. That is, in a folder like assets/[ANY NAME HERE]/books.json. Keep in mid that the resource domain must be lowercase, like minecraft.
This JSON-formatted file will contain a single array, with the list of books inside.
[ "domain1:path/book1.xml", "domain2:path/book2.xml" ]The books.json files are additive. That means an upper resource pack will not be able to remove books registered by a lower one, unlike normal resources which are replaced by upper packs.
For an example, click here.
If you don't know what resource domain to use, the preferred fallback should always be gbook and not minecraft. This is to avoid any potential future conflicts if Mojang ever decides to add resource-based custom books to the game.
An example of structure is as follows:
assets/
gbook/
books.json -- with contents [ "gbook:books/book1.xml", "gbook:books/book2.xml" ]
books/
book1.xml
book2.xml
If you use the configuration folder instead (for a modpack), this will be:
config/books/
books.json -- with contents [ "gbook:books/book1.xml", "gbook:books/book2.xml" ]
books/
book1.xml
book2.xml