The storage registry
What a base's containers give its crafting: which placed containers count as the base's crafting stock (the linked storage a station's fill and crafting from base storage take from), which of them take area deposits, and which placed things are its water sources. Entries are the game's templates of containers (anything placed or spawned with an inventory: chests, production stations, villagers, loot containers) and of water sources. A crafting stock container counts for the base it stands in: the base's build zone is its reach (balance.buildzoneSizesPerAltarLevel).
Schema version 0.1.1, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.StorageEntry. 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 template's stable name>. Mod entries:(none: entries are the game's templates). All ids are lower case. The mod idsgameandkilnare reserved: no mod's entries use them. - An entry has the id of its template: the template's debug name in lower case (the Magic chest Prop_Decoration_T1_Storage_24_Magic is game:prop_decoration_t1_storage_24_magic). A template without a name is game:template_<first 8 hex digits of its GUID>. When two templates would get the same name, the one that held it first keeps it and the other is game:
~<first 8 hex digits of its GUID>. The same id names the template in every registry (creatures share it). - Names:
DisplayName(never empty; display names) is the name of the container's template, as for creatures: Kiln's catalog, else one made from the template's debug name.
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 |
|---|---|---|---|---|---|---|---|
craftingStock |
bool | now | set | 0.1.0 | mapped | now | The container counts as its base's crafting stock (its linked storage): a station's fill and crafting from base storage take from it. The game's Magic chests and the refilling fruit plants a player plants are; ordinary chests are not. Only a container can be made crafting stock (an entry without an inventory is refused). A change in the start's edits (a data pack) is made in the templates: every placed container of the entry follows from that start, also those in a saved world; one made crafting stock starts with area deposits off and areaDeposit turns them on; false takes any container out, the game's own Magic chests too: what it holds stays in it and a saved world loads as before, but a player's own deposit switch on such a container goes with it (once it is crafting stock again, it follows areaDeposit). A change after the start (a live change, a reloaded pack) applies at once to every placed container of the entry, through Kiln's own list of each base's crafting stock: one made crafting stock that way takes no area deposits and has no deposit switch until a start makes it crafting stock (its areaDeposit reads false and an edit of it is refused); where Kiln cannot do that on this game build, or another mod changed the same game code, such an edit is refused for that entry. A Kiln client follows a change after the start too (its crafting menu and fill buttons count it); a vanilla client counts the game's own stock, while the server decides every payment. |
areaDeposit |
bool | now | set | 0.1.0 | mapped | now | A crafting stock container takes area deposits (the quick stack station's deposit into the base's storage) unless a player switched them off on that container: a player's own switch on one container can only turn them off, never on (with this false the container takes none, whatever its switch says). Read at every deposit. Only crafting stock has the value: an entry that is not reads null and an edit of it is refused for that entry (make it crafting stock first). |
water |
bool | restart | read-only | 0.1.0 | mapped | serverOnly | The entry is one of its base's water sources while it holds water (the game's wells and water barrels): a seedling bed's or a recipe's water comes from it. |
Traits
Selectors ask for these with has / hasNot.
| Trait | Means |
|---|---|
container |
has an inventory (chests, production stations, villagers, loot containers) |
station |
a production station (a kiln, a forge, a loom) |
Components
Each entry is a template, so a selector's has / hasNot also name the components its template holds or lacks, as component:<kind> with the kind's Kiln name from the template view (views): "has": ["component:inventoryCraftingStock"]. A kind no template holds selects nothing (since 0.2.0-dev.32.1).
Entries
- Add (stage add, id
<your mod id>:<name>): no. Containers are the game's templates: a mod adds a new container as a template of its own (a kiln.gamedata template clone or a placeable block), and gives it crafting stock here by its id. - Remove: no. A template is never removed: every container of it placed in a saved world needs it. Set craftingStock to false to take a container out of the base's crafting stock.
- Raw game paths in edits (the Advanced tier): refused.
Edit it from a data pack
A container's id is its template's: game:prop_decoration_t1_storage_24 (an ordinary chest), game:prop_decoration_t1_storage_24_magic
(a Magic chest). Select by id, glob or trait ("has": ["container"]; station for the production stations).
"field": "craftingStock", "op": truemakes a container (any template with an inventory: a chest, a production station, a villager) part of its base's linked storage, so a station's fill and crafting from base storage take from it;falsetakes one out, the game's Magic chests too. The game decides which placed things are stock when it loads the templates: a change in the start's edits (a data pack,GameStart) is made in the templates and applies from that start, to every placed container of the template, also in a saved world. Since 0.2.0-dev.32.3 the field isnow: a change after the start (a live change, a reloaded pack,WorldLoad) applies at once, through Kiln's own list of each base's crafting stock (the game's list, edited every frame after the game rebuilds it): a container made crafting stock that way takes no area deposits and has no deposit switch until a start makes it crafting stock (itsareaDepositreads false, an edit of it is refused for that entry). Where Kiln cannot do that on a game build, or another mod changed the same game code, such an edit is refused for that entry with the reason (with only the area deposit guard missing, taking a container out still works). What a container holds stays in it either way. An entry without an inventory (a well) is refused."field": "areaDeposit", "op": true: a crafting stock container takes the quick stack station's area deposits (read at every deposit). A container newly made crafting stock starts with it off; a container that is not crafting stock has none (it readsnulland an edit of it is refused for that entry), so make a container crafting stock and give it area deposits in one section (two edits). A player's own switch on one placed container can still turn its deposits off, never on: withareaDepositfalse the container takes none, whatever its switch says.wateris read-only: the wells and water barrels a base's seedling beds and recipes draw water from.- A crafting stock container counts for the base whose build zone it stands in; the zone sizes are
balance
buildzoneSizesPerAltarLevel. - No entry add or remove: a new container is a template of its own (a kiln.gamedata clone or a block), made crafting stock here
by its id. An older boot resource patch that copies the Magic chest's crafting stock onto a template (EMBER) is an older writer
under
craftingStock; kiln.gamedata'stemplatessection's area deposit switch one underareaDeposit.
Edit it from C#
[RegistryEntryPoints(RegistryEntryPoint.GameStart)]
public sealed class ChestStock : Mod
{
public override void OnRegistry(RegistryContext context)
{
if (!Kiln.Registry.Registries.Available) return; // kiln.registry: the host's registry transport
Kiln.Registry.Registries.For(context).Alter(stage =>
{
var chest = stage.Storage["game:prop_decoration_t1_storage_24"];
chest.CraftingStock = true; // GameStart: in the templates (WorldLoad: Kiln's list)
if (chest.CraftingStock) chest.AreaDeposit = true; // a container without crafting stock has no switch
});
}
}
stage.Storage is a RegistryEntries<StorageEntry> (CraftingStock and AreaDeposit bools, Water read-only). The complete
mods: RegistryEdits sample (C#) and
BaseStorage sample (a data pack).
Views
RegistryViews.Find("storage") is the stable view (608 templates on the current server build: 595 with an inventory, 13 water
sources). The advanced view template lists every template and reports CoveredBy where this registry maps the member
(views.md).
Since 0.2.0-dev.32 an entry's Template is its template in that view, every component readable by kind
(stage.Storage[id].Template.Get<JsonNode>("components[3]"); views.md). A component path this registry maps one to one names the
field (CoveredBy, or Covers for one index), and stage.View("template")[id].Set(path, value) edits it as this registry's field
(at WorldLoad, HotReload or in Registries.Change; never inside GameStart, where views are not open yet).
Worked example
Every storage chest becomes part of its base's linked storage and takes area deposits:
{
"format": 1,
"registry": {
"alter": [
{ "registry": "storage", "select": { "id": "game:prop_decoration_t*_storage_*", "has": ["container"] }, "field": "craftingStock", "op": true },
{ "registry": "storage", "select": { "id": "game:prop_decoration_t*_storage_*", "has": ["container"] }, "field": "areaDeposit", "op": true }
]
}
}
This is mods/samples/BaseStorage's pack.
In multiplayer
craftingStock's start value is made in the templates on each side at its own start, so every player needs the mod
(side: both, clients: mod), and the join compares it (kiln.registry.boot). A change after the start is the server's
sent to Kiln clients (joinedClient: now): the server sends each Kiln client the templates its list adds and takes out
(kiln:craftstock) at its join and on a change, and the client's own list follows, so its crafting menu and fill buttons count
the same chests; a hosting player's own game follows in process. A vanilla client counts the game's own stock (the server
still decides every craft and fill). areaDeposit is now: the content sync carries it to Kiln
clients, whose inventory screen shows the switch. water is read-only
(choosing clients).
Known limits
- A player's own deposit switch on a container taken out of crafting stock is not kept: put back, it follows
areaDepositagain. - Taking the Magic chests out is allowed (every chest keeps its items, a saved world loads as before).
- Not yet seen in a real game: a Kiln client's crafting menu and fill button counting a chest made crafting stock, a quick stack station depositing into it, a vanilla client joining a server whose crafting stock differs, and a change after the start (Kiln's list of a base's crafting stock: the server's fills and crafts take from the chest; a container made crafting stock that way takes no area deposits).