-
Notifications
You must be signed in to change notification settings - Fork 16
Old 0. Home
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.
Specify the text in the book tag, like <book title="This is an example">
.
Specify the location in the book tag, like <book cover="gbook:test">
, the png extension is implied.
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">
, ...).
Use the image tag, as in <image src="minecraft:items/coal" tw="16" th="16"/>
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>
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">
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
.
Use the BookRegistryEvent
. It only gets called on the client.
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.
If you want to spawn one book, you can give it to yourself ingame:
/give @p gbook:guidebook{Book:"gbook:demobook.xml"} 1
If you want all new players to get the book (or existing players if you added a book after the fact), use the server config file:
[general]
#List of books to give to the player when they join. Applied retroactively to existing players if a new book is added to the list.
give_on_first_join = [ "the:book.xml" ]
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):
public static final RegistryObject<GuidebookItem> GUIDEBOOK_ITEM = RegistryObject.of(new ResourceLocation("gbook","guidebook"), ForgeRegistries.ITEMS);
public static final Lazy<ItemStack> MY_BOOK = Lazy.of(() -> GUIDEBOOK_ITEM.map(item -> {
ItemStack stack = new ItemStack(item);
CompoundNBT tag = stack.getOrCreateTag();
tag.putString("Book", "my:book.xml");
return stack;
}).orElse(ItemStack.EMPTY));
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
public static void checkGbookGiven(EntityJoinWorldEvent event)
{
if (MY_BOOK.get().getCount() > 0)
{
final Entity entity = event.getEntity();
final String bookPlayerTag = "MODID:someTagLikeGbookGiven";
if (entity instanceof PlayerEntity && !entity.getEntityWorld().isRemote && !entity.getTags().contains(bookPlayerTag))
{
ItemHandlerHelper.giveItemToPlayer((PlayerEntity) entity, MY_BOOK.get().copy());
entity.addTag(bookPlayerTag);
}
}
}