Interface GuidePage

All Known Implementing Classes:
BuildPageElement, EmptyPage, EntityPageElement, ErrorPage, ImagePageElement, LinksPageElement, MultiblockPageElement, QuestPageElement, RecipePageElement, SpotlightPageElement, SpreadPage, StructurePageElement, TextPage

public interface GuidePage
A page of an entry, as its JSON describes it. Before it is shown it is laid out: set to the page size in the reader's language, which may take more than one page (text that runs on continues over the next). That is done once per book and language, not every frame.

A mod adds its own kind of page by registering a codec for it (GuidePageTypes.register(net.minecraft.resources.ResourceLocation, com.mojang.serialization.MapCodec<? extends net.ixdarklord.folios.api.client.page.GuidePage>)); its JSON object is what the codec reads, with "type" naming it.


 public record CounterPage(String title, int count) implements GuidePage {
     public static final MapCodec<CounterPage> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
             Codec.STRING.fieldOf("title").forGetter(CounterPage::title),
             Codec.INT.fieldOf("count").forGetter(CounterPage::count)).apply(i, CounterPage::new));

     public List<Laid> lay(GuideLayout layout) {
         return layout.flow(title, 20, null, (painter, y) -> painter.text(Component.literal("× " + count), 10, y, painter.palette().text()));
     }
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A page ready to draw.
    static interface 
    Something drawn on a page from a given height down, such as what comes before a page's text.
    static interface 
    A laid page that is half of a spread: the book draws its frame joined with the other half's over the fold, and one page number for both, at the fold.
  • Method Summary

    Modifier and Type
    Method
    Description
    default List<GuideStack>
    The items this page is about: anywhere in the book, pressing one of them opens this page.
    lay(GuideLayout layout)
    Sets the page out: one or more pages, each drawn on its own.
    What the page asks the player to do, if it is a quest: an entry with objectives shows how far along they are on its row, and a toast says when they are all done.
    default String
    Words of the page a search should find it by.
    default boolean
    Whether the page spreads over both pages of an open book: its laid pages then come in pairs, a left page and the right page beside it, and it starts on a left page (an empty page is put before it if need be).
  • Method Details

    • lay

      Sets the page out: one or more pages, each drawn on its own.
    • spread

      default boolean spread()
      Whether the page spreads over both pages of an open book: its laid pages then come in pairs, a left page and the right page beside it, and it starts on a left page (an empty page is put before it if need be).
    • searchText

      default String searchText()
      Words of the page a search should find it by.
    • items

      default List<GuideStack> items()
      The items this page is about: anywhere in the book, pressing one of them opens this page.
    • objectives

      default List<GuideObjective> objectives()
      What the page asks the player to do, if it is a quest: an entry with objectives shows how far along they are on its row, and a toast says when they are all done.