Skip to content

Book Component Renders

Leo edited this page May 6, 2024 · 1 revision

The BookComponent Renders are an implementation for:

- `IBookCategory` -> `ICategoryRender`
- `IBookEntry` -> `IEntryRender`
- `IBookPage` -> `IPageRender`

There are some renders provided by the mod.

Category Renders

The mod provides to us two category renders: ImageCategoryRender and ItemCategoryRender

You can make your custom render with a class that implements the ICategoryRender interface.

There a little example of how a custom render class looks (empty):

public final class ExampleCustomCategoryRender implements ICategoryRender {

    public void render (GuiGraphics pGraphics, RegistryAccess pAccess, int pCategoryX, int pCategoryY, int pMouseX, int pMouseY, IBookCategory pCategory, IModScreen pScreen, Font pFont) {
        // Your render logic here.
    }

}

Entry Renders

The mod provides to us two entry renders like the category renders provided:

One of these renders is for Images and other for Items.
    - `ImageEntryRender`
    - `ItemCategoryRender`

These two entry renders extends the abstract `EntryRender` class.

There is a little example of a custom entry render class using the EntryRender class(empty):

public final class ExampleCustomEntryRender extends EntryRender {
    
    public ExampleCustomEntryRender ( Component pName ) {
        super(pName);
    }

    public void render (GuiGraphics pGraphics, RegistryAccess pAccess, int pEntryX, int pEntryY, int pMouseX, int pMouseY, IBookEntry pCategory, IModScreen pScreen, Font pFont) {
        // Your render logic here, the entry render class do the movement and logic of all the entry.
    }
}

Also you can make it for 0 using the IEntryRender interface, is valid.

Page Renders

The mod like all the other component renders have some renders for the pages.

TextRenders

TextPageRender

This render is really simple, just render text on the page.

ImagePageRender

This is another simple render, just render an imagen on the center of the page.

TextImagePageRender

This render is some like the `TextPageRender` the difference here is that just render an image below the text.

EntityRenders

EntityPageRender

This render is a render of an entity on the center of the page, nothing more.

EntityTextPageRender

The EntityTextPageRender is like the EntityPageRender but the entity is above the text.

Recipe Renders

RecipePageRender

This page render is a little more complex, this takes an Recipe Render and a Recipe to make the render.

JsonRecipePageRender

Custom Page Renders

Like all the other component renders, you can make your custom page renders implementing the IPageRender on a class.

public class ExampleEmptyPageRender implements IPageRender {
    public void render (GuiGraphics pGraphics, RegistryAccess pAccess, int pMouseX, int pMouseY, IModScreen pScreen, Font pFont) {}
}

However all this renders ( Or at least the majority ) are in the Example Book (doesn't care if is in NeoForge or fabric or any platform, it work in the same mode.)