-
Notifications
You must be signed in to change notification settings - Fork 16
Old 2. Book XML structure
Book files are XML documents.
At the root is the 'book' tag. This tag has two optional attributes: 'title', for the name shown in the item tooltip, and 'cover', for the resource location of a cover texture.
<book title="Demo Book" cover="modid:texture">
...
</book>
The title will show up as the tooltip when hovering over your book in an inventory (or anywhere else the ItemStack is displayed). The cover image file is located at src/main/resources/assets/modid/textures and can be any size so long as it has a 1:1 pixel resolution (64x64, 256x256, 1024x1024, and so on). Do not include ".png" in the cover attribute, as it is implied.
Books are split into chapters. At least one chapter must be present. Chapters have an optional 'id' attribute for use in links.
Chapters are split into pages. Pages can also have an 'id' attribute.
<chapter id="ch1">
<page>
...
</page>
...
</chapter>
Inside pages there can be text, alongside other page elements. The primary way of adding text is through paragraph elements 'p'.
<p>Text</p>
There's many reasons to want different colors and alignments. This can be accomplished with the 'color' and 'align' attributes.
<p color="#606060" align="center">Centered Gray Text</p>
You can also customize the text appearance, using the 'bold', 'italics', and 'underline' attributes
<p bold="true" italics="true">Formatted Text</p>
Sometimes, you need indented text, or you want to change the separation between successive paragraphs, for this, you have 'indent' and 'space', respectively.
<p indent="20" space="20">Indented spaced text</p>
<p>Text After</p>
You can also change size of the text using 'scale'.
<p align="center" scale="2">Scale 2</p>
<p align="center" scale="1.5">Scale 1.5</p>
<p align="center" scale="1">Scale 1</p>
Finally, to avoid writing so many formatting codes. Section titles can be shortened with the 'title' tag, which has different default formattings.
<title>Title Here</title>
Image tags let you draw a piece of an image. The 'x', 'y', 'w', 'h' attributes define the location and size to draw.
The location to draw from the texture is taken from the 'tx' and 'ty' attributes, if not zero. If the image size is not exactly 256x256, you will have to specify the total size of the texture in 'tw' and 'th' attributes.
Image tags are relative to the current vertical position, but they do not increment the vertical position.
<image src="minecraft:items/coal" tw="16" th="16" />
To add your own .png images put them in the config\books\resources\textures
folder. In your XML, use the format "gbook:yourimagename"
as the img src attribute. Replacing yourimagename with the filename of course.
The name should be lowercase. Do not include the .png extension. Subfolders are supported.
<image src="gbook:demo" tw="16" th="16" />
This shows the demo.png file.
Links allow pointing to other places in the book, or to external websites.
<link ref="chapter[:page]">Book Link</link>
<link href="http://github.com/">Web Link</link>
Stack tags let you show an ItemStack in the book. The stack will show the icon and count, and if hovered, the tooltip. The 'stack' tag supports the following attributes:
item (vanilla or mod item)
meta (integer)
count (integer)
tag (string)
ore (string, for OreDictionary keys)
Like images, stack tags are relative to the current vertical position, but they do not increment the vertical position.
<stack item="minecraft:coal" meta="0" count="2" />