The stations registry
The game's crafting stations: the workbench, the production stations and the crafters' stations of the villagers. A recipe names its station (recipes.station), so a station's recipes are the recipes that name it.
Schema version 0.1.0, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.StationEntry. What registries are, the stages, the conflict rules and how ids are made: README.
Edits per call: 4,096. One OnRegistry callback (one phase of one entry point) or one Registries.Change takes at most this many edits of this registry; a call with more is refused whole, with the reason in kiln.log and registry.json, and nothing of it applies (the other calls do). The default for a registry whose schema declares none (4,096).
Ids
- Game entries:
game:<the station's item>. Mod entries:<mod id>:<name>. All ids are lower case. The mod idsgameandkilnare reserved: no mod's entries use them. - A station has the id of the item that builds or offers it (the workbench is game:craftingstation_workbench, the forge game:prop_production_t1_forge, the blacksmith game:npc_crafter_blacksmith01). A station without an item is game:station_<its 32-bit station id as 8 hex digits>. When two stations would get the same id, the one that held it first keeps it and the other is
~<first 8 hex digits of its GUID>. - Names:
DisplayName(never empty; display names) is the name of the item that builds the station, as the items registry's entry of that id has it; a station without an item (station_) has the game's text of its workshop's name, else one made from its id.
Fields
Applies: now = takes effect at the next use; worldLoad = takes effect when a world loads; restart = takes effect after a game restart. Ops: number = a value or the relative operations (mul, add, min, max, raiseOnly, lowerOnly); set = a value; list = clear, append, remove, replace; indexed = a list of fixed length, edited one element at a time (xpPerLevel[2]) with a value or a number operation. A field of a list's elements is named with [] in this table and with the element's index in an edit (entries[3].chance, or [*] for every element). Mapping: whether this Kiln maps the field onto the game; an unproven or unmapped field is refused per entry, with the reason, until a Kiln update maps it. Joined client: when a joined Kiln client consumes a server edit; see README.
| Field | Type | Applies | Ops | Since | Mapping | Joined client | About |
|---|---|---|---|---|---|---|---|
item |
ref items, optional | restart | read-only | 0.1.0 | mapped | serverOnly | The item that builds the station (a villager's station: the villager's item); absent for the stations of the flame altar and a few others without one. Given when a station is added (the item a mod adds that places it); read-only for the game's stations. |
npc |
bool | restart | read-only | 0.1.0 | mapped | serverOnly | The station is a villager's (a crafter or a trader), not one the player builds. |
Traits
Selectors ask for these with has / hasNot.
| Trait | Means |
|---|---|
npc |
a villager's station (npc) |
Entries
- Add (stage add, id
<your mod id>:<name>): yes. GameStart only. A crafting station of the mod's own like a game station, placed by the item given in item (an item a mod adds): the recipes that name it as their station are its recipes (a workshop of the mod's own). The game reads its stations once at start, so an added station is there from the next start a mod's recipe names it. - Add requires GameStart and an explicit present Kiln
likeid; clone chains end at a game entry. Kiln retains the stable identity and pins the structural base install-wide. Use a new id for an incompatible base. - Remove: no. A station is never removed: every placed one in a saved world names it. Hide its recipes instead (recipes remove with where station).
- Raw game paths in edits (the Advanced tier): refused.
Edit it from a data pack
Stations take no edit: every field is read-only. The registry exists so a recipe can name its station and a mod can select
recipes by it. A station's id is the id of the item that builds it (game:prop_production_t1_forge; a villager's station: the
villager's item), or game:station_<8 hex> for the few without one.
What a data pack does with it is select recipes: "select": {"id": "*", "where": {"station": "game:prop_production_t1_forge"}}
over the recipes registry. Traits: npc (a villager's station).
Edit it from C#
registry.Alter(stage =>
{
var forge = new RegistryId("game:prop_production_t1_forge");
foreach (var recipe in stage.Recipes.Select())
if (recipe.Station == forge) recipe.Duration /= 2; // every forge recipe takes half as long
});
Reading the stations themselves is outside a pass, on the tick thread in your mod (Registries.Read is tick-thread only,
so an OnRegistry pass that calls it gets KILN101):
if (!Kiln.Registry.Registries.Available) return; // kiln.registry
Kiln.Registry.Registries.Read(stage =>
{
foreach (var station in stage.Stations.Select())
Log.Info($"{station.Id.Value}: built by {station.Item}, villager's: {station.Npc}");
});
stage.Stations is a RegistryEntries<StationEntry> (Item, Npc: read-only properties, no setters).
Views
RegistryViews.Find("stations") is the stable view (51 stations on the current server build, 7 without an item); every field
reads Readable and is marked ReadOnly (views.md).
Worked example
Every forge recipe takes half as long. The station is only the selector; the edit is the recipes':
{
"format": 1,
"registry": {
"alter": [
{ "registry": "recipes", "select": { "id": "*", "where": { "station": "game:prop_production_t1_forge" } }, "field": "duration", "op": { "mul": 0.5 } }
]
}
}
In multiplayer
The registry is read-only and serverOnly: nothing syncs. What the example edits (recipe durations) syncs as the
recipes registry says.
Known limits
- Read-only for the game's stations and recipes: a game recipe cannot move to another station and a station cannot be removed.
- Entry add (0.2.0-dev.32, GameStart only):
{"registry": "stations", "entry": "add", "id": "<mod>:<name>", "like": "game:craftingstation_workbench", "fields": {"item": "<mod>:<its item>"}}(C#Stations.AddLike(id, like, item, ...)) is a workshop of the mod's own, placed by that item (one a mod adds); the recipes a mod adds with"station": "<mod>:<name>"(C#Recipes.AddLike(id, like, station, ...)) are its recipes. What a player places is a copy of what the like station's item places, running the mod's workshop, and the station's recipes are listed in a menu laid out as the like station's. The like is a station a player places (a villager's is refused), and one item places one station. - One station has many placed forms (the game has 17 for the workbench), so what a placed chest or station does for its base is not a station's data: which containers count as a base's crafting stock and which take area deposits are the containers' templates, and no registry maps them yet (README).