YAB Lib

YAB Lib (Yet Another Book Lib) is a NeoForge library for in-game guidebooks. Mods supply their own chapters, artwork and optional build diagrams.

How to use YAB Lib

YAB Lib (Yet Another Book Lib) is a NeoForge library for in-game guidebooks. Mods supply their own chapters, artwork and optional build diagrams.

For players

  1. Install YAB Lib 0.2.1 and a mod that provides a compatible guidebook. Use Minecraft 26.1.2 with NeoForge 26.1.2.126 or newer. For multiplayer, install both mods on the server and on each client.
  2. Get the book through the content mod, then hold it and right-click. Browse Guide and Lore or search for a chapter. Locked chapters show a hint for how to unlock them.
  3. Select Build layout when a chapter offers it. Drag to rotate the 3D preview and scroll to zoom. Switch to Top view or Side view to measure the layout, with one block per square. Select Instructions to return to the same reading page.

Each player has their own progress for each book. A replacement copy opens at your saved reading position.

alt text

Field Notes with the chapter index on the left and illustrated instructions on the right.

alt text

The Workshop Manual’s pump station in 3D. Drag to rotate the layout or hide the roof to see the basin.

alt text

The same pump station in side view. Each square represents one block, so you can count the height and spacing.

For mod authors

  • Add your book under data/<modid>/guidebooks/ and any diagrams under data/<modid>/guidebook_layouts/.
  • Keep translations and illustrations under your own assets/<modid>/ namespace.
  • Give players a guidebooks:guide stack with its guidebooks:book_id component set to your book’s ID. In Java, use Guidebooks.create(bookId).
  • Unlock a chapter after a gameplay event succeeds by calling Guidebooks.unlock(player, bookId, discoveryId) on the server. Keep chapter IDs stable across updates so existing readers keep their progress.

Workshop Manual example

This example uses the mod ID examplemod. Players craft the manual from a book and a copper ingot. Crafting a lever unlocks the second chapter. The example uses a three-block switch mount so the layout data is easy to follow.

1. Declare the dependency

Add the Maven repository that hosts YAB Lib to your Gradle repositories block, then add this dependency.

dependencies {
    implementation("com.hoopawolf.guidebooks:guidebooks-neoforge:0.2.1")
}

Add the required mod dependency to src/main/resources/META-INF/neoforge.mods.toml.

[[dependencies.examplemod]]
modId = "guidebooks"
type = "required"
versionRange = "[0.2.1,0.3.0)"
ordering = "AFTER"
side = "BOTH"

2. Define the book and layout

src/main/resources/data/examplemod/guidebooks/workshop.json

{
  "schema_version": 1,
  "title": "guide.examplemod.workshop.title",
  "start": "examplemod:pump",
  "chapters": [
    {
      "id": "examplemod:pump",
      "section": "guide",
      "order": 10,
      "title": "guide.examplemod.pump.title",
      "body": ["guide.examplemod.pump.body"],
      "items": ["minecraft:smooth_stone", "minecraft:lever"],
      "layout": "examplemod:pump"
    },
    {
      "id": "examplemod:pump_notes",
      "section": "guide",
      "order": 20,
      "title": "guide.examplemod.pump_notes.title",
      "body": ["guide.examplemod.pump_notes.body"],
      "requires": "examplemod:crafted_lever",
      "hint": "guide.examplemod.pump_notes.hint"
    }
  ]
}

src/main/resources/data/examplemod/guidebook_layouts/pump.json

{
  "schema_version": 1,
  "caption": "guide.examplemod.pump.caption",
  "side_view": { "axis": "z", "slice": 0 },
  "parts": [
    {
      "from": [0, 0, 0],
      "to": [2, 0, 0],
      "block": "minecraft:smooth_stone",
      "role": "support"
    },
    {
      "from": [1, 1, 0],
      "block": "minecraft:lever",
      "properties": { "face": "floor", "facing": "east" },
      "role": "anchor"
    }
  ]
}

Layout coordinates are local to the diagram and use X, Y, Z order. The to position is inclusive. The first chapter shows Build layout because it references examplemod:pump.

src/main/resources/assets/examplemod/lang/en_us.json

{
  "item.guidebooks.book.examplemod.workshop": "Workshop Manual",
  "guide.examplemod.workshop.title": "Workshop Manual",
  "guide.examplemod.pump.title": "Mounting the pump switch",
  "guide.examplemod.pump.body": "Place three smooth stone blocks in a row. Put a lever on the middle block. Open Build layout to check its position.",
  "guide.examplemod.pump.caption": "The lever sits one block above the middle of the base.",
  "guide.examplemod.pump_notes.title": "Workshop notes",
  "guide.examplemod.pump_notes.body": "Leave space beside the switch so you can reach it from either end of the base.",
  "guide.examplemod.pump_notes.hint": "Craft a lever to unlock these notes."
}

3. Give players the book

src/main/resources/data/examplemod/recipe/workshop_manual.json

{
  "type": "minecraft:crafting_shapeless",
  "category": "misc",
  "ingredients": ["minecraft:book", "minecraft:copper_ingot"],
  "result": {
    "id": "guidebooks:guide",
    "count": 1,
    "components": {
      "guidebooks:book_id": "examplemod:workshop"
    }
  }
}

For a quest reward or another Java-based grant, use Guidebooks.create(Identifier.parse("examplemod:workshop")) to create the stack.

4. Unlock the second chapter in Java

The discovery ID passed to unlock must match the chapter’s requires value. If your mod already has a @Mod entry point, register the listener there.

package com.example.examplemod;

import com.hoopawolf.guidebooks.Guidebooks;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.Items;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;

@Mod("examplemod")
public final class WorkshopExample {
    private static final Identifier BOOK =
            Identifier.parse("examplemod:workshop");
    private static final Identifier CRAFTED_LEVER =
            Identifier.parse("examplemod:crafted_lever");

    public WorkshopExample() {
        NeoForge.EVENT_BUS.addListener(this::onItemCrafted);
    }

    private void onItemCrafted(PlayerEvent.ItemCraftedEvent event) {
        if (event.getEntity() instanceof ServerPlayer player
                && event.getCrafting().is(Items.LEVER)) {
            Guidebooks.unlock(player, BOOK, CRAFTED_LEVER);
        }
    }
}

5. Test it in game

Give yourself the manual with the command below and open it. Workshop notes should show the locked hint. Craft a lever and reopen the book to read the chapter.

/give @s guidebooks:guide[guidebooks:book_id="examplemod:workshop"]

YAB Lib Team

profile avatar
  • 3
    Followers
  • 2
    Projects
  • 18.0K
    Downloads

More from HoopAWolf