Interface FoliosPageElement
- All Known Implementing Classes:
BuildPageElement, EmptyPage, EntityPageElement, ErrorPage, ImagePageElement, LinksPageElement, MultiblockPageElement, QuestPageElement, RecipePageElement, SpotlightPageElement, SpreadPage, StructurePageElement, TextPage
public interface FoliosPageElement
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 (FoliosPageElements.register(Identifier, MapCodec)); its JSON object
is what the codec reads, with "type" naming it.
public record CounterPage(String title, int count) implements FoliosPageElement {
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(FoliosLayout layout) {
return layout.flow(title, 20, null, (painter, y) -> painter.text(Component.literal("× " + count), 10, y, painter.palette().text()));
}
}
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA page ready to draw.static interfaceSomething drawn on a page from a given height down, such as what comes before a page's text.static interfaceA 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 TypeMethodDescriptiondefault List<FoliosStack> items()The items this page is about: anywhere in the book, pressing one of them opens this page.lay(FoliosLayout layout) Sets the page out: one or more pages, each drawn on its own.default List<FoliosObjective> 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 StringWords of the page a search should find it by.default booleanspread()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
Words of the page a search should find it by. -
items
The items this page is about: anywhere in the book, pressing one of them opens this page. -
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.
-