Package net.ixdarklord.folios.api
Class FoliosSources
java.lang.Object
net.ixdarklord.folios.api.FoliosSources
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 ClassesModifier and TypeClassDescriptionstatic final classstatic final recordA row of a source: its id, and its fields by name. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidchanged(net.minecraft.resources.ResourceLocation id) Tells books a client source has changed, so pages observing it are written again.static voidchangedServer(net.minecraft.server.MinecraftServer server, net.minecraft.resources.ResourceLocation id) Sends a server source to every player again, after it changed.static booleanexists(net.minecraft.resources.ResourceLocation id) Whether anyone has given the source: Folios itself, a server, a client source, or a data pack.static voidregister(net.minecraft.resources.ResourceLocation 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 voidregisterServer(net.minecraft.resources.ResourceLocation id, Function<net.minecraft.server.MinecraftServer, List<FoliosSources.Row>> rows) Adds a source the server works out (data-driven content), sent to every player.static FoliosSources.BuilderA row to fill in:FoliosSources.row(id).field("name", ...).field("cost", 3).static List<FoliosSources.Row>rows(net.minecraft.resources.ResourceLocation id) A source's rows as the client has them, asrows(ResourceLocation, String)with nothing to narrow it.static List<FoliosSources.Row>A source's rows as the client has them: a source Folios gives itself (folios:items, ...), narrowed byof; 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.static List<FoliosSources.Row>serverRows(net.minecraft.server.MinecraftServer server, net.minecraft.resources.ResourceLocation 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.ResourceLocation>Every server source's id, a data pack's too.
-
Method Details
-
row
A row to fill in:FoliosSources.row(id).field("name", ...).field("cost", 3). -
register
public static void register(net.minecraft.resources.ResourceLocation 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.ResourceLocation id) Tells books a client source has changed, so pages observing it are written again. -
rows
A source's rows as the client has them, asrows(ResourceLocation, String)with nothing to narrow it. -
rows
public static List<FoliosSources.Row> rows(net.minecraft.resources.ResourceLocation id, @Nullable @Nullable String of) A source's rows as the client has them: a source Folios gives itself (folios:items, ...), narrowed byof; 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.ResourceLocation 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.ResourceLocation 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.ResourceLocation 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.ResourceLocation id) A server source's rows now (less those data packs removed, with those they added); for Folios's sending. -
serverSources
Every server source's id, a data pack's too.
-