Class FoliosSources

java.lang.Object
net.ixdarklord.folios.api.FoliosSources

public final class FoliosSources extends Object
Live lists a book's pages can show: a page element with "observe": {"source": "mymod:spells", "row": "..."} writes a line for each row of the source, and is written again whenever the list changes, so content added by addons or data packs shows in the book without anyone editing it.

A source is rows, each an id and named fields (text, which may be markup or a translation key):

// On the client: rows the client knows (registries, client config, what addons register).
FoliosSources.register(MyMod.id("spells"), () -> Spells.all().stream()
        .map(spell -> FoliosSources.row(spell.id().toString()).field("name", spell.nameKey()).field("mana", spell.cost()))
        .toList());
FoliosSources.changed(MyMod.id("spells"));                  // an addon added one

// On the server: rows that live there (data-driven content), sent to every player by Folios.
FoliosSources.registerServer(MyMod.id("rituals"), server -> Rituals.all(server).stream()
        .map(ritual -> FoliosSources.row(ritual.id().toString()).field("name", ritual.title()))
        .toList());
FoliosSources.changedServer(server, MyMod.id("rituals"));   // resent to everyone
Server sources are sent to each player as they join and after every data pack reload. A data pack can also add rows to any source with no code: data/<namespace>/folios/sources/<name>.json, {"source": "mymod:rituals", "rows": [{"id": "mypack:moon", "name": "Moonlit"}]}; a row with an id already in the source takes its place, {"id": "mymod:old", "remove": true} takes a row out (whoever gave it), and "requires_mods": ["create"], on a file or a row, leaves it out unless those mods are loaded.

Folios gives a few sources itself, worked out from the game: folios:items, folios:blocks, folios:entities and folios:advancements, narrowed by the page's "of" (a tag or a mod).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     
    static final record 
    A row of a source: its id, and its fields by name.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    changed(net.minecraft.resources.Identifier id)
    Tells books a client source has changed, so pages observing it are written again.
    static void
    changedServer(net.minecraft.server.MinecraftServer server, net.minecraft.resources.Identifier id)
    Sends a server source to every player again, after it changed.
    static boolean
    exists(net.minecraft.resources.Identifier id)
    Whether anyone has given the source: Folios itself, a server, a client source, or a data pack.
    static void
    register(net.minecraft.resources.Identifier id, Supplier<List<FoliosSources.Row>> rows)
    Adds a source the client works out itself (call on the client; asked when a page observing it is laid out).
    static void
    registerServer(net.minecraft.resources.Identifier id, Function<net.minecraft.server.MinecraftServer, List<FoliosSources.Row>> rows)
    Adds a source the server works out (data-driven content), sent to every player.
    row(String id)
    A row to fill in: FoliosSources.row(id).field("name", ...).field("cost", 3).
    rows(net.minecraft.resources.Identifier id)
    A source's rows as the client has them, as rows(Identifier, String) with nothing to narrow it.
    rows(net.minecraft.resources.Identifier id, @Nullable String of)
    A source's rows as the client has them: a source Folios gives itself (folios:items, ...), narrowed by of; then those the server sent; then those of a client source of the same id, a row whose id is already there taking its place; less those data packs removed.
    serverRows(net.minecraft.server.MinecraftServer server, net.minecraft.resources.Identifier id)
    A server source's rows now (less those data packs removed, with those they added); for Folios's sending.
    static List<net.minecraft.resources.Identifier>
    Every server source's id, a data pack's too.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • row

      public static FoliosSources.Builder row(String id)
      A row to fill in: FoliosSources.row(id).field("name", ...).field("cost", 3).
    • register

      public static void register(net.minecraft.resources.Identifier id, Supplier<List<FoliosSources.Row>> rows)
      Adds a source the client works out itself (call on the client; asked when a page observing it is laid out).
    • changed

      public static void changed(net.minecraft.resources.Identifier id)
      Tells books a client source has changed, so pages observing it are written again.
    • rows

      public static List<FoliosSources.Row> rows(net.minecraft.resources.Identifier id)
      A source's rows as the client has them, as rows(Identifier, String) with nothing to narrow it.
    • rows

      public static List<FoliosSources.Row> rows(net.minecraft.resources.Identifier id, @Nullable String of)
      A source's rows as the client has them: a source Folios gives itself (folios:items, ...), narrowed by of; then those the server sent; then those of a client source of the same id, a row whose id is already there taking its place; less those data packs removed. Empty for a source no one has given.
    • exists

      public static boolean exists(net.minecraft.resources.Identifier id)
      Whether anyone has given the source: Folios itself, a server, a client source, or a data pack.
    • registerServer

      public static void registerServer(net.minecraft.resources.Identifier id, Function<net.minecraft.server.MinecraftServer, List<FoliosSources.Row>> rows)
      Adds a source the server works out (data-driven content), sent to every player.
    • changedServer

      public static void changedServer(net.minecraft.server.MinecraftServer server, net.minecraft.resources.Identifier id)
      Sends a server source to every player again, after it changed.
    • serverRows

      public static List<FoliosSources.Row> serverRows(net.minecraft.server.MinecraftServer server, net.minecraft.resources.Identifier id)
      A server source's rows now (less those data packs removed, with those they added); for Folios's sending.
    • serverSources

      public static List<net.minecraft.resources.Identifier> serverSources()
      Every server source's id, a data pack's too.