Class FoliosLinks

java.lang.Object
net.ixdarklord.folios.api.client.FoliosLinks

public final class FoliosLinks extends Object
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(FoliosBook, 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.
  • Method Details

    • register

      public static void register(String scheme, FoliosLinks.Kind kind)
      Adds a kind of link, scheme:target; a scheme already taken (Folios's own too) is refused.
    • get

      public static @Nullable FoliosLinks.Kind get(String scheme)
      The kind a link's scheme names; null for Folios's built-in links and schemes no one registered.
    • find

      public static @Nullable FoliosLinks.Found find(String link)
      The kind a whole link (scheme:target) goes to, and its target; null when no kind takes it.