The materials registry
The game's building materials: what digging each one takes (hardness, health, the class of tool that breaks it best) and gives back. The server reads them at each dig; Kiln writes them before the game reads its tables, so an edit takes effect at the next start. A MaterialTweakBlock of the same field lies below a registry edit.
Schema version 0.1.0, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.BuildingMaterialEntry. 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:building_<n>. Mod entries:(none: a mod adds materials with blocks). All ids are lower case. The mod idsgameandkilnare reserved: no mod's entries use them. - A building material has no name of its own: it is game:building_<its building id as 8 hex digits> (the cell id less 128: Rough Wood, cell 143, is game:building_0000000f). kiln.worldtables' names (WoodRough, Cell143) name the same materials.
- Names:
DisplayName(never empty; display names) is the material's name as kiln.worldtables labels it (VoxelMaterial.DisplayName: the name of the item that places it or that digging it gives), else one made from its name ("Cell 143").
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 |
|---|---|---|---|---|---|---|---|
hardness |
enum (soft, slightlyHard, moderatelyHard, hard, veryHard, unbreakable) | restart | set | 0.1.0 | mapped | serverOnly | How hard the material is to dig: a tool's damage per hardness decides how fast it goes; unbreakable cannot be dug by anything. |
health |
int 1..1000000 | restart | number | 0.1.0 | mapped | serverOnly | The material's health points: what a dig has to deal to remove one block (cost = health / the tool's damage for its hardness). |
breaks |
enum (none, wood, stone, metal) | restart | set | 0.1.0 | mapped | serverOnly | The material's class for a tool's class modifiers (an axe against wood, a pickaxe against stone and metal); none takes no modifier. |
blocksPerLoot |
int 1..100000 | restart | number | 0.1.0 | mapped | serverOnly | How many blocks a player digs for one loot item. |
loot |
ref items, optional | restart | read-only | 0.1.0 | mapped | serverOnly | The item digging gives back (the block's main raw material, not the block itself); absent for the few old building ids without one. |
Entries
- Add (stage add, id
<your mod id>:<name>): no. A mod adds a building material with a buildingMaterials block (BuildingMaterialBlock): kiln.worldtables gives it one of the 49 free ids and keeps worlds' cells of it while its mod is away. - Remove: no. A game material is never removed: every saved world's cells name it.
- Raw game paths in edits (the Advanced tier): refused.
Edit it from a data pack
An entry is one of the game's building materials, named by a building material's cell id less 128 in 8 hex digits (game:building_0000000f is Rough Wood (cell 143)). kiln.worldtables' names
(GameMaterials, Cell<id>) name the same materials (services/worldtables.md).
Every field applies at the next game start (restart): Kiln writes it before the game reads its tables. Edits use the
same shape as every registry (items):
"field": "hardness", "op": "hard"(soft, slightlyHard, moderatelyHard, hard, veryHard, unbreakable);"field": "health", "op": {"mul": 2}: twice as long to dig with the same tool;"field": "breaks", "op": "stone": the class a tool's class modifier is for (none, wood, stone, metal);"field": "blocksPerLoot", "op": 25: one loot item per 25 dug;loot(the item digging gives back) is read-only.
A MaterialTweakBlock of the same field lies below a registry edit: the tweak leaves that field out (kiln.log names the
registry edit) and applies its other fields. A relative edit (mul, add) of a mod built for the Gate stacks on the value
beneath it, a tweak's included: a tweak's health 500 with such a mod's {"mul": 2} is 1000 (decision 5; health and
blocksPerLoot). A mod built before the Gate keeps computing on the game's value, and its edit replaces the tweak's, as does an
absolute value or "base": "game". registry.json's result for a stacked field is still computed on the game's value (kiln.content
writes it before kiln.worldtables stacks); the value in effect is in kiln/data/worldtables/status.json (the tweak's registry
row, "decision": "stacked") and in kiln.log.
Edit it from C#
[RegistryEntryPoints(RegistryEntryPoint.GameStart)]
public sealed class HarderMaterials : Mod
{
public override void OnRegistry(RegistryContext context)
{
if (!Kiln.Registry.Registries.Available) return;
var registry = Kiln.Registry.Registries.For(context);
registry.Alter(stage =>
{
var m = stage.Materials["game:building_0000000f"];
m.Health = m.Health * 2;
m.BlocksPerLoot = 25;
});
}
}
stage.Materials holds BuildingMaterialEntrys (Hardness, Health, Breaks, BlocksPerLoot, Loot). Restart fields are written at
GameStart; from a later entry point an edit is refused with RestartRequired.
Views
RegistryViews.Find("materials") is the stable view of every game building material; it reads the values the stage composed.
Worked example
Rough Wood (cell 143) twice as tough, one loot item per 25 dug:
{
"format": 1,
"registry": {
"alter": [
{ "registry": "materials", "select": { "id": "game:building_0000000f" }, "field": "health", "op": { "mul": 2 } },
{ "registry": "materials", "select": { "id": "game:building_0000000f" }, "field": "blocksPerLoot", "op": 25 }
]
}
}
In multiplayer
The server digs: every field is server-only (serverOnly), so a vanilla client may join, and digs as the server says. Edits of
these fields ask nothing of players' games (as a MaterialTweakBlock's strength does not).
Known limits
- Only the game's own materials are entries; materials a mod adds (
BuildingMaterialBlock) are kiln.worldtables' and not edited here. - The loot item is read-only: the boot back-end writes no references.
- The server reads every field at each dig (docs/re/building.md 8); this release writes them at start only (a live back-end could make them apply at once).
- Not yet seen in a real game: a player's dig with an edited hardness or health, and the loot it gives.