Frostdev

KilnAPI reference Guide

The movement registry

How player characters move: the steps they climb, the falls that hurt them, the slopes they slide down, and how much of the map their game reveals around them. One entry per player template; game:1_player is the one the game makes every player's character from. Gameplay values: a player's game predicts its own character's movement from its own copy, so the server and its players need the same values. Since 0.2.0-dev.32.1.

Schema version 0.1.0, experimental (KILNX031: may change in any release until it is marked stable). C# entry type Kiln.Registry.MovementEntry. 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 player template's stable name>. Mod entries: (none: the player templates are the game's). All ids are lower case. The mod ids game and kiln are reserved: no mod's entries use them.
  • An entry has the id of its template, as a creature has (1_Player is game:1_player); the same id names the template in every registry. The entries are the templates with a player character's locomotion: game:1_player (every player's character), game:1_player_ag2 and game:automatedplayer (the game's own test player), which the game's code does not make characters from.
  • Names: DisplayName (never empty; display names) is the name of the player template as TemplateInfo.DisplayName gives it: Kiln's catalog, else one made from the template's debug name. An id no template has is made readable from the 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.

Groups of fields:

  • stepHeight: The character's step heights, in metres: one over the terrain and built blocks, one over placed objects. Read at every step of the character's movement, also by characters already in the world.
  • fallDamage: How long a fall must be to hurt, in metres. A fall between start and lethal costs that share of the character's maximum health ((distance - start) / (lethal - start)); a start at or above lethal turns fall damage off. Read at every landing.
  • slope: Which ground is too steep to stand on, in degrees. A character takes these when it is made (each time a player joins a world), so they apply from the next start, and every player needs the same ones.
  • slide: Values the template carries for sliding. No game code reads them on this game build (the game's slide uses fixed numbers of its own), so edits of them stay refused.
Field Type Applies Ops Since Mapping Joined client About
stepHeight.voxels float m -3.4028234663852886e+38..3.4028234663852886e+38 now number 0.1.0 mapped now On the terrain and built blocks (the world's voxels): the collision step's check of the terrain takes it, and the step settles a grounded character onto ground within it. The game's own is 0.9 m.
stepHeight.props float m -3.4028234663852886e+38..3.4028234663852886e+38 now number 0.1.0 mapped now On placed objects (props: furniture, crates, a station): the collision step's check of placed objects takes it. The game's own is 0.51 m.
fallDamage.start float m -3.4028234663852886e+38..3.4028234663852886e+38 now number 0.1.0 mapped now The shortest fall that hurts. The game's own is 8 m.
fallDamage.lethal float m -3.4028234663852886e+38..3.4028234663852886e+38 now number 0.1.0 mapped now The shortest fall that kills. The game's own is 16 m.
discoveryRange float m -3.4028234663852886e+38..3.4028234663852886e+38 now number 0.1.0 mapped now How much of the map a player's game reveals around the character as it moves: the diameter of the revealed circle, in metres (the game's own 300 reveals 150 m around the character). Read by the player's own game every frame; the map it revealed stays revealed. A dedicated server never reads it: the content sync brings a server's value to Kiln players.
slope.steepFloor float degrees -3.4028234663852886e+38..3.4028234663852886e+38 restart number 0.1.0 unproven: no game code reads this angle on this build, so an edit of it would change nothing unknown An angle the template carries for steep floor. No game code reads it on this game build (the game's own steep checks use a fixed 45 degrees), so edits of it stay refused.
slope.sliding float degrees -3.4028234663852886e+38..3.4028234663852886e+38 restart number 0.1.0 mapped restart Ground at least this steep (and below fallDamage) makes the character slide. The game's own is 55 degrees; a character out of stamina slides from 45 degrees whatever this is.
slope.fallDamage float degrees -3.4028234663852886e+38..3.4028234663852886e+38 restart number 0.1.0 mapped restart Ground at least this steep is no floor at all: the character falls, and the fall counts toward fall damage (ground of a sliding material excepted). The game's own is 65 degrees.
slope.slidingMaterial float degrees -3.4028234663852886e+38..3.4028234663852886e+38 restart number 0.1.0 mapped restart On ground of a material the game makes slippery, the character slides from this angle. The game's own is 10 degrees; anything below 2 counts as 2.
slide.downhillFactor float -3.4028234663852886e+38..3.4028234663852886e+38 worldLoad number 0.1.0 unproven: no game code reads the slide values on this build, so an edit of them would change nothing unknown A downhill acceleration factor (the game's data: 0.0625).
slide.downhillAcceleration float -3.4028234663852886e+38..3.4028234663852886e+38 worldLoad number 0.1.0 unproven: no game code reads the slide values on this build, so an edit of them would change nothing unknown A downhill acceleration (the game's data: 0.25).
slide.lateralAcceleration float -3.4028234663852886e+38..3.4028234663852886e+38 worldLoad number 0.1.0 unproven: no game code reads the slide values on this build, so an edit of them would change nothing unknown A sideways acceleration (the game's data: 0.6).
slide.uphillAcceleration float -3.4028234663852886e+38..3.4028234663852886e+38 worldLoad number 0.1.0 unproven: no game code reads the slide values on this build, so an edit of them would change nothing unknown An uphill acceleration (the game's data: 4).
slide.maxUphillSpeed float m/s -3.4028234663852886e+38..3.4028234663852886e+38 worldLoad number 0.1.0 unproven: no game code reads the slide values on this build, so an edit of them would change nothing unknown A highest uphill speed (the game's data: 10).

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 player template is the game's: the game makes every player's character from game:1_player, so a template a mod adds would make no character.
  • Remove: no. A player template is never removed: every player's character is made from it.
  • Raw game paths in edits (the Advanced tier): allowed.

Edit it from a data pack

An entry is a player template. Every player's character is made from game:1_player, so select that one (the other two, game:1_player_ag2 and game:automatedplayer, the game's own test player, are templates no game code makes a player from). Edits use the same shape as every registry (items):

  • "field": "stepHeight.voxels", "op": 1.5: a step height of 1.5 m over terrain and built blocks (the game's own 0.9); stepHeight.props is the same over placed objects (0.51). Both apply now: the next step of every character.
  • "field": "fallDamage.start", "op": 15 and "field": "fallDamage.lethal", "op": 40: falls hurt from 15 m and kill from 40 m (the game's own 8 and 16). A start at or above lethal turns fall damage off. They apply now: the next landing.
  • "field": "discoveryRange", "op": 600: the map reveals a circle 600 m across around the character (300 around it). It is a diameter, as the game keeps it (the game's own 300 reveals 150 m around). It applies now, in the player's own game.
  • "field": "slope.sliding", "op": 60: characters slide only on ground of 60 degrees or more (the game's own 55), up to slope.fallDamage (65), where the ground is no floor at all: steeper ground makes the character fall, and the fall hurts. A sliding angle at or above slope.fallDamage leaves no ordinary ground to slide on (slippery ground and a character out of stamina still slide). slope.slidingMaterial is where slippery ground starts to slide (10). The slope applies at the next start (restart): a character takes its angles when it is made, at each join.

slope.steepFloor and the five slide.* values are in the game's data but no game code reads them on this game build: an edit of them is refused with that reason, never silently kept.

Edit it from C#

[RegistryEntryPoints(RegistryEntryPoint.GameStart | RegistryEntryPoint.WorldLoad)]
public sealed class Climber : Mod
{
    public override void OnRegistry(RegistryContext context)
    {
        if (!Kiln.Registry.Registries.Available) return;
        var registry = Kiln.Registry.Registries.For(context);
        registry.Alter(stage =>
        {
            var player = stage.Movement["game:1_player"];
            player.StepHeight.Voxels = 1.5;                         // now: also at WorldLoad
            player.FallDamage.Start = player.FallDamage.Start * 2;  // the value below this mod: 8 becomes 16
            player.FallDamage.Lethal = player.FallDamage.Lethal * 2;
            if (context.EntryPoint == RegistryEntryPoint.GameStart)
                player.Slope.Sliding = 60;                          // restart: GameStart only
        });
    }
}

stage.Movement holds MovementEntrys (StepHeight, FallDamage, DiscoveryRange, Slope, Slide). A slope edit from a later entry point (WorldLoad, ModLoad, Registries.Change) is refused RestartRequired, as every restart field is.

Views

RegistryViews.Find("movement") is the stable view of the three player templates; it reads the values the stage and the live edits composed. The template view (RegistryViews.Find("template")) shows the same members as the template's components.

Worked example

Steps of 1.5 m, falls that hurt from 15 m and kill from 40 m, a map revealed 300 m around the character, and sliding only from 60 degrees:

{
  "format": 1,
  "registry": {
    "alter": [
      { "registry": "movement", "select": "game:1_player", "field": "stepHeight.voxels", "op": 1.5 },
      { "registry": "movement", "select": "game:1_player", "field": "fallDamage.start", "op": 15 },
      { "registry": "movement", "select": "game:1_player", "field": "fallDamage.lethal", "op": 40 },
      { "registry": "movement", "select": "game:1_player", "field": "discoveryRange", "op": 600 },
      { "registry": "movement", "select": "game:1_player", "field": "slope.sliding", "op": 60 }
    ]
  }
}

Give the pack "side": "both" and "clients": "mod": its slope edit is a start value every player needs.

In multiplayer

A player's game moves its own character ahead of the server (prediction) with its own copy of these values, so the server and its players need the same ones:

  • slope.* is a start value (restart): every player needs the mod (side: both, clients: mod), and the join compares the values both sides started with (kiln.registry.boot); a player whose angles differ gets the join's warning, or is turned away under modSync: refuse.
  • stepHeight.*, fallDamage.* and discoveryRange are live (now): Kiln's content sync brings the server's values to a Kiln player's game while it plays (within about 10 seconds of a change), whose movement and map then use them. A vanilla player keeps the game's own: its game predicts its character with the old step height, so its movement can disagree with the server's, and reveals its map with the old range. The server decides fall damage for everyone.

Known limits

  • slope.steepFloor and the slide.* values are read by no game code on this game build: edits of them are refused.
  • A character takes its slope angles when it is made, so they apply from the next start, never in a running world.
  • A character out of stamina slides from a fixed 45 degrees, whatever slope.sliding says; values below 2 degrees of slope.slidingMaterial count as 2.
  • Kiln's NoFallDamage rule and invulnerability cancel a fall whatever these distances say; Kiln's creative map reveal widens the revealed range further while it is on.
  • A discoveryRange wider than the map reveals the whole map in one frame, and the player's game then paints its whole map every frame; whether its map shows every part at once is not traced (Kiln's creative "whole map" reveal spreads the work over a few dozen frames instead).
  • Which part of the game's collision lets a character walk up a step of this height is not traced to the instruction: the values are read at every step (the check of the terrain and of placed objects, the ground settling).
  • Not yet seen in a real game: a character stepping higher, a fall at the new distances, a map revealed at the new range, sliding at the new angles (a playerless lab moves no character).

Enshrouded is a trademark of Keen Games GmbH. Kiln is unofficial.