Files
bworld/MODS.md
T
2026-11-14 00:29:34 -03:00

4.8 KiB

Making bworld Mods

Mods add blocks, items, entities, recipes, world generation, game logic and screens to bworld. A mod is installed on the server. Players who join download its client code, data and textures from that server automatically, so they never install anything themselves.

The base game is a mod too: mods/bworld is written against the same API as any other mod, so anything it does, your mod can do, and it's the best place to look for examples.

A mod is mostly data: JSON files for blocks, items, recipes and entities, and PNG textures. Behavior comes from TypeScript scripts: a server script for game logic, a client script for what players see, and a worldgen script for terrain features.

deno task new-mod copper_tools "Copper Tools"   # a new mod in mods/copper_tools, from templates/mod
deno task check-mods                            # checks every mod in mods/
deno task build && deno task server             # packs the mods and starts a server with them

Documentation

Getting started

  • Getting Started: making, checking, running and testing a mod
  • Mod Files: the folder layout, manifest.json, scripts and .cubi files

Concepts

  • Sides: what runs on the server and what runs on players' clients
  • Registries: ids, namespaces and how mods load
  • Events: reacting to and cancelling what players do
  • Security: what servers and players trust

Blocks

  • Blocks: looks, mining, drops and placement
  • Block States: state bits, variants and facing
  • Block Components: giving blocks behavior from a server script
  • Tile Data: data kept for one block, the part clients see, and blocks that hold or show items
  • Visuals: blocks drawn with code, like a shaft that turns or the items and fluid in a machine
  • Crops: farming without writing code
  • Verdigris: blocks that make and use signals, like levers, torches and doors

Items

  • Items: items, item stacks and item components
  • Tools: tool types, tiers and durability
  • Food: hunger and saturation

Entities

  • Entities: animals, monsters, natural spawning, scripted entities and entity models
  • Players: the player API, health and hunger

Inventories

  • Containers: slots the server owns and saves
  • Menus: slots, data and buttons on the server, and their screens

Resources

  • Textures
  • Block Models
  • Recipes: crafting, smelting, smithing, stonecutting and your own recipe types
  • Tags: lists of blocks, items or entities that every mod can add to
  • Loot Tables: what blocks, mobs, fishing and chests give
  • Fluids: fluids that can be held, apart from blocks that flow, and the fluid handlers that tanks and containers are filled and drained through

Everything else

  • World Generation: ores and features
  • Biomes: surfaces, colors and seasons
  • Screens: plain screens, inventory overlays and drawing with Graphics
  • HUD: layers drawn over the world, like the base game's hotbar and hearts
  • Networking: how players get mods and the world
  • Saving Data: where a mod keeps what should last
  • Config: settings a server can change, like how fast a machine works
  • Commands
  • Time: ticks, timers, days and nights
  • Engine Access: reaching into the engine and hooking its methods, for what the API doesn't cover yet

API Types

The API types are the reference for everything scripts can call. Scripts import them as cubi/server, cubi/client, cubi/shared, cubi/worldgen and cubi/content, and they live in common/mod_api/.

A few parts of those types aren't built yet and throw when used: forms, custom screens and keybinds. docs/modding_plan.md covers those, what else is planned, and the design behind the mod API.