David Quintana edited this page Jun 19, 2018 · 12 revisions

Welcome to the Guidebook wiki!

This wiki is a work in progress.

The contents of this wiki are an almost-verbatim copy of the contents of the in-game Guidebook manual.

See the Table of Contents on the right for the main help topics.

Very Incomplete FAQ / Cheat Sheet

How do I give a book a title?

Specify the text in the book tag, like <book title="This is an example">.

How do I give a book a cover image?

Specify the location in the book tag, like <book cover="gbook:test">, the png extension is implied.

How do I format text?

You can use bold, italics, underline, color, indent, scale and align, in either the paragraph elements (<p color="#FF00FF">) or the span elements (<span bold="true">, <link underline="true">, ...).

How do I insert an image?

Use the image tag, as in <image src="minecraft:items/coal" tw="16" th="16"/>

How do I insert a recipe?

Use the recipe tag, as in

<recipe type="gbook:crafting" key="minecraft:quartz_block"/>

or

<recipe type="shaped">
    <recipe.result>
        <stack item="minecraft:comparator"/>
    </recipe.result>
</recipe>

How do I make part of the book show conditionally?

First, declare a condition in the top level of the document (inside <book>):

<conditions>
    <item-exists name="ingot_exists" registry-name="minecraft:iron_ingot"/>
</conditions>

Then, you can use the condition in a chapter, section, or paragraph:

<chapter condition="ingot_exists">

How do I make the book in multiple languages?

The mod will look for files with the right language code in the filename, when trying to load the book.

If the user language is ca_es, the mod will load gbook:demo.ca_es.xml if present, instead of gbook:demo.xml.

How do I add a book into a mod?

Use the BookRegistryevent. It only gets called on the client.

How do I add a book into a modpack?

Use the configuration folder. The mod looks for XML files in <instance>/config/books/, and it will look for images in <instance>/config/books/resources/textures/. See the page on adding books for more detail.

How do I get the book?

If you want to spawn one book, you can give it to yourself ingame:

/give @p gbook:guidebook 1 0 {Book:"gbook:whatever.xml"}

How do I give the book to all players when they join?

If you want all new players to get the book (or existing players if you added a book after the fact), use the config file:

books {
   S:GiveOnFirstJoin <
      gbook:whatever.xml
   >
}

... And as a mod?

I don't like mods giving people items by default (modpacks can use the config if they want), but since people will inevitably keep asking...

First ask forge to give you an itemstack of the book (ItemStackHolder helps keep this as a soft dependency):

@GameRegistry.ItemStackHolder(value = "gbook:guidebook", nbt = "{Book:\"MODID:pathToTheBook.xml\"}")
public static ItemStack gbookStack;

Then, give yourself a handler for EntityJoinWorldEvent, and use some system such as the entity tags, to mark the player persistently:

// Give one gbook per player on first join
@SubscribeEvent
@Optional.Method(modid = "gbook")
public static void checkGbookGiven(EntityJoinWorldEvent event)
{
    final Entity entity = event.getEntity();
    final String bookPlayerTag = "MODID:someTagLikeGbookGiven";

    if (entity instanceof EntityPlayer && !entity.getEntityWorld().isRemote && !entity.getTags().contains(bookPlayerTag))
    {
        ItemHandlerHelper.giveItemToPlayer((EntityPlayer) entity, gbookStack.copy());
        entity.addTag(bookPlayerTag);
    }
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.