Files
bworld/docs/modding/concepts/registries.md
T
2026-09-30 13:41:29 -03:00

3.1 KiB

Registries

Every block, item, block model, entity, entity model and texture has an id, and is registered under it once, while mods load. After that the game refers to things only by their id.

Identifiers

An id looks like namespace:name, like farmersdelight:cabbage:

  • namespace is the id of the mod that registers it, 1-32 characters of a-z, 0-9 and _.
  • name is a-z, 0-9 and _.
  • A mod only registers ids in its own namespace. It can refer to any id, like using bworld:planks in a recipe.
  • Registering an id that's already registered, by the same mod or another, is an error.

Two namespaces are reserved:

  • bworld belongs to the base game, mods/bworld.
  • engine belongs to the engine: the missing texture engine:missing, the breaking cracks engine:break_0 to engine:break_8, and the built-in block models engine:cube, engine:cross and engine:crop.

bworld:air is the one exception: it's the engine's empty block, but keeps that id because every save has it.

Tags aren't registered like this: they're lists that every mod can add to, their ids can have folders (c:ingots/iron), and the c namespace is shared by every mod.

The same id can name different kinds of thing. A block registers an item with the same id unless it sets "item": false, and its texture is often named the same too.

Loading

The server and every client load mods the same way, in the same order:

  1. Order. Dependencies come before the mods that need them, and otherwise mods load alphabetically. Mods that depend on each other in a circle are an error. The server sends its order to clients, and they follow it.
  2. Data, one mod at a time: its block models, blocks (and their items), items, entity models and entities. Then every mod's tags, merged in load order, then each mod's recipes and ores, which can use tags.
  3. Scripts. Server scripts' setup runs on the server, and client scripts' on each client. Worldgen scripts' setup runs on the server before it makes chunks.

Scripts read the registries but can't add to them. Content comes from data files.

Important

The server and the client must end up with exactly the same blocks, items and recipes. They do as long as content is only data, since both load the same files in the same order.

Numeric Ids

Blocks get a number when they register, and chunks store those numbers. Numbers are local to one running program: the server and each client can number blocks differently, so saves and the network always use string ids. When a player joins, the server sends its list of block ids, and the client translates chunks into its own numbers as they arrive.

The practical rule: never save or send a block's number. Use its id.

Changing What Exists

Ids never change and blocks and items can't be removed, because saves refer to them. A world saved with your mod installed keeps your ids in its chunks, inventories and chests, so renaming a block breaks those worlds.

To retire something, stop it from being obtainable: take away its recipes and drops.