Skip to content

Commit

Permalink
Some fixes and many improvements to the ingame manual / example book.
Browse files Browse the repository at this point in the history
  • Loading branch information
gigaherz committed Jan 22, 2017
1 parent b399b44 commit 2280f27
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven-publish'

version = "1.4.0"
version = "1.4.1"
group = "gigaherz.guidebook" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Guidebook-1.10.2"

Expand Down
59 changes: 39 additions & 20 deletions src/main/resources/assets/gbook/xml/guidebook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<title>Index</title>
<link ref="API">1. Adding new Books</link>
<link indent="8" ref="API:registry">1.1. Book Registry (for mods)</link>
<link indent="8" ref="API:configuration">1.2. Config. Folder (for modpacks)</link>
<link indent="8" ref="API:respack">1.3. Resource Packs (for adv. maps)</link>
<link indent="8" ref="API:respack">1.2. Resource Packs (for adv. maps)</link>
<link indent="8" ref="API:configuration">1.3. Config. Folder (for modpacks)</link>
<link ref="XML">2. Structure of the book</link>
<link indent="8" ref="XML:pages">2.1. Chapters and Pages</link>
<link indent="8" ref="XML:text">2.2. Paragraphs and titles</link>
Expand All @@ -42,10 +42,13 @@
<chapter id="API">
<page>
<title>Adding new books</title>
<p>Guidebook has 3 ways to declare new books, designed for different purposes:</p>
<link ref=":registry" indent="8">1. Using the book registry API.</link>
<link ref=":configuration" indent="8">2. Using the configuration folder.</link>
<link ref=":respack" indent="8" space="8">3. Using resource packs.</link>
<p>Guidebook has 3 ways to declare new books, designed for different purposes.</p>
<p>For modders:</p>
<link ref=":registry" indent="8" space="8">- Using the book registry API.</link>
<p>For adventure map authors:</p>
<link ref=":respack" indent="8" space="8">- Using resource packs.</link>
<p>For modpack authors:</p>
<link ref=":configuration" indent="8" space="8">- Using the configuration folder.</link>
<p space="8">Afterward, you can give the books to the player by using the creative menu, or using a command (command-block) with</p>
<p space="8">/give @p gbook:guidebook 1 0 {Book:"gbook:xml/book.xml"}</p>
<p>Finally, you can make the mod give new players one or more books the first time they join (applies retroactively to existing players if enabled).</p>
Expand All @@ -54,7 +57,6 @@
<page id="registry">
<title>Book Registry</title>
<p space="8">The preferred way to access the registry is through the BookRegistryEvent. An example of use is provided below:</p>

<p>@Optional.Method(modid="gbook")</p>
<p>@SubscribeEvent</p>
<p>public static void registerBook</p>
Expand All @@ -64,26 +66,43 @@
<p indent="16">new ResourceLocation(</p>
<p indent="24">"modid:xml/book.xml"));</p>
<p>}</p>

<space height="8" />

<p>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.</p>
<p>In order for this event to run, you need to annotate the class with @Mod.EventBusSubscriber.</p>

</page>
<page id="configuration">
<title>Configuration Folder</title>
<p>If you are a modpack author, you may want to add custom books available to everyone using your pack. This can be done by using the `config/guidebook/` folder. This folder will behave like a resource pack, except the contents inside will be limited to the `gbook` resource domain.</p>
<p>See the following section for details on how to declare books in a resource pack.</p>
</page>
<page id="respack">
<title>Resource Packs</title>
<p>Another 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.</p>
<p>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`.</p>
<p>This JSON-formatted file will contain a single array, with the list of books inside. It will look like this:</p>
<p indent="8">[ "domain1:path/book1.xml", "domain2:path/book2.xml", ... ]</p>
<p space="8">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.</p>
<p space="8">Books will be placed as resources inside a resourcepack resource domain. That is, in a folder like `assets/gbook/` or similar. Note that it must be lowercase.</p>
<p>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.</p>
</page>
<page>
<p>An example of structure is as follows:</p>
<p indent="8">assets/</p>
<p indent="16">gbook/</p>
<p indent="24">books.json</p>
<p indent="32">books/</p>
<p indent="40">book1.xml</p>
<p indent="48" space="8">book2.xml</p>
<p space="8">The most important resource will be the `books.json` file, which will have to reside at the root of any resource domain. This JSON-formatted file will contain a single array, with the list of books inside. It will look like this:</p>
<p indent="8" space="8">[ "gbook:books/book1.xml", "gbook:books/book2.xml", ... ]</p>
<p>These resources 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.</p>
<p>See the other sections of this document for information on the tags available, and read the source code of this book for a practical example.</p>
</page>
<page id="configuration">
<title>Configuration Folder</title>
<p space="8">If you are a modpack author, you may want to add custom books available to everyone using your pack. This can be done by using the `config/books/` folder (it may need to be created). This folder will behave like a resource pack, except the contents inside will be limited to the `gbook` resource domain.</p>
<p space="8">See the previous section for details on how to declare books in a resource pack.</p>
</page>
<page>
<p>The difference is, in this case, you would see this structure:</p>
<p indent="8">config/books/</p>
<p indent="16">books.json</p>
<p indent="24">books/</p>
<p indent="32">book1.xml</p>
<p indent="40" space="8">book2.xml</p>

<p>The contents of the 'books.json' would remain the same as if using a resource pack:</p>
<p indent="8" space="8">[ "gbook:books/book1.xml", "gbook:books/book2.xml", ... ]</p>
</page>
</chapter>
<chapter id="XML">
Expand Down

0 comments on commit 2280f27

Please sign in to comment.