Mods: model handles (render.model-id, model-generation, set-models-by-id; API level 11) so mods send no model names each tick; clear-post and set-lighting documented
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,7 @@ A block along the player's view.
|
||||
| --- | --- | --- |
|
||||
| `get-player` | `func() -> option<player>` | None on the title screen. |
|
||||
| `get-clock` | `func() -> option<clock>` | None on the title screen. |
|
||||
| `world-id` | `func() -> option<string>` | Which world is open (AirDef fork): `world:<folder>` for a saved world, `server:<address>` on a server; none on the title screen. Mods keep their state apart by it. |
|
||||
| `raycast` | `func(distance: f32) -> option<hit>` | The first block along the player's view (fluids pass), up to `distance` blocks (at most 1024; past the loaded chunks, across the distant terrain when LOD Distance is on), as of this tick. None when nothing is hit, and on the title screen. |
|
||||
|
||||
## `chat`
|
||||
@@ -399,6 +400,16 @@ Any four-cornered shape (a wheel's segment, an arrow): the corners in order roun
|
||||
| `centered` | `bool` | Centred on `at.x` instead of starting there. |
|
||||
| `shadow` | `bool` | |
|
||||
|
||||
### record `view-shape`
|
||||
|
||||
A picture of one of the mod's `set-views` cameras (AirDef fork).
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `view` | `u32` | The camera's id; an unknown one draws nothing. |
|
||||
| `rect` | `rect` | |
|
||||
| `mode` | `u32` | 0 as seen, 1 thermal (white hot), 2 night vision (green). |
|
||||
|
||||
### variant `shape`
|
||||
|
||||
| Case | Payload | |
|
||||
@@ -408,6 +419,7 @@ Any four-cornered shape (a wheel's segment, an arrow): the corners in order roun
|
||||
| `sprite` | `sprite-shape` | |
|
||||
| `item` | `item-shape` | |
|
||||
| `text` | `text-shape` | |
|
||||
| `view` | `view-shape` | |
|
||||
|
||||
### record `frame-rate`
|
||||
|
||||
@@ -442,6 +454,93 @@ Any four-cornered shape (a wheel's segment, an arrow): the corners in order roun
|
||||
| `distance` | `u32` | How far the distant terrain reaches, in chunks: 64 to 1024. On integrated graphics other than Apple's the game caps it lower. |
|
||||
| `reduced` | `bool` | Coarser far tiles, as the Far Detail setting's Reduced: 2 to 4 ms less GPU time per frame on integrated graphics. |
|
||||
|
||||
### record `model-instance`
|
||||
|
||||
A block model drawn in the world (AirDef fork).
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | Stays the same while the object lives: the game moves an id smoothly from where the last `set-models` put it. |
|
||||
| `model` | `string` | A block state as commands write it (`airdef:shahed`, `minecraft:stone`, `minecraft:furnace[facing=east]`): its block model is drawn. An unknown one draws nothing. |
|
||||
| `x` | `f64` | Where the model's centre is, in blocks. |
|
||||
| `y` | `f64` | |
|
||||
| `z` | `f64` | |
|
||||
| `rotation` | `tuple<f32, f32, f32, f32>` | Rotation about the model's centre: a quaternion (x, y, z, w). |
|
||||
| `scale` | `f32` | Uniform scale, 1.0 a block (0 to 64). |
|
||||
| `glow` | `bool` | Drawn at full brightness, whatever the light where it is. |
|
||||
|
||||
### record `model-instance-id`
|
||||
|
||||
`model-instance` with the model as a handle.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | |
|
||||
| `model` | `u32` | From `model-id`. |
|
||||
| `x` | `f64` | |
|
||||
| `y` | `f64` | |
|
||||
| `z` | `f64` | |
|
||||
| `rotation` | `tuple<f32, f32, f32, f32>` | |
|
||||
| `scale` | `f32` | |
|
||||
| `glow` | `bool` | |
|
||||
|
||||
### record `particle-spawn`
|
||||
|
||||
Particles to spawn on this client (AirDef fork).
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `particle` | `string` | As `/particle` names the type: `minecraft:flame`, `minecraft:dust`. |
|
||||
| `x` | `f64` | |
|
||||
| `y` | `f64` | |
|
||||
| `z` | `f64` | |
|
||||
| `spread` | `tuple<f32, f32, f32>` | Gaussian spread round the point, per axis, in blocks. |
|
||||
| `velocity` | `tuple<f32, f32, f32>` | Every particle's starting velocity, blocks a tick. |
|
||||
| `speed` | `f32` | Gaussian speed added to it per axis. |
|
||||
| `count` | `u32` | 1 to 256. |
|
||||
| `color` | `u32` | 0xRRGGBB for dust and coloured types (0: white). |
|
||||
| `scale` | `f32` | Dust size (0.01 to 4). |
|
||||
|
||||
### record `camera-view`
|
||||
|
||||
A camera the game renders the world from besides the player's eye (AirDef fork): the land, the sky and the entities near the player.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | Stays the same while the camera lives: the game turns it smoothly between the last two `set-views`. |
|
||||
| `x` | `f64` | |
|
||||
| `y` | `f64` | |
|
||||
| `z` | `f64` | |
|
||||
| `yaw` | `f32` | Degrees, as the player's: yaw 0 looks south (+z), pitch 90 down. |
|
||||
| `pitch` | `f32` | |
|
||||
| `fov` | `f32` | Vertical field of view, degrees (1 to 110). |
|
||||
| `width` | `u32` | The picture's size in pixels (16 to 1920 × 16 to 1080). |
|
||||
| `height` | `u32` | |
|
||||
|
||||
### record `point-light`
|
||||
|
||||
A light the mod's things give off (AirDef fork): rocket flames, flares, blasts. Drawn by the HD lighting (`set-lighting`).
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | Stays the same while the light lives: the game moves it smoothly. |
|
||||
| `x` | `f64` | |
|
||||
| `y` | `f64` | |
|
||||
| `z` | `f64` | |
|
||||
| `color` | `tuple<f32, f32, f32>` | Linear RGB, 0 to 1. |
|
||||
| `intensity` | `f32` | Brightness: about what it lights one block away (0 to 100000). |
|
||||
| `radius` | `f32` | Nothing past this many blocks (1 to 256). |
|
||||
|
||||
### record `lighting`
|
||||
|
||||
The HD lighting (AirDef fork): the world lit per pixel by the mods' lights, in high dynamic range, with bloom and tone mapping.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `hd` | `bool` | |
|
||||
| `exposure` | `f32` | 1 as is; more brightens. |
|
||||
| `bloom` | `f32` | How much bright things glow (0 none, 1 strong). |
|
||||
|
||||
| Function | Signature | What it does |
|
||||
| --- | --- | --- |
|
||||
| `set-hud` | `func(shapes: list<shape>)` | Replaces the mod's HUD shapes: up to 1024, drawn every frame in order over the HUD (after the hotbar, under chat and screens), hidden with the HUD (F1). An empty list removes them. |
|
||||
@@ -454,6 +553,20 @@ Any four-cornered shape (a wheel's segment, an arrow): the corners in order roun
|
||||
| `set-zoom` | `func(zoom: zoom)` | Zooms the camera until the next call (`factor` 1 ends it), only while playing: a screen opening or the spyglass's own view (which wins) leave the camera vanilla's. With several mods, the strongest zoom counts. |
|
||||
| `set-minimap` | `func(minimap: option<minimap>)` | Shows a map of the world around the player in `corner`, stacked with the game's overlays and the mods' panels, until the next call (none hides it). It looks like a map item: vanilla's map colours with their height shading and water depth, and the player's arrow. Underground, under a roof and in the Nether it maps the floor around the player's height. The game keeps the map's tiles and refreshes them within its own frame budget; hidden, they are dropped. One map shows at a time: the first loaded mod's. |
|
||||
| `set-far-terrain` | `func(far-terrain: option<far-terrain>)` | Draws the world beyond the render distance as distant terrain, out to `distance` chunks, until the next call (none ends it). The game builds it on its own workers, from the chunks already loaded or saved and, where nobody has been, from the world's generator; the simulation distance doesn't change. Only worlds whose generator the game has (single player and a LAN world you host) show it. The player's own LOD Distance setting, when on, wins. One far terrain shows at a time: the first loaded mod's. |
|
||||
| `set-models` | `func(models: list<model-instance>)` | Replaces the mod's models: up to 4096, drawn with the world's entities until replaced. Call it once a tick: the game interpolates each id between its last two positions and rotations every frame. An empty list removes them. |
|
||||
| `model-id` | `func(model: string) -> option<u32>` | A handle for a block state name, for `set-models-by-id` (AirDef fork, API level 11): the name crosses once, not every tick. None for a name that is no block state of the game's registry (nothing is remembered for it). Handles are valid until `model-generation` changes (the registry changed: a resource reload, another world's data); ask again for every name then. |
|
||||
| `model-generation` | `func() -> u32` | Moves on whenever the handles `model-id` gave stop being valid. A mod reads it before `set-models-by-id` and re-asks when it changed. |
|
||||
| `set-models-by-id` | `func(generation: u32, models: list<model-instance-id>) -> bool` | `set-models` with handles instead of names: the same models, limits and interpolation, fewer bytes across the boundary. `generation` is the `model-generation` the handles were asked under; if it is not the current one the call is ignored and returns false (re-ask the handles and call again). Handles the game doesn't know draw nothing. |
|
||||
| `spawn-particles` | `func(particles: list<particle-spawn>)` | Spawns particles on this client only: no command, no server. At most 512 spawns a call. |
|
||||
| `play-sound` | `func(event: string, x: f64, y: f64, z: f64, volume: f32, pitch: f32)` | Plays a sound event (`minecraft:entity.generic.explode`, `<mod>:<name>`) at a point on this client. |
|
||||
| `query-ground` | `func(columns: list<tuple<s32, s32>>)` | Asks for the ground height of these columns (x, z): at most 512 a tick, answered by `ground` from the next tick on. |
|
||||
| `ground` | `func() -> list<tuple<s32, s32, s32>>` | The answers to the last tick's `query-ground`: (x, z, y), y one above the highest block that blocks motion or holds a fluid, as the motion blocking heightmap; -64 where the chunk isn't loaded. |
|
||||
| `set-post` | `func(wgsl: string)` | A full-screen post pass (AirDef fork): WGSL defining `fn post(uv: vec2<f32>, pixel: vec2<f32>) -> vec4<f32>`, after a prelude with `frame` (camera matrices, time, `params`), the world's colour and depth and helpers (`scene`, `depth-at`, `view-dir`, `scene-distance`, `project`). It runs after the world, before the hand and the HUD. Compile errors come back in the chat and the log; the last good pass keeps running. |
|
||||
| `clear-post` | `func()` | Removes this mod's post pass: the world is shown as the game draws it. |
|
||||
| `set-params` | `func(params: list<f32>)` | The pass's `frame.params` (up to 1024 floats, as 256 vec4), kept until replaced; call it once a tick (the pass gets the partial tick in `frame.time.y`). |
|
||||
| `set-views` | `func(views: list<camera-view>)` | Replaces the mod's cameras: up to 8. A `view` shape shows one; the game renders up to three a frame, in turn. |
|
||||
| `set-lights` | `func(lights: list<point-light>)` | Replaces the mod's lights: up to 512, interpolated per id between the last two calls. |
|
||||
| `set-lighting` | `func(lighting: lighting)` | Switches the HD lighting on or off for this mod's world, with its exposure and bloom; off, the world is drawn as the game draws it. |
|
||||
|
||||
## `events`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user