Read books while moving!
Book Display natively supports:
- Bibliocraft
- Big Writing Book
- Clipboard
- Recipe Book
- Redstone: Volume I
- Slotted Book
- Lexica Botania from Botania
- Engineer's Manual from Immersive Engineering
- Any book from Mantle (e.g. Materials and You from Tinkers' Construct)
- OpenComputers Manual from OpenComputers
- Any book from Patchouli
- The Akashic Tome
- TIS-3D
- TIS-3D Reference Manual
- Code Bible
To add your own book gui to the Book Display registry, you first need to add Book Display to your dev enviroment as a dependency.
repositories {
// ...
maven {
name 'Astavie' // You can name it whatever you want
url 'https://raw.githubusercontent.com/Astavie/Astavie.github.io/mvn-repo/'
}
}
dependencies {
// ...
compile 'astavie:bookdisplay:<version>:deobf'
}
Next, you register your book gui with BookDisplay.register(predicate, factory);
A java 8 predicate, with an ItemStack
as its input. This predicate should return true
if the ItemStack
opens your book gui on a right click.
A java 8 function, with an ItemStack
as its input and an IBookWrapper
as its output (more on them later). Returns an instance of IBookWrapper
using the ItemStack
previously checked against.
BookWrapper
is a class that transforms a GuiScreen
instance into an overlay that can be drawn on the ingame gui. Its constructor has two parameters: gui
, a new instance of your book gui, and drawsBackground
, a boolean. If your GUI draws a grey background when its opened, you should put true
here, so Book Display can remove the background in the overlay.
If you want to add page scrolling, you should override the left()
and right()
methods. These methods should switch the page, either to the left or right of the current page.
Sometimes, there are buttons in your GUI that you don't want to display on the overlay. In the makeButtonInvisible(button)
method, you can choose per button which ones should be made invisible.
IBookWrapper
is an interface that contains rendering methods that are invoked when drawing the ingame gui. The class contains 5 extra methods you need to override, apart from left()
and right()
.
This method should draw the gui on the left or right side of the screen as specified by the side
parameter. If you want to use rendering methods from the vanilla Gui
class, you can simply make your wrapper extend Gui
.
Invoked when the window resolution changes.
Invoked when the overlay is opened, before its been rendered.
Invoked every tick while the overlay is opened.
Invoked when the overlay is closed, after its been rendered.