Package net.ixdarklord.folios.api.client
Class FoliosLinks
java.lang.Object
net.ixdarklord.folios.api.client.FoliosLinks
Kinds of link a book's text can make:
[label](scheme:target) in any book goes to the kind registered for
scheme, which says what the link shows under the pointer and does when pressed.
// [the Fire spell](spell:mymod:fireball) shows the spell's cost and opens the mod's spell screen.
FoliosLinks.register("spell", new FoliosLinks.Kind() {
public List<Component> tooltip(FoliosBook book, String target) {
Spell spell = Spells.get(target);
return spell == null ? List.of() : List.of(spell.name(), Component.literal(spell.cost() + " mana"));
}
public boolean press(FoliosBook book, String target) {
Minecraft.getInstance().setScreen(new SpellScreen(target));
return true;
}
});
A kind can show a FoliosPopup in place of a tooltip: pressing its link then pins it, unless FoliosLinks.Kind.press(net.ixdarklord.folios.api.client.FoliosBook, java.lang.String)
does something else. Folios's own are entry:, category:, item: and web addresses, and the
popups entity:, structure:, build: and multiblock:; a scheme can't be registered twice.
Register while the client initialises.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA link's kind and the part of it after the scheme.static interfaceWhat a kind of link does. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable FoliosLinks.FoundThe kind a whole link (scheme:target) goes to, and its target; null when no kind takes it.static @Nullable FoliosLinks.KindThe kind a link's scheme names; null for Folios's built-in links and schemes no one registered.static voidregister(String scheme, FoliosLinks.Kind kind) Adds a kind of link,scheme:target; a scheme already taken (Folios's own too) is refused.
-
Method Details
-
register
Adds a kind of link,scheme:target; a scheme already taken (Folios's own too) is refused. -
get
The kind a link's scheme names; null for Folios's built-in links and schemes no one registered. -
find
The kind a whole link (scheme:target) goes to, and its target; null when no kind takes it.
-