Package net.ixdarklord.folios.api
Class FoliosBooks
java.lang.Object
net.ixdarklord.folios.api.FoliosBooks
Guide books from either side: the item that carries one, and opening one for a player from the server.
A book lives in resource packs, at assets/<namespace>/folios/<path>/book.json (id
<namespace>:<path>), with its categories and entries beside it; the client reads them and draws them (see
net.ixdarklord.folios.api.client.FoliosGuides). The server only knows books by id.
player.addItem(FoliosBooks.createStack(MyMod.id("handbook")));
player.addItem(FoliosBooks.createStack("mymod:handbook"));
player.addItem(FoliosBooks.createStack(MyItems.HANDBOOK.get(), MyMod.id("handbook")));
FoliosBooks.open(player, MyMod.id("handbook"), "basics/first_steps");
In commands: /give @s folios:guide_book{folios_book:"mymod:handbook"}.-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable net.minecraft.resources.ResourceLocationbookOf(net.minecraft.world.item.ItemStack stack) The book a stack names: in its NBT (folios_book), on any item, or else the book aFoliosBookItemof a mod's own always opens (so its stacks need no NBT to show their cover); null when none.static net.minecraft.world.item.ItemStackcreateStack(String book) AscreateStack(ResourceLocation), the book given as"namespace:path".static net.minecraft.world.item.ItemStackcreateStack(net.minecraft.resources.ResourceLocation book) Folios's guide book item, opening the given book.static net.minecraft.world.item.ItemStackcreateStack(net.minecraft.world.level.ItemLike item, net.minecraft.resources.ResourceLocation book) A mod's own item carrying a book in its NBT (folios_book): aFoliosBookItemof its own opens that book and takes its name.static voidopen(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation book) Opens a book on a player's screen at its first page.static voidopen(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation book, @Nullable String entry) Opens a book on a player's screen at an entry ("category/entry", its path under the book'sentries/), or at its start for null.
-
Method Details
-
createStack
public static net.minecraft.world.item.ItemStack createStack(net.minecraft.resources.ResourceLocation book) Folios's guide book item, opening the given book. -
createStack
AscreateStack(ResourceLocation), the book given as"namespace:path". -
createStack
public static net.minecraft.world.item.ItemStack createStack(net.minecraft.world.level.ItemLike item, net.minecraft.resources.ResourceLocation book) A mod's own item carrying a book in its NBT (folios_book): aFoliosBookItemof its own opens that book and takes its name. (On any other item it only names the book, forbookOf(net.minecraft.world.item.ItemStack).) -
bookOf
@Nullable public static @Nullable net.minecraft.resources.ResourceLocation bookOf(net.minecraft.world.item.ItemStack stack) The book a stack names: in its NBT (folios_book), on any item, or else the book aFoliosBookItemof a mod's own always opens (so its stacks need no NBT to show their cover); null when none. -
open
public static void open(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation book) Opens a book on a player's screen at its first page. -
open
public static void open(net.minecraft.server.level.ServerPlayer player, net.minecraft.resources.ResourceLocation book, @Nullable @Nullable String entry) Opens a book on a player's screen at an entry ("category/entry", its path under the book'sentries/), or at its start for null. Does nothing for a client without Folios.
-