The spawns registry
The game's natural spawners: the spawn points in the world that bring enemies and wildlife near players (a wolf pack's den, a scattering of critters). How many each brings, how far from itself, how often and how many may live at once. Read at each spawner's update, also by spawners already in the world.
Schema version 0.1.0, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.SpawnerEntry. 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 spawner's stable name>. Mod entries:(none: a mod adds spawners as templates). All ids are lower case. The mod idsgameandkilnare reserved: no mod's entries use them. - A spawner has the id of its template, as creatures have (Spawnpoints_Enemy_Scattering_Wildbeast_Wolf_Above_1-3_Enemies is game:spawnpoints_enemy_scattering_wildbeast_wolf_above_1-3_enemies); the same id names the template in every registry. The entries are the templates with a natural spawner.
- Names:
DisplayName(never empty; display names) is the name of the spawner'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.
Groups of fields:
amount: How many creatures one spawn brings.range: How far from the spawner, in metres, its creatures appear.timeout: How long the spawner waits between spawns, in seconds (a random time between min and max), and before its first.
| Field | Type | Applies | Ops | Since | Mapping | Joined client | About |
|---|---|---|---|---|---|---|---|
amount.min |
int 0..255 | now | number | 0.1.0 | mapped | serverOnly | The fewest a spawn brings. |
amount.max |
int 0..255 | now | number | 0.1.0 | mapped | serverOnly | The most a spawn brings. |
maxAlive |
int 0..255 | now | number | 0.1.0 | mapped | serverOnly | How many of the spawner's creatures may live at once (0: no limit, the game's own value for most spawners). |
range.min |
float m 0..10000 | now | number | 0.1.0 | mapped | serverOnly | The nearest, in metres. |
range.max |
float m 0..10000 | now | number | 0.1.0 | mapped | serverOnly | The farthest, in metres. |
timeout.initial |
time s 0..86400 | now | number | 0.1.0 | mapped | serverOnly | Before its first spawn. |
timeout.min |
time s 0..86400 | now | number | 0.1.0 | mapped | serverOnly | The shortest wait. |
timeout.max |
time s 0..86400 | now | number | 0.1.0 | mapped | serverOnly | The longest wait. |
respawn |
bool | now | set | 0.1.0 | mapped | serverOnly | The spawner spawns again after its creatures are gone. |
despawnRange |
float m 0..10000 | now | number | 0.1.0 | mapped | serverOnly | How far, in metres, players must be before the spawner's creatures may be despawned. |
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. A spawner is a template placed in the world's scene: a mod adds one as a template of its own (a kiln.gamedata clone) placed by its own code. - Remove: no. A spawner is never removed: the world's scene places it.
- Raw game paths in edits (the Advanced tier): allowed.
Edit it from a data pack
An entry is one of the game's natural spawners: a template the world's scene places that brings creatures near players (a wolf pack's den, a scattering of critters). Its id is its template's, as a creature's is. Every field applies now: each spawner reads its template's values at its next update, also spawners already in the world. Edits use the same shape as every registry (items):
"field": "maxAlive", "op": 2: at most two of the spawner's creatures alive at once (0is no limit: the game's own value for most spawners, every wolf den among them, so{"mul": ...}orMath.Minon a 0 keeps it unlimited);"field": "amount.max", "op": {"mul": 2}: twice as many at most in one spawn (amount.min,amount.max: 0 to 255);"field": "timeout.min", "op": 120: at least two minutes between spawns (timeout.initial,.min,.max, in seconds);"field": "range.max", "op": 40: creatures appear up to 40 m from the spawner;respawn(it spawns again once its creatures are gone) anddespawnRange(how far players must be before its creatures may go).
The world setting for how many spawners run (Few to Extreme) and a scene node's own scaling switches stay the game's: they are not part of a spawner's values.
Edit it from C#
[RegistryEntryPoints(RegistryEntryPoint.GameStart)]
public sealed class FewerWolves : Mod
{
public override void OnRegistry(RegistryContext context)
{
if (!Kiln.Registry.Registries.Available) return;
var registry = Kiln.Registry.Registries.For(context);
registry.Alter(stage =>
{
foreach (var spawner in stage.Spawns.Select("game:spawnpoints_*wolf*"))
spawner.MaxAlive = spawner.MaxAlive == 0 ? 2 : Math.Min(spawner.MaxAlive, 2); // 0: no limit
});
}
}
stage.Spawns holds SpawnerEntrys (Amount, MaxAlive, Range, Timeout, Respawn, DespawnRange).
Views
RegistryViews.Find("spawns") is the stable view of every natural spawner; it reads the values the stage and the live edits composed.
Worked example
Wolf dens keep at most two wolves alive and wait at least two minutes between spawns:
{
"format": 1,
"registry": {
"alter": [
{ "registry": "spawns", "select": "game:spawnpoints_*wolf*", "field": "maxAlive", "op": 2 },
{ "registry": "spawns", "select": "game:spawnpoints_*wolf*", "field": "timeout.min", "op": 120 }
]
}
}
In multiplayer
The server spawns: every field is server-only (serverOnly), so a vanilla client may join and sees the server's creatures.
Known limits
- The game runs a natural spawner only near players: a playerless lab proves the mapping (write, read back, revert), not a spawn.
- What a spawner brings (its entries and their weights) is not a field yet; Kiln's
Gameplay.ReplaceNaturalSpawnsstill swaps a natural spawn's template per spawn. - Not yet seen in a real game: a spawner following an edit while a player is near.