Merge branch 'feat/server-mods-0.3' into feat/server-mod-test-scripts
# Conflicts: # crates/horizon-mods/src/testing.rs
This commit is contained in:
+3
-1
@@ -1,6 +1,6 @@
|
||||
# Horizon documentation
|
||||
|
||||
To play, use [the launcher](../launcher/README.md); the project site is [playhorizon.dev](https://playhorizon.dev). These pages are for developers.
|
||||
To play, use [the launcher](../launcher/README.md); the project site is [playhorizon.dev](https://playhorizon.dev). These pages are for developers. What is being done now and next, the work board and how to help: [the hub](https://playhorizon.dev/hub) ([ROADMAP.md](../ROADMAP.md), [roadmap/README.md](../roadmap/README.md) for keeping it current).
|
||||
|
||||
## Build and run
|
||||
|
||||
@@ -13,6 +13,7 @@ To play, use [the launcher](../launcher/README.md); the project site is [playhor
|
||||
- [Graphics](graphics.md): the Simple and Advanced graphics settings, the graphics benchmark and what it measured.
|
||||
- [Benchmark](benchmark.md): Horizon against vanilla 26.3 and vanilla with performance mods, on the same machine, world, path and settings: what is measured, how it is kept fair, how to reproduce it.
|
||||
- [Extras](extras.md): optional zoom, minimap, FPS and keystroke overlays and auto-reconnect, all off by default.
|
||||
- [Shader packs](shaders.md): Horizon's own WGSL shader packs, how to make and check one (`horizon-shader`).
|
||||
- [Mods](mods.md): Horizon's own mod system (Rust, sandboxed WebAssembly), how to make and install mods.
|
||||
- [Modpacks](modpacks.md): porting whole packs (ATM10 and smaller): import, inventory, carry-over, an agent per mod with a harness against the Java original, coverage, and how "10x" is measured.
|
||||
- [Launcher](../launcher/README.md): installs, updates and starts builds; its CLI and MCP server; releasing it.
|
||||
@@ -34,6 +35,7 @@ To play, use [the launcher](../launcher/README.md); the project site is [playhor
|
||||
## Architecture: world generation
|
||||
|
||||
- [World generation](world-generation.md): the pipeline from noise to features.
|
||||
- [Pregeneration](pregeneration.md): `/pregen`, generating, lighting and saving an area ahead of the players.
|
||||
- [Noise generation](noise-generation.md), [compiled density functions](density-functions.md), [structure density](structure-density.md), [terrain filling](terrain-filling.md).
|
||||
- Biomes: [lookup](biome-lookup.md), [temperatures](biome-temperatures.md).
|
||||
- Surfaces: [material surfaces](material-surfaces.md), [material conditions](material-conditions.md), [rule libraries](material-rule-libraries.md), [vertical anchors](vertical-anchors.md), [value providers](value-providers.md).
|
||||
|
||||
+2
-1
@@ -51,5 +51,6 @@ Every page has the same parts: **Overview** (what you can build), **Guide** (whe
|
||||
**Examples**, **Stability** (the level of each part, per [stability.md](stability.md)), **Changelog** and
|
||||
**Not there yet** (what is planned, so nobody builds on a guess).
|
||||
|
||||
The website's summary for players and authors is [playhorizon.dev/docs/apis](https://playhorizon.dev/docs/apis)
|
||||
The website shows these pages at [playhorizon.dev/docs/api](https://playhorizon.dev/docs/api), built from this
|
||||
folder, and a summary for players and authors at [playhorizon.dev/docs/apis](https://playhorizon.dev/docs/apis)
|
||||
(`website/docs/apis.md`).
|
||||
|
||||
+16
-1
@@ -138,9 +138,24 @@ Unknown keys are refused. Its CI runs `cargo-horizon-mod` (`crates/cargo-horizon
|
||||
| `cargo horizon-mod check <file> [--json]` | A submission's checks: its kind's (above), its signature with `--key` and `--signature`, and for a mod a trial run in the sandbox (40 ticks, 120 frames, a chat line, each command). |
|
||||
| `cargo horizon-mod registry check <base> <head> --files <dir>` | `check` on each file `head` lists and `base` doesn't: a pull request's new files. |
|
||||
| `cargo horizon-mod registry list <checkout>` | `<sha256> <id> <version> <file>` per version: the files to download. |
|
||||
| `cargo horizon-mod registry build <checkout> --files <dir> --out index.json` | Reads every entry and its file (`<dir>/<sha256>`), lists every problem, and writes the index with URLs `<release>/<id>-<version>/<file>`. |
|
||||
| `cargo horizon-mod registry build <checkout> --files <dir> --out index.json` | Reads every entry and its file (`<dir>/<sha256>`), lists every problem, and writes the index with URLs `<release><id>-<version>/<file>` (`--release`, ending in `/`, defaults to the repository's releases). |
|
||||
| `cargo horizon-mod registry review <base> <head> --author <login>` | A pull request's changes: a published file never changes and is never removed (take it down in `revoked.toml`), a kind never changes; changes by a non-owner and to owners or keys are pointed out for the reviewers. |
|
||||
|
||||
How the repository runs (its workflows are in `.github/workflows/`):
|
||||
|
||||
- **A pull request** (`check.yml`) runs `registry review`, downloads each new file from the `staging` prerelease, runs
|
||||
`registry check` on it and builds the index it would publish; the report is the run's summary. The tool is
|
||||
`cargo-horizon-mod` from Horizon at the commit in the repository variable `HORIZON_REV`. The form's pull requests
|
||||
are opened with the token of the account in the variable `REGISTRY_BOT`; for those, the author is the login in the
|
||||
body's `<!-- submitted-by: … -->` line.
|
||||
- **Merging** needs the `check` run and a CODEOWNER's review. `publish.yml` then makes each new version a release
|
||||
`<id>-<version>` and deploys `index.json` and `icons/` to GitHub Pages:
|
||||
`https://ludovic111.github.io/horizon-mods/index.json`, served with `Access-Control-Allow-Origin: *`.
|
||||
- **Weekly**, `cleanup.yml` deletes staged copies of published files after 7 days and of files no open pull request
|
||||
lists after 30.
|
||||
- **Taking a file down** is a pull request adding it to `revoked.toml`. Removing an entry outright (a test, a project
|
||||
nobody installed) fails `registry review` on purpose and needs an administrator's merge.
|
||||
|
||||
Kinds open to submissions: `mod`, `modpack`, `resourcepack`. `shader` is in the schema and stays closed until
|
||||
Horizon's own shader pack format exists (Iris and OptiFine packs are for the Modrinth browser); its check will compile
|
||||
the pack in a headless Horizon. A new kind gets its own check before it opens.
|
||||
|
||||
+296
-1
@@ -11,14 +11,18 @@ The contract between Horizon and its mods: the WIT package `horizon:mods@0.1.0`,
|
||||
| `chat` | [`chat`](#chat) | show you chat messages |
|
||||
| `hud` | [`hud`](#hud) | draw text on your screen |
|
||||
| `storage` | [`storage`](#storage) | save its own settings to disk |
|
||||
| `command` | [`command`](#command) | run commands as you, with your permissions |
|
||||
| `registries` | data files (`assets/`, `data/`), no interface | add blocks and items to your worlds |
|
||||
| `ui` | [`ui`](#ui) | show its own screens and a settings page |
|
||||
| `render` | [`render`](#render) | draw on your screen, shake and zoom the camera |
|
||||
| `input` | [`input`](#input) | see the keys you hold and your clicks, take over the use button on its own items and the mouse wheel, and add keys |
|
||||
| `players` | [`players`](#players) | see who is on the server and message them |
|
||||
|
||||
## World `horizon-mod`
|
||||
|
||||
A client mod: runs in the player's game.
|
||||
|
||||
- Imports (what the game offers): `log`, `game`, `chat`, `hud`, `storage`
|
||||
- Imports (what the game offers): `log`, `game`, `chat`, `hud`, `storage`, `command`
|
||||
- Exports (what the mod provides): `events`
|
||||
|
||||
## World `horizon-server-mod`
|
||||
@@ -28,6 +32,27 @@ A server mod (manifest `side = "server"`, `api = "0.3"`, experimental): runs whe
|
||||
- Imports (what the game offers): `log`, `storage`, `players`
|
||||
- Exports (what the mod provides): `server-events`
|
||||
|
||||
## World `horizon-ui-mod`
|
||||
|
||||
A mod with widgets (capability `ui`): the SDK builds every mod against this world. Mods built for `horizon-mod` alone (no `ui-events` export) still load and simply hear nothing of their widgets.
|
||||
|
||||
- Imports (what the game offers): `ui`, `render`, `input`, `log`, `game`, `chat`, `hud`, `storage`, `command`
|
||||
- Exports (what the mod provides): `ui-events`, `events`
|
||||
|
||||
## World `ui-host`
|
||||
|
||||
The game's side of `horizon-ui-mod` beyond `horizon-mod`.
|
||||
|
||||
- Imports (what the game offers): `ui`
|
||||
- Exports (what the mod provides): `ui-events`
|
||||
|
||||
## World `render-host`
|
||||
|
||||
The game's side of capability `render` (imports only).
|
||||
|
||||
- Imports (what the game offers): `render`, `input`
|
||||
- Exports (what the mod provides):
|
||||
|
||||
## `log`
|
||||
|
||||
Access: always granted.
|
||||
@@ -127,6 +152,276 @@ Capability `storage`: a per-mod folder of small key/value files, quota'd (docs/m
|
||||
| `set` | `func(key: string, value: list<u8>) -> result<_, string>` | Errs on a malformed key or over quota (bytes for the whole mod). |
|
||||
| `delete` | `func(key: string)` | No error if `key` was already absent. |
|
||||
|
||||
## `command`
|
||||
|
||||
Access: capability `command`.
|
||||
|
||||
Capability `command`: vanilla commands run as the player, with the player's permissions, after the hook call returns (8 per call). A mod's own commands are not run this way.
|
||||
|
||||
| Function | Signature | What it does |
|
||||
| --- | --- | --- |
|
||||
| `run` | `func(line: string)` | `line` without its slash; its feedback goes to the chat as if typed. |
|
||||
|
||||
## `ui`
|
||||
|
||||
Access: capability `ui`.
|
||||
|
||||
Capability `ui`: widgets the game draws with its own menus' widgets, for a screen the mod owns and a settings page in Options > Mods. Layout and drawing are the game's: a mod says what its widgets hold, never where they sit or how they look, and the game clips everything it is handed.
|
||||
|
||||
### record `text-widget`
|
||||
|
||||
A line of text.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | The mod's own name for the widget; `ui-events` calls echo it. |
|
||||
| `text` | `string` | Up to 256 characters. |
|
||||
| `color` | `u32` | 0xRRGGBB; 0 is the menus' white. |
|
||||
|
||||
### record `item-widget`
|
||||
|
||||
An item's icon and a name beside it, as recipe viewers show them.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | The mod's own name for the widget. |
|
||||
| `item` | `string` | `minecraft:diamond`, `<mod>:<path>`; an unknown id draws a "?". |
|
||||
| `name` | `string` | The name shown beside the icon (empty: the item's own). |
|
||||
|
||||
### record `list-widget`
|
||||
|
||||
Rows the player picks one of, as an options page lists choices: a pick is `ui-events::select`, `selected` is the row to mark now.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | The mod's own name for the widget; `ui-events::select` echoes it. |
|
||||
| `rows` | `list<string>` | The rows' texts, at most 512, each up to 256 characters. |
|
||||
| `selected` | `option<u32>` | The row to mark as the current choice, if any. |
|
||||
|
||||
### record `button-widget`
|
||||
|
||||
A thing on a mod's screen or settings page. A button as the options pages have them (200 × 20): a click is `ui-events::select(id, 0)`. Mods cycle its label for a choice ("Corner: Top Left").
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `u32` | The mod's own name for the widget. |
|
||||
| `label` | `string` | Up to 256 characters. |
|
||||
|
||||
### variant `widget`
|
||||
|
||||
| Case | Payload | |
|
||||
| --- | --- | --- |
|
||||
| `text` | `text-widget` | Text the player reads. |
|
||||
| `button` | `button-widget` | A button. |
|
||||
| `item` | `item-widget` | An item's icon and name. |
|
||||
| `list` | `list-widget` | Rows the player picks from. |
|
||||
|
||||
### record `screen`
|
||||
|
||||
A screen the mod owns: a title over widgets stacked down the middle, the Done button the game adds, and Esc to leave it.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `title` | `string` | Its title, up to 256 characters. |
|
||||
| `widgets` | `list<widget>` | Its widgets, in order, at most 64. |
|
||||
|
||||
| Function | Signature | What it does |
|
||||
| --- | --- | --- |
|
||||
| `open-screen` | `func(screen: screen)` | Show `screen` over the game; a second call while it is open replaces it. Only the last call of one hook counts. |
|
||||
| `close-screen` | `func()` | Close the mod's screen when it is open (the mod hears no `closed` for this: it was its own doing). |
|
||||
| `set-settings` | `func(widgets: list<widget>)` | The mod's page in Options > Mods, reached from a settings button on its row: the widgets it shows, an empty list for no page. The player opening the page is `ui-events::settings-opened`: push fresh widgets then; later calls update the page while it shows. |
|
||||
|
||||
## `ui-events`
|
||||
|
||||
Access: exported by the mod: the game calls it.
|
||||
|
||||
What the game calls on a mod that shows widgets (capability `ui`): what the player did with them.
|
||||
|
||||
| Function | Signature | What it does |
|
||||
| --- | --- | --- |
|
||||
| `select` | `func(id: u32, row: u32)` | A row of one of the mod's `list` widgets was picked: the widget's `id` and the row, on the screen or the settings page that showed it. |
|
||||
| `closed` | `func()` | The player left the mod's screen (Esc or Done); not for a screen the mod closed itself or one that went away with the mod. |
|
||||
| `settings-opened` | `func()` | The player opened the mod's settings page in Options > Mods: call `ui::set-settings` now to fill it with fresh widgets. |
|
||||
|
||||
## `input`
|
||||
|
||||
Access: capability `input`.
|
||||
|
||||
Capability `input` (experimental: the manifest needs `experimental = ["input"]`): the use button on items the mod claims, and the mod's own keys. Events wait for `poll`, at most 256.
|
||||
|
||||
### record `held-item`
|
||||
|
||||
The main hand's stack.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `id` | `string` | `minecraft:spyglass`, `<mod>:<path>`. |
|
||||
| `count` | `u32` | |
|
||||
| `slot` | `u32` | The hotbar slot, 0 to 8. |
|
||||
|
||||
### record `item-use`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `item` | `held-item` | |
|
||||
| `ticks` | `u32` | Game ticks the button was held (0 on `use-start`). |
|
||||
|
||||
### variant `event`
|
||||
|
||||
| Case | Payload | |
|
||||
| --- | --- | --- |
|
||||
| `use-start` | `item-use` | The use button went down with a claimed item in the main hand. The game does nothing else with the click: no placing, no eating, no swing. |
|
||||
| `use-stop` | `item-use` | It came up again, or the item left the hand, or a screen opened. |
|
||||
| `key-down` | `string` | A key `register-key` named went down or up while playing (no screen open). The game's own mapping on that key still runs. A screen opening lets every held key up. |
|
||||
| `key-up` | `string` | |
|
||||
| `wheel` | `f32` | Mouse wheel steps while the mod holds the wheel (`claim-wheel`): positive away from the player, as the hotbar reads them. |
|
||||
|
||||
### record `mapping-state`
|
||||
|
||||
A mapping as the player has bound it.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `label` | `string` | The bound key's name as Controls shows it: `W`, `Space`, `LMB`. |
|
||||
| `down` | `bool` | Held down now (as of this frame for a mod with a `frame` hook, else this tick). |
|
||||
|
||||
| Function | Signature | What it does |
|
||||
| --- | --- | --- |
|
||||
| `claim-items` | `func(ids: list<string>)` | The items whose use the mod handles instead of the game, by id (at most 64). Replaces the previous list. |
|
||||
| `register-key` | `func(name: string, label: string, key: string) -> result<_, string>` | A key of the mod's: `name` comes back in `key-down` and `key-up`, `label` says what it does, `key` is the key as options.txt writes it (`key.keyboard.r`), the default: the player can bind another one on the mod's page in Options > Mods, and that one wins. At most 16; an unknown key is an error. |
|
||||
| `held` | `func() -> option<held-item>` | The main hand's stack, as of this tick; none when it is empty. |
|
||||
| `poll` | `func() -> list<event>` | The events since the last call, oldest first. |
|
||||
| `claim-wheel` | `func(on: bool)` | Takes the mouse wheel while playing (true) or gives it back: while taken, its steps are the mod's `wheel` events and the hotbar doesn't move. The game gives it back when the mod stops. |
|
||||
| `mapping` | `func(name: string) -> option<mapping-state>` | A movement or click mapping as the player has bound it: `key.forward`, `key.left`, `key.back`, `key.right`, `key.jump`, `key.sneak`, `key.sprint`, `key.attack` or `key.use`. None for another name. |
|
||||
| `clicks-per-second` | `func() -> tuple<u32, u32>` | Clicks of the attack and use buttons in the last second. |
|
||||
|
||||
## `render`
|
||||
|
||||
Access: capability `render`.
|
||||
|
||||
Capability `render` (experimental: the manifest needs `experimental = ["render"]`): shapes the game draws for the mod with its own renderer, kept until the mod replaces them (no call per frame). A mod never supplies shader code.
|
||||
|
||||
### enum `corner`
|
||||
|
||||
A corner of the screen, as `hud`'s panels use them.
|
||||
|
||||
| Case | |
|
||||
| --- | --- |
|
||||
| `top-left` | |
|
||||
| `top-right` | |
|
||||
| `bottom-left` | |
|
||||
| `bottom-right` | |
|
||||
|
||||
### record `rect`
|
||||
|
||||
A rectangle in GUI pixels: the top left corner and the size.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `x` | `f32` | |
|
||||
| `y` | `f32` | |
|
||||
| `w` | `f32` | |
|
||||
| `h` | `f32` | |
|
||||
|
||||
### record `point`
|
||||
|
||||
A point in GUI pixels from the screen's top left.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `x` | `f32` | |
|
||||
| `y` | `f32` | |
|
||||
|
||||
### record `fill-shape`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `rect` | `rect` | |
|
||||
| `color` | `u32` | 0xAARRGGBB. |
|
||||
|
||||
### record `quad-shape`
|
||||
|
||||
Any four-cornered shape (a wheel's segment, an arrow): the corners in order round it.
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `corners` | `tuple<point, point, point, point>` | |
|
||||
| `color` | `u32` | 0xAARRGGBB. |
|
||||
|
||||
### record `sprite-shape`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `sprite` | `string` | One of the game's GUI sprites, as `gui/sprites/` names them (`hud/heart/full`, `widget/button`), the resource packs' versions included. An unknown one draws nothing. |
|
||||
| `rect` | `rect` | |
|
||||
| `color` | `u32` | A tint, 0xAARRGGBB: 0xFFFFFFFF draws it as it is. |
|
||||
|
||||
### record `item-shape`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `item` | `string` | `minecraft:diamond`, `<mod>:<path>`; an unknown one draws nothing. |
|
||||
| `at` | `point` | The icon's top left. |
|
||||
| `scale` | `f32` | 1.0 is the hotbar's 16 × 16. |
|
||||
|
||||
### record `text-shape`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `text` | `string` | Up to 256 characters, one line. |
|
||||
| `at` | `point` | |
|
||||
| `color` | `u32` | 0xRRGGBB, as `hud`'s lines. |
|
||||
| `centered` | `bool` | Centred on `at.x` instead of starting there. |
|
||||
| `shadow` | `bool` | |
|
||||
|
||||
### variant `shape`
|
||||
|
||||
| Case | Payload | |
|
||||
| --- | --- | --- |
|
||||
| `fill` | `fill-shape` | |
|
||||
| `quad` | `quad-shape` | |
|
||||
| `sprite` | `sprite-shape` | |
|
||||
| `item` | `item-shape` | |
|
||||
| `text` | `text-shape` | |
|
||||
|
||||
### record `frame-rate`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `fps` | `u32` | Frames drawn in the last second. |
|
||||
| `min` | `u32` | The slowest frame's rate, and the 1% low (the 99th percentile frame time's rate), over the last 5 seconds. |
|
||||
| `low` | `u32` | |
|
||||
|
||||
### record `zoom`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `factor` | `f32` | The field of view is divided by it: 1 is none, at most 10. |
|
||||
| `smooth` | `bool` | Ease in and out through the game's field-of-view easing, as the spyglass does, instead of at once. |
|
||||
| `turn` | `f32` | Mouse turning is multiplied by it while zoomed: 1 keeps the player's sensitivity, at least 0.05. |
|
||||
|
||||
### record `minimap`
|
||||
|
||||
| Field | Type | |
|
||||
| --- | --- | --- |
|
||||
| `corner` | `corner` | |
|
||||
| `size` | `f32` | Its side in GUI pixels, 16 to 256. |
|
||||
| `blocks-per-pixel` | `f32` | World blocks per map pixel, 0.5 to 4; the map is 128 × 128 pixels. |
|
||||
| `rotate` | `bool` | The map turns with the player, who faces up, and an N on its rim marks north. Otherwise north is up and the player's arrow turns. |
|
||||
| `round` | `bool` | Round, the corners left clear; otherwise square. |
|
||||
|
||||
| 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. |
|
||||
| `gui-size` | `func() -> tuple<f32, f32>` | The screen's size in GUI pixels (width, height), as of this tick. |
|
||||
| `shake` | `func(strength: f32, seconds: f32)` | Shakes the camera: a jolt of `strength` (0 to 1, 1 the hardest) that fades out over `seconds` (at most 10). Jolts add up to 1. The view turns, the player doesn't, and the player's Distortion Effects option scales it (0 turns it off). |
|
||||
| `set-corner` | `func(corner: corner, width: f32, height: f32, shapes: list<shape>)` | Replaces the mod's corner panel: shapes in GUI pixels from the top left of a `width` × `height` box that the game places in `corner`, stacked with the game's overlays and the other mods' panels (under the status effects at the top right), as `hud`'s panels are. |
|
||||
| `clear-corner` | `func()` | Removes the mod's corner panel. |
|
||||
| `text-width` | `func(text: string) -> f32` | The width of one line of text in GUI pixels, in the HUD's font: exact for Latin letters (U+0000 to U+024F), 6 per other character. |
|
||||
| `frame-stats` | `func() -> frame-rate` | The game's frame counter, recomputed twice a second. |
|
||||
| `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. |
|
||||
|
||||
## `events`
|
||||
|
||||
Access: exported by the mod: the game calls it.
|
||||
|
||||
+11
-1
@@ -19,11 +19,14 @@ the player before the mod is turned on, and checked against the component's real
|
||||
| Capabilities | 6: `game-read`, `chat`, `hud`, `storage`, `registries`, `players` |
|
||||
| Manifest `api` lines served | 3: `0.1` (code), `0.2` (content), `0.3` (server mods, experimental) |
|
||||
| SDK | the `Mod` trait (5 methods), `Registration` (4 builders), `export_mod!`, log helpers; `server::ServerMod` (8 methods), `server::Registration` (5 builders), `export_server_mod!` |
|
||||
| `cargo horizon-mod` | `new`, `build`, `run`, `test`, `check` |
|
||||
| `cargo horizon-mod` | `new` (templates `code` and `content`), `build`, `run`, `test`, `check` |
|
||||
| Example mods | `coords-hud` (code), `ruby-content` (content), `welcome` (server) |
|
||||
|
||||
## Guide
|
||||
|
||||
The step-by-step guide, from installing the tools to publishing on the registry, is
|
||||
[Make a mod](https://playhorizon.dev/docs/make-a-mod) on the website. In short:
|
||||
|
||||
1. `rustup target add wasm32-unknown-unknown`, `cargo install --git https://github.com/ludovic111/horizon
|
||||
cargo-horizon-mod`, then `cargo horizon-mod new my-mod` ([Making a mod](../mods.md#making-a-mod)).
|
||||
2. Implement `Mod` for your type, list the capabilities you import in `horizon-mod.toml`
|
||||
@@ -60,6 +63,7 @@ scripting runtime in the game.
|
||||
| Way in | For | Status | Template and example |
|
||||
| --- | --- | --- | --- |
|
||||
| Rust | most mods; the fastest | first-class: the SDK, `cargo horizon-mod` | `cargo horizon-mod new`, `coords-hud` |
|
||||
| Data only | blocks and items with no code | first-class: content mods (API 0.2) | `cargo horizon-mod new --template content`, `ruby-content` |
|
||||
| Lua scripts | people who don't want a compiler | planned: a script mod whose code is a `.lua` file, run by Horizon's own interpreter mod | planned, with the same example as Rust |
|
||||
| C, C++, Zig | authors of those languages | to evaluate: bindings generated from the WIT, built without WASI | one each if it passes |
|
||||
| Go (TinyGo), AssemblyScript, JavaScript / TypeScript | authors of those languages | to evaluate: each needs its toolchain to emit a component without WASI imports, or an interpreter mod as for Lua | one each if it passes |
|
||||
@@ -104,5 +108,11 @@ What real mods need next, in the order modpacks and servers need it:
|
||||
- API 0.3 (server mods, experimental): world `horizon-server-mod`, capability `players`, the `server-events`
|
||||
hooks; SDK `server::ServerMod`; example `welcome`.
|
||||
- SDK: `cargo horizon-mod test` and `horizon_mods::testing`, test scripts in TOML; the template has one.
|
||||
- Experimental: `ui` button widget; `render.set-corner`, `text-width`, `frame-stats`; `input.mapping`,
|
||||
`clicks-per-second` (what the official FPS, keystrokes and zoom mods need).
|
||||
- Experimental `input` (`experimental = ["input"]`): `claim-items`, `register-key`, `held`, `poll` (use-start,
|
||||
use-stop, key-down, key-up).
|
||||
- Experimental `render` (`experimental = ["render"]`): HUD shapes (fill, quad, sprite, item, text), `gui-size`, camera
|
||||
`shake`, drawn by the game's own renderer.
|
||||
- API 0.2 (content): data-driven blocks and items, tags, `horizon:add_to`, terrain adaptation.
|
||||
- API 0.1.0: `log`, `game`, `chat`, `hud`, `storage`; `init`, `tick`, `frame`, `command`, `chat`.
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
# Shader API reference (0.1)
|
||||
|
||||
Generated from `crates/horizon-shader-api` (`HORIZON_WRITE_DOCS=1 cargo test -p horizon-shader-api --test reference`
|
||||
rewrites it; the test fails when it drifts). The API's design and pack format: [shaders.md](shaders.md).
|
||||
|
||||
A stage is a function your WGSL defines, with the signature below; Horizon puts the prelude (these structs, the
|
||||
resources and helpers) before your files and calls the function from its own pass. Your files declare no
|
||||
bindings and no entry points, and no names starting with `horizon_`.
|
||||
|
||||
## Stages
|
||||
|
||||
| Stage | In `horizon-shaders.toml` | Your function |
|
||||
| --- | --- | --- |
|
||||
| sky | `[sky]` | `fn sky(input: SkyInput) -> vec4<f32>` |
|
||||
| material | `[material]` | `fn material(input: MaterialInput) -> Surface` |
|
||||
| post | `[[post]]` | `fn post(input: PostInput) -> vec4<f32>` |
|
||||
|
||||
## sky
|
||||
|
||||
`fn sky(input: SkyInput) -> vec4<f32>`
|
||||
|
||||
### `SkyInput`
|
||||
|
||||
One direction of the sky, for `fn sky(input: SkyInput) -> vec4<f32>`. The sun, moon, stars and clouds are drawn over the result.
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `direction` | `vec3<f32>` | Unit view ray, camera-relative world axes. |
|
||||
| `color` | `vec4<f32>` | Vanilla's sky colour along the ray (sky, fog and sunrise). |
|
||||
|
||||
Resources (bind group 3):
|
||||
|
||||
| Binding | Declaration | Meaning |
|
||||
| --- | --- | --- |
|
||||
| 0 | `var<uniform> frame: Frame` | The frame (`Frame`). |
|
||||
|
||||
## material
|
||||
|
||||
`fn material(input: MaterialInput) -> Surface`
|
||||
|
||||
### `MaterialInput`
|
||||
|
||||
One point of a block's surface, for `fn material(input: MaterialInput) -> Surface`.
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `albedo` | `vec4<f32>` | The block texture's colour here (alpha 0..1). |
|
||||
| `tint` | `vec4<f32>` | The vertex colour: biome tint, face shade and ambient occlusion. |
|
||||
| `light` | `vec2<f32>` | Block and sky light, 0..1, smoothed over the face. |
|
||||
| `lightmap` | `vec3<f32>` | Vanilla's light colour for that light this frame. |
|
||||
| `position` | `vec3<f32>` | The point, camera-relative, in blocks. |
|
||||
| `uv` | `vec2<f32>` | The texture coordinate inside the block atlas. |
|
||||
| `translucent` | `bool` | Drawn in the translucent pass (water, stained glass, ice). |
|
||||
|
||||
### `Surface`
|
||||
|
||||
What `material` returns. Vanilla's own is `albedo * tint * vec4(lightmap, 1.0)`; Horizon then applies the alpha test (cutout and translucent) and fog.
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `color` | `vec4<f32>` | The lit colour, 0..1, with its alpha. |
|
||||
|
||||
Resources (bind group 3):
|
||||
|
||||
| Binding | Declaration | Meaning |
|
||||
| --- | --- | --- |
|
||||
| 0 | `var<uniform> frame: Frame` | The frame (`Frame`). |
|
||||
|
||||
## post
|
||||
|
||||
`fn post(input: PostInput) -> vec4<f32>`
|
||||
|
||||
### `PostInput`
|
||||
|
||||
One pixel of the picture, for `fn post(input: PostInput) -> vec4<f32>`.
|
||||
|
||||
| Field | Type | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `uv` | `vec2<f32>` | Where the pixel is, 0..1 from the top left. |
|
||||
| `pixel` | `vec2<f32>` | The pixel's centre, in pixels from the top left of what the pass draws (the world's size; the window's for the last pass). |
|
||||
| `color` | `vec4<f32>` | The previous pass's colour here (the world's picture for the first pass). |
|
||||
| `depth` | `f32` | The world's depth here, reversed: 0 is the sky. |
|
||||
|
||||
Resources (bind group 3):
|
||||
|
||||
| Binding | Declaration | Meaning |
|
||||
| --- | --- | --- |
|
||||
| 0 | `var<uniform> frame: Frame` | The frame (`Frame`). |
|
||||
| 1 | `var scene_color: texture_2d<f32>` | The world's picture before any pass. |
|
||||
| 2 | `var scene_depth: texture_depth_2d` | The world's depth, reversed (1 near, 0 far and sky). |
|
||||
| 3 | `var previous: texture_2d<f32>` | The previous pass's output (`scene_color` for the first pass). |
|
||||
| 4 | `var linear_sampler: sampler` | Bilinear filtering, clamped to the edges. |
|
||||
| 5 | `var nearest_sampler: sampler` | Nearest texel, clamped to the edges. |
|
||||
|
||||
Helpers:
|
||||
|
||||
- `fn depth_at(uv: vec2<f32>) -> f32`: the world's depth at `uv`.
|
||||
- `fn view_position(uv: vec2<f32>, depth: f32) -> vec3<f32>`: the camera-relative position, in blocks, of
|
||||
the point at `uv` and `depth`.
|
||||
|
||||
## The frame
|
||||
|
||||
### `Frame`
|
||||
|
||||
The frame, as `frame` in every stage. Positions and directions are in world axes relative to the camera (x east, y up, z south), so they stay precise far from the world's origin; depth is reversed (1 near, 0 at the far plane and in the sky).
|
||||
|
||||
| Field | Type | Offset | Meaning |
|
||||
| --- | --- | --- | --- |
|
||||
| `view` | `mat4x4<f32>` | 0 | Camera-relative world to view space: the camera's rotation. |
|
||||
| `projection` | `mat4x4<f32>` | 64 | View to clip space (reversed depth, wgpu's clip space: z 0..1). |
|
||||
| `view_inverse` | `mat4x4<f32>` | 128 | View to camera-relative world space. |
|
||||
| `projection_inverse` | `mat4x4<f32>` | 192 | Clip to view space. |
|
||||
| `camera_position` | `vec3<f32>` | 256 | The camera's world position, in blocks (about a millimetre of precision 10 000 blocks out). |
|
||||
| `time` | `f32` | 268 | Seconds since the pack was loaded, wrapping to 0 every hour. |
|
||||
| `sun_direction` | `vec3<f32>` | 272 | Unit vector toward the sun (below the horizon at night). |
|
||||
| `day_time` | `f32` | 284 | The time of day, 0..1: 0 sunrise, 0.25 noon, 0.5 sunset, 0.75 midnight. |
|
||||
| `moon_direction` | `vec3<f32>` | 288 | Unit vector toward the moon. |
|
||||
| `game_time` | `f32` | 300 | Vanilla's GameTime: (game time % 24000 + partial tick) / 24000, 0..1. |
|
||||
| `sky_color` | `vec3<f32>` | 304 | Vanilla's sky colour this frame, 0..1. |
|
||||
| `rain` | `f32` | 316 | Rain strength, 0..1. |
|
||||
| `fog_color` | `vec3<f32>` | 320 | Vanilla's fog colour this frame (also the clear colour), 0..1. |
|
||||
| `thunder` | `f32` | 332 | Thunder strength, 0..1. |
|
||||
| `resolution` | `vec2<f32>` | 336 | The size of the world's picture, in pixels (the resolution scale applied). |
|
||||
| `eye_light` | `vec2<f32>` | 344 | Block and sky light at the camera, 0..1 (level / 15). |
|
||||
| `fog_start` | `f32` | 352 | Where vanilla's fog starts, in blocks from the camera. |
|
||||
| `fog_end` | `f32` | 356 | Where vanilla's fog is full, in blocks. |
|
||||
| `render_distance` | `f32` | 360 | The render distance, in blocks. |
|
||||
| `far` | `f32` | 364 | The far plane, in blocks. |
|
||||
| `night_vision` | `f32` | 368 | Night vision strength, 0..1. |
|
||||
| `blindness` | `f32` | 372 | Blindness strength, 0..1. |
|
||||
| `darkness` | `f32` | 376 | The darkness effect's strength, 0..1. |
|
||||
| `brightness` | `f32` | 380 | The Brightness option, 0..1 (Moody to Bright). |
|
||||
| `eye_in` | `u32` | 384 | What the camera is in: 0 air, 1 water, 2 lava, 3 powder snow. |
|
||||
| `dimension` | `i32` | 388 | 0 the Overworld, -1 the Nether, 1 the End, 2 any other dimension. |
|
||||
| `frame_index` | `u32` | 392 | Frames drawn since the pack was loaded (wraps). |
|
||||
| `hide_gui` | `u32` | 396 | 1 while F1 hides the HUD, else 0. |
|
||||
|
||||
## Options
|
||||
|
||||
Each `[[options]]` entry sets the WGSL `override` of the same name when the pipelines are built:
|
||||
|
||||
| `type` | Keys | The `override` |
|
||||
| --- | --- | --- |
|
||||
| `bool` | `default` | `override <id>: bool` |
|
||||
| `float` | `default`, `min`, `max`, `step` | `override <id>: f32` |
|
||||
| `int` | `default`, `min`, `max` | `override <id>: i32` |
|
||||
| `choice` | `values`, `default` (one of them) | `override <id>: u32`, the value's index |
|
||||
|
||||
## Limits
|
||||
|
||||
- 8 post passes, 64 options, `budget.gpu_ms` up to 16.
|
||||
- 256 KiB per WGSL file, 8 MiB per pack.
|
||||
- Per stage: 20000 naga expressions over all its functions, 64 texture reads (samples,
|
||||
gathers and loads, the prelude's included).
|
||||
|
||||
## The check
|
||||
|
||||
A pack runs only after it passes `horizon_shader_api::check` (the game when it loads a pack, the launcher before it
|
||||
installs one, the registry's CI): each stage is parsed and validated by naga, checked against its signature and
|
||||
the rules above, and translated for Vulkan (SPIR-V), Metal and DirectX 12 (HLSL) with its options at their
|
||||
defaults, minimums and maximums. Every option must be an `override` of its type in some stage; an `override`
|
||||
that is no option needs a default.
|
||||
+53
-3
@@ -34,10 +34,55 @@ how the world is fed to the GPU.
|
||||
benchmark ([benchmark-report.md](../benchmark-report.md)) records the pack and its cost, so "fast" stays measured.
|
||||
- **Off by default.** Without a pack the renderer is vanilla's look, and no pack code runs.
|
||||
|
||||
## The pack format (schema 1)
|
||||
|
||||
A pack is a folder, or the same files zipped as a `.hshader`, with `horizon-shaders.toml` at its root
|
||||
(crate `horizon-shader-api`; the sample with every key is
|
||||
`crates/horizon-shader-api/tests/samples/schema-1/`):
|
||||
|
||||
```toml
|
||||
schema = 1 # the manifest's format; a reader refuses schemas newer than it knows
|
||||
id = "soft_light" # [a-z0-9_]{1,64}: the settings key and the registry id
|
||||
name = "Soft Light"
|
||||
version = "1.0.0"
|
||||
api = "0.1" # the shader API line the WGSL is written for
|
||||
description = "..." # optional, like authors and license
|
||||
shared = ["common.wgsl"] # optional: WGSL put before every stage's file, in order
|
||||
|
||||
[sky] # each stage is optional, but a pack has at least one
|
||||
file = "sky.wgsl"
|
||||
|
||||
[material]
|
||||
file = "material.wgsl"
|
||||
|
||||
[[post]] # full-screen passes, in the order they run (8 at most)
|
||||
file = "post/grade.wgsl"
|
||||
name = "Colour grade" # optional: the GPU time overlay's label
|
||||
|
||||
[[options]] # 64 at most; `id` is the WGSL `override` it sets
|
||||
id = "saturation"
|
||||
name = "Saturation"
|
||||
type = "float" # bool, float (min, max, step), int (min, max), choice (values)
|
||||
default = 1.1
|
||||
min = 0.0
|
||||
max = 2.0
|
||||
step = 0.05
|
||||
|
||||
[budget]
|
||||
gpu_ms = 1.5 # optional: the GPU time the pack aims to add (0 to 16 ms)
|
||||
```
|
||||
|
||||
An option's `override` has the type of its kind: `bool`, `f32`, `i32`, or `u32` for a choice (the index of the
|
||||
value). The pack holds only the manifest, the `.wgsl` files it names (each used, UTF-8, 256 KiB at most),
|
||||
`README.md`, `LICENSE` (`.md`, `.txt`) and `icon.png`, under plain paths, 8 MiB in all. A `.hshader` is built
|
||||
the same way every time (files in path order, fixed dates), so a pack's SHA-256 depends only on its files.
|
||||
|
||||
## Guide, reference and examples
|
||||
|
||||
None yet. When the first stage lands: a guide here, a generated reference (`shaders-reference.md`) and an example pack
|
||||
in the repository that the renderer's tests load.
|
||||
- [shaders-reference.md](shaders-reference.md): every stage's signature, input and output structs, resources and
|
||||
helpers, the frame's fields with their units, option types and limits, generated from `crates/horizon-shader-api`.
|
||||
- [The guide](../shaders.md): making a pack with `horizon-shader new`, `check` and `pack`; the templates and the
|
||||
example pack (`crates/horizon-shader-api/packs/golden_hour`).
|
||||
|
||||
## Stability
|
||||
|
||||
@@ -46,9 +91,14 @@ pack exist ([stability.md](stability.md)).
|
||||
|
||||
## Not there yet
|
||||
|
||||
Everything on this page. The order: the renderer hooks shared with the format loader, then the material and post
|
||||
The stages and everything that runs a pack (the format above is read and checked). The order: the renderer hooks shared with the format loader, then the material and post
|
||||
stages with options and hot reload, then the overlay, lighting, sky and shadow stages.
|
||||
|
||||
## Changelog
|
||||
|
||||
- 2026-10-26: the post stage in the game (`HORIZON_SHADER_PACK`, hot reload with the last good pack kept).
|
||||
- 2026-10-25: `horizon-shader` (`new`, `check`, `pack`), three templates, the example pack and the guide.
|
||||
- 2026-10-25: the check (naga validation, signatures, options, budgets, SPIR-V/Metal/HLSL translation).
|
||||
- 2026-10-25: the stages of API 0.1 (sky, material, post), their inputs and the generated reference.
|
||||
- 2026-10-25: the pack format, schema 1: `horizon-shaders.toml` and the `.hshader` package.
|
||||
- 2026-10-24: the earlier shader pack code was removed; this API is designed from scratch.
|
||||
|
||||
+22
-5
@@ -26,12 +26,13 @@ promise, how something is deprecated and removed, and the tests that keep old mo
|
||||
## What counts as a breaking change
|
||||
|
||||
Breaking: removing or renaming anything; changing a type, a default, a unit or a meaning; making something optional
|
||||
required; refusing input that was accepted; a new case in a WIT `enum` or `variant` the game sends to mods (an older
|
||||
component cannot decode it); a JSON field that changes type.
|
||||
required; refusing input that was accepted; any change to a WIT type a function uses, a new `enum` or `variant` case
|
||||
included, in either direction (the runtime links a component only when each imported function's types match exactly:
|
||||
a mod built before the change no longer loads); a JSON field that changes type.
|
||||
|
||||
Not breaking: a new function, interface, capability, command, endpoint, tool or `server.toml` key; a new optional
|
||||
argument or JSON field (readers must ignore fields they don't know); a new WIT case the mod *sends* (the game decodes
|
||||
every case it ever served); faster, or fixing behaviour to what the reference already says.
|
||||
argument or JSON field (readers must ignore fields they don't know); a new WIT function or type (mods built earlier
|
||||
don't import it); faster, or fixing behaviour to what the reference already says.
|
||||
|
||||
## Stability levels
|
||||
|
||||
@@ -86,7 +87,10 @@ Deprecations and breaking changes are in bold. The release notes of the game rel
|
||||
|
||||
| Part | Level | Version |
|
||||
| --- | --- | --- |
|
||||
| Mod API: `log`, `game`, `chat`, `hud`, `storage`, `events` | preview | 0.1.0 |
|
||||
| Mod API: `log`, `game`, `chat`, `hud`, `storage`, `command`, `events` | preview | 0.1.0 |
|
||||
| Mod API: `ui`, `ui-events` (a mod's screens and settings page) | experimental | manifest `experimental = ["ui"]` |
|
||||
| Mod API: `render` (HUD shapes, camera shake and zoom; drawn by the game, no mod shaders) | experimental | manifest `experimental = ["render"]` |
|
||||
| Mod API: `input` (claimed items' use, the mod's keys, the mouse wheel) | experimental | manifest `experimental = ["input"]` |
|
||||
| Content mods (`registries`: data-driven blocks and items) | preview | manifest `api = "0.2"` |
|
||||
| Server mods: world `horizon-server-mod`, `players`, `server-events` | experimental | manifest `api = "0.3"` |
|
||||
| Script mods (Lua run by an interpreter mod, [mods.md](mods.md#ways-in)) | not started | |
|
||||
@@ -101,3 +105,16 @@ Deprecations and breaking changes are in bold. The release notes of the game rel
|
||||
| Telemetry batch and consent | stable | `"schema": 1`, consent `2` |
|
||||
| `horizon-graphics.txt`, `horizon-extras.txt`, `horizon-mods.txt` | preview | none |
|
||||
| `SHA256SUMS` and `SHA256SUMS.sig` | stable | |
|
||||
|
||||
### The experimental mod APIs' choices
|
||||
|
||||
- **What a mod may take from the game.** `input.claim-wheel` is the one input a mod consumes: while it holds the
|
||||
wheel, the steps are its `wheel` events and the hotbar doesn't move. `claim-items` takes the use button only on the
|
||||
items it names. A mod's keys (`register-key`) never consume: vanilla's mapping on the same key still runs. Whether
|
||||
keys may consume too is decided before `input` becomes preview.
|
||||
- **`input`'s `wheel` event** is a new case in a variant the game sends, so it breaks mods built before it (allowed
|
||||
because `input` is experimental): an `input` mod that calls `poll` needs a rebuild against the new WIT.
|
||||
- **`render.set-minimap`** draws a map the game makes, not one a mod composes: reading the blocks around the player
|
||||
for a map image costs too much through hook calls, so the game keeps the tiles (vanilla's map colours) and the mod
|
||||
picks the corner, side, scale and shape. One map shows at a time, the first loaded mod's. It is a new function and a
|
||||
new type, so mods built before it keep loading.
|
||||
|
||||
+18
-40
@@ -1,8 +1,7 @@
|
||||
# Horizon extras
|
||||
|
||||
Optional conveniences built into the client: fullbright, dynamic lights, zoom, a minimap, an FPS counter, a
|
||||
keystroke overlay, auto-reconnect, Mouse Tweaks-style inventory controls and
|
||||
inventory sorting. **Every one is off by default**: a fresh
|
||||
Optional conveniences built into the client: fullbright, dynamic lights, a minimap, auto-reconnect,
|
||||
Mouse Tweaks-style inventory controls and inventory sorting. **Every one is off by default**: a fresh
|
||||
install looks and behaves exactly like vanilla 26.3, and turning an extra off
|
||||
again restores vanilla's behaviour completely.
|
||||
|
||||
@@ -11,9 +10,9 @@ again restores vanilla's behaviour completely.
|
||||
| Part | Code |
|
||||
|---|---|
|
||||
| Settings, parsing and saving | `crates/horizon-client/src/extras.rs` |
|
||||
| Zoom curve, FPS and click counters | `extras.rs` (pure logic, unit tested) |
|
||||
| FPS and click counters (for mods) | `extras.rs` (pure logic, unit tested) |
|
||||
| Dynamic lights: item glow, nearest sources | `crates/horizon-client/src/dynamic_light.rs` (unit tested), `game/dynamic_lights.rs`, `terrain.wgsl` and `entity.wgsl` (`dynamic_block_light`) |
|
||||
| HUD drawing (FPS, keystrokes, minimap frame) | `crates/horizon-client/src/extras_hud.rs` |
|
||||
| HUD drawing (minimap frame, corner stacking) | `crates/horizon-client/src/extras_hud.rs` |
|
||||
| Minimap colours, tiles and image | `crates/horizon-client/src/minimap.rs` |
|
||||
| Reconnect policy and backoff | `crates/horizon-client/src/reconnect.rs` |
|
||||
| Game glue (input hooks, per-frame update) | `crates/horizon-client/src/game/extras.rs` |
|
||||
@@ -35,10 +34,9 @@ extras stay out of the way of other input and options work.
|
||||
`horizon-graphics.txt`. `options.txt` is untouched, so a vanilla client can share
|
||||
the folder. Unknown or broken lines fall back to the defaults.
|
||||
|
||||
The zoom key is a Horizon setting stored in that file (`zoomKey:key.keyboard.z`)
|
||||
and bound on the Extras page, not in vanilla's Key Binds screen: Horizon has no
|
||||
Horizon category in Controls, and adding one would put a non-vanilla mapping into
|
||||
`options.txt`.
|
||||
Extras' keys (the sort key) are Horizon settings stored in that file and bound on
|
||||
the Extras page, not in vanilla's Key Binds screen: Horizon has no Horizon category
|
||||
in Controls, and adding one would put a non-vanilla mapping into `options.txt`.
|
||||
|
||||
## The extras
|
||||
|
||||
@@ -62,36 +60,16 @@ Horizon category in Controls, and adding one would put a non-vanilla mapping int
|
||||
- Off: nothing is gathered and the shaders' loop runs zero times (the count is 0), so it costs
|
||||
nothing measurable (numbers in the pull request, #814).
|
||||
|
||||
### Zoom (`zoom`, default off)
|
||||
- Hold the zoom key (default **Z**, unused by every vanilla 26.3 key mapping; C
|
||||
is `key.saveToolbarActivator`) to zoom. The key does nothing while zoom is off.
|
||||
- It zooms only while playing: in chat, signs, books, text fields and every
|
||||
other screen the key is typed or handled as usual. The key is never taken
|
||||
from vanilla's mappings: one bound to the same key still acts (a key bound
|
||||
twice triggers both, as vanilla's do), and the Extras page marks the zoom key
|
||||
"Also bound" and names the mapping.
|
||||
- Starts at the default level (4x, settable 2x to 10x); the scroll wheel changes
|
||||
it while the key is held (and does not move the hotbar then).
|
||||
- **Smooth** (default on) goes through vanilla's own FOV easing: the zoom divides
|
||||
the field-of-view modifier target `Camera.tickFov` eases toward, the path the
|
||||
spyglass uses (`AbstractClientPlayer.getFieldOfViewModifier` returns 0.1 while
|
||||
scoping). The modifier keeps vanilla's 0.1 floor, so 10x is the deepest zoom.
|
||||
Off applies the zoom to the final FOV with no easing.
|
||||
- While scoping with a spyglass the zoom does nothing: the spyglass view and its
|
||||
overlay stay exactly vanilla's.
|
||||
- **Slower turning** (default on) divides mouse turning by the zoom factor.
|
||||
- With zoom off (or the key up) the FOV target and mouse are vanilla's, bit for
|
||||
bit; the FOV harness covers this.
|
||||
### Moved to the mod browser
|
||||
|
||||
### FPS counter (`fps`, default off)
|
||||
- A small "N fps" line in a corner (default top left), optionally followed by
|
||||
the minimum and the 1% low over the last 5 seconds.
|
||||
- Separate from the Advanced graphics "Overlay" (the frame-time graph).
|
||||
|
||||
### Keystrokes (`keystrokes`, default off)
|
||||
- W A S D, Space, LMB and RMB keys that light up while held, with clicks per
|
||||
second under the mouse buttons (clicks in the last second). The letters follow
|
||||
the bound keys.
|
||||
The **FPS counter**, **Keystrokes** and **Zoom** are official mods now (`mods/official/`, [mods.md](mods.md#horizons-official-mods)),
|
||||
with the same look and options. On the first start after the update, a player who had one on gets the mod installed
|
||||
from Horizon's registry and turned on, with their corner and options carried over (Zoom's key too, into
|
||||
`horizon-mods.txt`, when it wasn't Z), and reads one line in the chat ("Zoom moved to the mod browser: installed for
|
||||
you"). The install is checked like the launcher's (size,
|
||||
SHA-256, signature, manifest); if it fails (offline), the next start tries again. `horizon-extras.txt` keeps the old
|
||||
keys and lists what was done in `movedToMods`. Code: `crates/horizon-client/src/moved_extras.rs`,
|
||||
`game/moved_extras.rs`.
|
||||
|
||||
### Minimap (`minimap`, default off)
|
||||
- A corner map (top right by default), square or round, small/medium/large,
|
||||
@@ -162,11 +140,11 @@ and the container screen tests are unchanged).
|
||||
the world, like vanilla's HUD. Extras in the top left corner give way to the
|
||||
debug screen (F3), which shows the FPS anyway.
|
||||
- Corners stack: extras placed in the same corner stack downward (top corners)
|
||||
or upward (bottom corners) in the order minimap, FPS, keystrokes. The top
|
||||
or upward (bottom corners) in the order minimap, then mods' panels. The top
|
||||
right corner starts below the status effect icons.
|
||||
|
||||
## Perf budget
|
||||
|
||||
Off: a flag check per frame per extra (no allocations, no world access).
|
||||
On: FPS and keystrokes are a few quads; the minimap stays under 0.3 ms of CPU
|
||||
On: the minimap stays under 0.3 ms of CPU
|
||||
per frame (tile budget) plus a 64 KiB texture upload when its image changes.
|
||||
|
||||
@@ -94,7 +94,7 @@ Every command `horizon-ctl` takes, its MCP tool in `horizon-ctl mcp` (the launch
|
||||
| `respawn` | `respawn` | Respawn from the death screen | none |
|
||||
| `pause` | `pause` | Open the pause menu | none |
|
||||
| `resume` | `resume` | Leave the pause menu | none |
|
||||
| `options [PAGE]` | `options` | Open the options screen, or one of its pages (Horizon's too) | `page` (main, video, sound, controls, keybinds, controller, controller-binds, mouse, chat, accessibility, language, font, packs, mods, graphics, graphics-advanced, extras, horizon, agent): the page (default: the main options) |
|
||||
| `options [PAGE]` | `options` | Open the options screen, or one of its pages (Horizon's too) | `page` (main, video, sound, controls, keybinds, controller, controller-binds, mouse, chat, accessibility, language, font, packs, mods, shader-packs, graphics, graphics-advanced, extras, horizon, agent): the page (default: the main options) |
|
||||
| `book [next\|back\|take\|done]` | `book` | The open book or lectern: its page text, or press one of its buttons | `action` (next, back, take, done): a button to press |
|
||||
| `signedit X Y Z [front\|back]` | `signedit` | Open the sign editor of the sign at X Y Z (then type and close) | `x` (integer, required): block X<br>`y` (integer, required): block Y<br>`z` (integer, required): block Z<br>`side` (front, back): which side |
|
||||
| `mount-menu` | `mount_menu` | Open the inventory of the horse, donkey, mule or llama being ridden | none |
|
||||
|
||||
+4
-1
@@ -71,7 +71,7 @@ from there too.
|
||||
## 2. Prepare the game files
|
||||
|
||||
Horizon reads Minecraft's data from your own copy of the game. You need Minecraft Java Edition 26.3, played
|
||||
once from the official launcher on this computer, Java 25 (a JDK), and the 26.3 `server.jar`: it's the
|
||||
once from the official launcher on this computer, a Java 25 runtime, and the 26.3 `server.jar`: it's the
|
||||
`downloads.server.url` in your launcher's `versions/26.3/26.3.json`. Then:
|
||||
|
||||
```sh
|
||||
@@ -218,6 +218,9 @@ horizon-server rollback back to the release before
|
||||
While the server runs, `op`, `whitelist` and `cmd` go to the game's console, so they act exactly as vanilla's
|
||||
console commands do. While it's stopped, they edit vanilla's files directly. Any console command works through
|
||||
`cmd`: `horizon-server cmd ban Griefer`, `horizon-server cmd say Restarting in 5 minutes`.
|
||||
To generate the world around spawn ahead of the players, Horizon has its own `pregen` command, off until
|
||||
`server.toml` has `horizon-pregen = true` under `[properties]`: `horizon-server cmd pregen start 2500`
|
||||
([pregeneration](pregeneration.md)).
|
||||
|
||||
`config set` changes `server.toml` without opening it: `horizon-server config set world.difficulty=hard
|
||||
server.max_players=10`. Each key is a section and a name from the file (`properties.spawn-protection=0` for any
|
||||
|
||||
@@ -323,7 +323,7 @@ Search for packs Horizon loads.
|
||||
- `TEXT`
|
||||
- `--kind` (mod, resource, modpack)
|
||||
- `--everything`: Also what was made for other versions or runs only partly, each marked
|
||||
- `--source` (modrinth, curseforge)
|
||||
- `--source` (modrinth, curseforge, horizon)
|
||||
|
||||
MCP: `mods_search`.
|
||||
|
||||
@@ -335,7 +335,7 @@ Say how well a Java mod runs in Horizon: its jar is downloaded (checksum checked
|
||||
|
||||
- `PROJECT`
|
||||
- `--everything`: Allow a version made for another Minecraft version (1.21 and later)
|
||||
- `--source` (modrinth, curseforge)
|
||||
- `--source` (modrinth, curseforge, horizon)
|
||||
|
||||
MCP: `mods_check`.
|
||||
|
||||
@@ -347,7 +347,7 @@ Install a pack and what it needs, by its id or slug (checksums checked); a Java
|
||||
|
||||
- `PROJECT`
|
||||
- `--everything`: Allow a version made for another Minecraft version
|
||||
- `--source` (modrinth, curseforge)
|
||||
- `--source` (modrinth, curseforge, horizon)
|
||||
|
||||
MCP: `mods_install`.
|
||||
|
||||
@@ -372,6 +372,26 @@ Remove a pack the browser installed.
|
||||
|
||||
MCP: `mods_remove`, needs `confirm: true`.
|
||||
|
||||
## `horizon-launcher mods enable`
|
||||
|
||||
Turn on a mod the browser installed (horizon-mods.txt, as the game's Options > Mods does).
|
||||
|
||||
horizon-launcher mods enable <PROJECT>
|
||||
|
||||
- `PROJECT`
|
||||
|
||||
MCP: `mods_enable`.
|
||||
|
||||
## `horizon-launcher mods disable`
|
||||
|
||||
Turn off a mod the browser installed; it stays installed.
|
||||
|
||||
horizon-launcher mods disable <PROJECT>
|
||||
|
||||
- `PROJECT`
|
||||
|
||||
MCP: `mods_disable`.
|
||||
|
||||
## `horizon-launcher servers list`
|
||||
|
||||
The servers, their folder and whether they run.
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# Launcher resource preparation
|
||||
|
||||
Release folders include `exporters/server`, `exporters/client` and an integrity manifest.
|
||||
These contain only Horizon's original Java exporter classes. Minecraft jars, libraries,
|
||||
assets and generated resources remain local and are verified against `research-lock.json`.
|
||||
The same platform-independent class bundle is used in game and dedicated-server releases.
|
||||
|
||||
The release runner compiles the server and client source sets separately with
|
||||
`javac --release <pinned major> -proc:none -encoding UTF-8`, resolving shared helpers once
|
||||
per classpath. It checks every class and its signatures with `-Xverify:all` against the
|
||||
pinned jars. The release job also compares two fresh isolated preparations with a fresh
|
||||
batched preparation using a runtime-only Java home:
|
||||
|
||||
```sh
|
||||
cargo build --release -p horizon-prepare
|
||||
# Requires already imported Minecraft files in .local/minecraft/<version>.
|
||||
target/release/horizon-prepare compile-exporters
|
||||
# Copy server/, client/ and manifest.json from the printed folder into exporters/.
|
||||
python3 tools/check_prepare_exporters.py --binary target/release/horizon-prepare
|
||||
```
|
||||
|
||||
Development checkouts and changed sources compile on demand, into
|
||||
`.local/exporters/<sha256>`. The key covers Java sources (including implicit helpers),
|
||||
pinned dependency checksums and compiler settings. Class checksums detect missing or damaged
|
||||
outputs. Compilation happens in a private staging folder before publishing a complete cache
|
||||
entry. Sources and paths are normalized so one release bundle works on all three platforms.
|
||||
|
||||
Compatible exporters run sequentially through one server JVM and one client JVM. Both keep
|
||||
Minecraft's initialized built-in registries. Every task restores the original registry tags
|
||||
before replying; failures stop preparation. Collision exports share the first generated
|
||||
registry and collision files, encoded block states and shape grids within the server worker.
|
||||
Ordinary parity oracle processes keep their existing behavior.
|
||||
|
||||
Command-registry and creative-tab exporters remain separate processes: they install data
|
||||
components as well as tags. The data generator also remains separate. Inspection of pinned
|
||||
`net.minecraft.data.Main.main` showed that it calls `Util.shutdownExecutors` after running
|
||||
its providers. Calling it inside a worker would shut down shared executors; incorporating
|
||||
its providers directly needs a separate comparison of registry and executor lifetimes.
|
||||
Fresh release preparation therefore starts five exporter/data-generator JVMs, down from 18,
|
||||
and invokes no compiler. `HORIZON_PREPARE_ISOLATED=1` retains separate exporter JVMs for
|
||||
output comparisons and diagnosis.
|
||||
|
||||
`tools/check_prepare_exporters.py` requires identical resource file sets and identical bytes
|
||||
for every file stable across the two isolated runs. For the three known noisy JSON files,
|
||||
it also requires semantic equality after normalizing object key order, opaque JVM lambda
|
||||
addresses and creative-tab tag set order. Other variation fails the release check.
|
||||
|
||||
On Linux with Java 25, the output comparisons used 23,204 resource files per run.
|
||||
All runs used precompiled exporters:
|
||||
|
||||
| Comparison | Isolated A | Isolated B | Batched |
|
||||
|---|---:|---:|---:|
|
||||
| Initial | 178.95 s | 104.25 s | 45.05 s |
|
||||
| Repeat | 100.03 s | 176.06 s | 120.09 s |
|
||||
| Final, immutable collision cache | 133.80 s | 123.79 s | 56.19 s |
|
||||
|
||||
These use fresh output directories with a warm OS file cache, on a machine with other
|
||||
workloads. The first two rows include output hashing; the final row measures preparation
|
||||
before comparison. The variability prevents treating these as a controlled speedup estimate.
|
||||
The compiler saving is separate: release preparation removes the previously measured
|
||||
15 compiler invocations (29–52 s).
|
||||
@@ -149,6 +149,32 @@ horizon-launcher mods remove faithful-32x
|
||||
|
||||
## Sources
|
||||
|
||||
**Horizon's registry.** Mods (`.hmod`) and resource packs made for Horizon, reviewed as pull requests in
|
||||
[ludovic111/horizon-mods](https://github.com/ludovic111/horizon-mods) ([api/mod-index.md](api/mod-index.md)). The
|
||||
launcher reads its `index.json` (`browser/horizon.rs`; `HORIZON_MOD_INDEX=<file or https address>` reads a test
|
||||
registry instead, whose files may then be on disk) at most every ten minutes, and keeps the last copy in
|
||||
`mod-browser/horizon-index.json`. Before a result is installed it shows whether its files are signed and, for a mod,
|
||||
what it may do, in the words of the game's Options > Mods. A download goes to `mod-browser/downloads/` and is moved
|
||||
into place only after `horizon_mods::index::check_file` passes (size, SHA-256, the author's signature when the project
|
||||
has a key, the file's own manifest against the index). A mod becomes `horizon-mods/<id>.hmod`, turned on;
|
||||
`mods disable` and `mods enable` switch it in `horizon-mods.txt`. When the index takes a file down, the launcher turns
|
||||
it off the next time it reads the index or starts the game, says why, and refuses to install it or turn it back on.
|
||||
A Horizon modpack (`.hpack`) installs as its own profile (`browser/horizon/pack.rs`): `horizon-packs/<id>/` holds the
|
||||
checked pack, `pack.json` and `home/`, the profile's game folder, where each of the pack's mods is downloaded and checked
|
||||
like any registry mod and turned on or off as the pack says; its overrides (settings, resource packs, a mod's saved
|
||||
settings) are copied in on the first install only, so the player's changes survive updates. A pack whose mod was taken
|
||||
down installs nothing. It is listed on the Modpacks tab with **Play** and **Remove**, and plays like an imported pack
|
||||
(`modpacks::apply_profile`). Shader packs are listed by the index but not installed by this launcher yet.
|
||||
|
||||
```sh
|
||||
horizon-launcher mods search --source horizon --kind mod coords # with whether it is signed and what it may do
|
||||
horizon-launcher mods install --source horizon coords_hud
|
||||
horizon-launcher mods disable coords_hud
|
||||
horizon-launcher mods install --source horizon cozy # a modpack: its own profile
|
||||
horizon-launcher modpack play cozy
|
||||
```
|
||||
|
||||
|
||||
**Modrinth.** The public API (`api.modrinth.com/v2`) needs no key. The launcher names itself in its user agent, as
|
||||
Modrinth asks.
|
||||
|
||||
|
||||
+70
-19
@@ -12,11 +12,12 @@ folder, loads no runtime and plays exactly like vanilla 26.3.
|
||||
|
||||
| Part | Where | State |
|
||||
|---|---|---|
|
||||
| The contract (WIT) | `crates/horizon-mod-sdk/wit/horizon.wit` | 0.1: log, game-read, chat, hud, storage; tick, frame, chat and command hooks |
|
||||
| The contract (WIT) | `crates/horizon-mod-sdk/wit/horizon.wit` | 0.1: log, game-read, chat, hud, storage, command, ui; tick, frame, chat and command hooks |
|
||||
| SDK for mod authors | `crates/horizon-mod-sdk` | 0.1 |
|
||||
| Example mod | `crates/horizon-mod-sdk/examples/coords-hud` | coordinates, facing and time HUD, `/where`, `/coords` |
|
||||
| Runtime | `crates/horizon-mods` | wasmtime 36 LTS, component model |
|
||||
| Authoring tool | `crates/cargo-horizon-mod` | `cargo horizon-mod new / build / run / test / check`, and the registry's CI (`registry build / review / list`) |
|
||||
| Example mods | `crates/horizon-mod-sdk/examples/coords-hud`, `examples/predator-missile` | coordinates, facing and time HUD, `/where`, `/coords`; `/missile`, a guided missile from vanilla commands |
|
||||
| Horizon's official mods | `mods/official/` | the extras moving to the registry: FPS Counter (`fps-overlay`), Keystrokes, Zoom, Minimap |
|
||||
| Runtime | `crates/horizon-mods` | wasmtime 48 LTS, component model |
|
||||
| Authoring tool | `crates/cargo-horizon-mod` | `cargo horizon-mod new [--template code\|content] / build / run / test / check`, and the registry's CI (`registry build / review / list`) |
|
||||
| In the game | `crates/horizon-client/src/game/mods.rs`, Options > Mods | client mods |
|
||||
| Launcher mod browser (Modrinth, CurseForge with a key) | [mod-browser.md](mod-browser.md) | resource packs, modpacks |
|
||||
| Registry index (`index.json`, `.hpack`), signatures | `horizon_mods::index`, [api/mod-index.md](api/mod-index.md) | schema 1; launcher and website next |
|
||||
@@ -86,6 +87,10 @@ folder, loads no runtime and plays exactly like vanilla 26.3.
|
||||
| `chat` | `chat` | `show(text)`: a line only the local player sees, after the mod's name (8 per call) |
|
||||
| `hud` | `hud` | `set-panel(corner, lines)`, `clear()`: up to 16 lines of 256 characters |
|
||||
| `storage` | `storage` | `get(key)`, `set(key, value)`, `delete(key)`: a per-mod folder of up to 64 files, 4 MiB total, at most 1 MiB written per call |
|
||||
| `command` | `command` | `run(line)`: a vanilla command run as the player, with the player's permissions, after the hook returns (8 per call); mods' own commands are not run |
|
||||
| `ui` | `ui` | `open-screen`, `close-screen`, `set-settings`: a screen the mod owns and a page in Options > Mods, of text, button, item and list widgets the game lays out and draws with its own menus' code. **Experimental:** the manifest needs `experimental = ["ui"]` |
|
||||
| `render` | `render` | `set-hud(shapes)`: up to 1024 fills, four-cornered shapes, GUI sprites, items and text, kept on the HUD (over the hotbar, under chat and screens, hidden with F1) until replaced; `set-corner(corner, w, h, shapes)`: a box the game places in a corner, stacked with its overlays and other panels, as `hud`'s panels are; `text-width(text)`; `frame-stats()`: the game's FPS, min and 1% low; `gui-size()`; `shake(strength, seconds)`: the view turns, the player doesn't, scaled by Distortion Effects; `set-zoom(zoom)`: the field of view divided by up to 10, eased or at once, with slower turning, while playing and not through a spyglass (the strongest of several mods' zooms counts); `set-minimap(minimap)`: a map of the world around the player in a corner, as a map item colours it (the floor underground and under roofs), square or round, turning with the player or north up, with the player's arrow; the game keeps its tiles within its own frame budget (one map at a time, the first loaded mod's). The game's own HUD renderer draws them: a mod never supplies shader code. **Experimental:** `experimental = ["render"]` |
|
||||
| `input` | `input` | `claim-items(ids)`: the use button on those items is the mod's (`use-start`, `use-stop` with the ticks held; the game doesn't place, eat or swing); `register-key(name, label, key)`: up to 16 keys (`key.keyboard.r`), heard while playing as `key-down` / `key-up` (the game's own mapping on that key still runs; a screen opening lets held keys up), mouse buttons as `key.mouse.4`. The player rebinds them on the mod's page in Options > Mods, where the game lists them first as Key Binds rows (click, then press a key or mouse button; Esc binds none), even for a mod without `ui`; the choice is kept in `horizon-mods.txt` (`key.<mod>.<name>:key.keyboard.z`) and wins over `register-key`'s default; `claim-wheel(on)`: the wheel's steps become `wheel` events and the hotbar doesn't move (the one input a mod takes from the game; a mod's keys never do); `held()`; `mapping(name)`: a movement or click mapping's key label and whether it is held; `clicks-per-second()`; `poll()` returns the events, at most 256 kept. **Experimental:** `experimental = ["input"]` |
|
||||
|
||||
| Hook (export) | When |
|
||||
|---|---|
|
||||
@@ -112,9 +117,8 @@ loading. Ordered by what the first native ports need:
|
||||
| `target` | the crosshair's block or entity, with its state and NBT summary | Jade/WTHIT-style tooltips |
|
||||
| `inventory-read` | the player's inventory, held item, open container | AppleSkin, recipe viewers |
|
||||
| `recipes` | the recipe registry and lookups | JEI/EMI-style viewers |
|
||||
| `ui` | widgets: text, item icons, lists, a screen the mod owns, a settings page in Options > Mods | built from vanilla's widgets (`ui`) so it matches the menus |
|
||||
| `world-read` | blocks and biomes around the player, within the render distance | minimaps, schematics |
|
||||
| `render` | world-space lines, boxes and ghost blocks in a per-frame budget | Litematica-style placement, waypoints |
|
||||
| `render` (world) | world-space lines, boxes and billboards, beside the HUD shapes `render` has | Litematica-style placement, waypoints |
|
||||
| `registries` | new blocks, items, entities and recipes, mostly data: JSON models, textures, loot and recipes in the `.hmod`'s `assets/` and `data/` | server side; see [Multiplayer](#multiplayer) |
|
||||
| `server` | world events (entity spawn/death), game rules, world read/write, typed server commands | after [server mods 0.3](#server-mods-api-03-experimental)'s players, chat, blocks and commands |
|
||||
| `net` | a mod's own client↔server channel (custom payloads) | only between the two halves of the same mod |
|
||||
@@ -132,8 +136,10 @@ There is no file, socket, process or raw-input interface, on purpose.
|
||||
| native `cdylib` plugins | none | no: per OS and arch, unstable Rust ABI | yes | none | unsafe for players |
|
||||
| an embedded JVM | none per mod | yes | Java | 100+ MB, seconds of startup | see the research |
|
||||
|
||||
wasmtime 36 is a long-term-support line (security fixes until August 2027)
|
||||
that builds on the client's Rust 1.90. Only its `runtime`, `cranelift`,
|
||||
wasmtime 48 is a long-term-support line (security fixes until August 2028)
|
||||
and needs Rust 1.95. It reads WebAssembly with the same wasm-tools release
|
||||
(0.254) as the `wit-component` that packs mods and the SDK's `wit-bindgen`, so
|
||||
the build carries one copy of them. Only its `runtime`, `cranelift`,
|
||||
`component-model` and `std` features are on: no WASI, no async, no GC
|
||||
proposal, no profiling. Its cranelift backend generates native code for x86-64
|
||||
and ARM64 on Windows, macOS and Linux, which is why one `.hmod` serves them
|
||||
@@ -215,6 +221,7 @@ Benchmarks (`--benchmark`) never load mods.
|
||||
rustup target add wasm32-unknown-unknown
|
||||
cargo install --git https://github.com/ludovic111/horizon cargo-horizon-mod
|
||||
cargo horizon-mod new my-mod # Cargo.toml, horizon-mod.toml, src/lib.rs, tests/hello.toml
|
||||
# (--template content: a content mod, no code)
|
||||
cd my-mod
|
||||
cargo horizon-mod run # build, then start the game with it
|
||||
cargo horizon-mod build # again after an edit: the running game reloads it
|
||||
@@ -357,15 +364,21 @@ authors = ["..."]
|
||||
api = "0.1" # the API the SDK targets
|
||||
side = "client" # client | server | both
|
||||
capabilities = ["game-read", "hud", "chat"]
|
||||
experimental = [] # experimental capabilities it uses, e.g. ["ui"]
|
||||
```
|
||||
|
||||
Unknown keys are refused, so a typo is an error, not a silently ignored
|
||||
permission.
|
||||
permission. An experimental capability (today `ui`, `render` and `input`) may change in any release
|
||||
([stability](api/stability.md)): a mod uses it only by naming it in
|
||||
`experimental` as well, so nobody depends on it by accident.
|
||||
|
||||
### Content mods (API 0.2)
|
||||
|
||||
A mod with `api = "0.2"` and capability `registries` may carry `assets/` and
|
||||
`data/` in the `.hmod`, and needs no `mod.wasm` if it has no code. It adds
|
||||
`data/` in the `.hmod`, and needs no `mod.wasm` if it has no code
|
||||
(`cargo horizon-mod new --template content` starts one; `build` in a folder
|
||||
with no `Cargo.toml` packs the manifest, `assets/` and `data/`, and `check`
|
||||
reads it without a trial run). It adds
|
||||
blocks and items by declaring them in `data/<id>/horizon/block/*.json` and
|
||||
`data/<id>/horizon/item/*.json`, each copying a vanilla template
|
||||
([modpacks.md](modpacks.md#registries-02-data-driven-blocks-and-items)):
|
||||
@@ -435,14 +448,14 @@ A pool addition holds `"elements"` as a pool does. This is what lithostitched's
|
||||
NeoForge and Fabric, and `horizon-port-pack carry` writes them from those.
|
||||
|
||||
A structure (and any of its pool elements, in place of the structure's) may
|
||||
hold `horizon:enhanced_terrain_adaptation`: YUNG's API's and
|
||||
MoogsStructureLib's terrain kernel, which carves or buries terrain around the
|
||||
hold `horizon:enhanced_terrain_adaptation`: MoogsStructureLib's terrain
|
||||
kernel, which carves or buries terrain around the
|
||||
pieces on top of vanilla's `terrain_adaptation`. `kernel_size` and
|
||||
`kernel_distance` shape the kernel; `top` and `bottom` (`carve`, `bury` or
|
||||
`none`) act above and below a piece's floor; `bottom_offset`, `padding`
|
||||
(`x`, `top`, `bottom`, `z`) and MoogsStructureLib's `band` (`bottom`, `top`,
|
||||
`piece_heights`) move the box it measures from. On a structure,
|
||||
`rigid_junctions` (YUNG's API) adds rigid pieces' junctions as well and
|
||||
`rigid_junctions` adds rigid pieces' junctions as well and
|
||||
`inflate` grows the start's box by the kernel radius. `kernel_size` 0 is
|
||||
none.
|
||||
|
||||
@@ -483,6 +496,46 @@ runtime, the registry's `check` and the SDK run them today; the game starts
|
||||
them once its server code calls these hooks (the next step), and until then a
|
||||
server mod that is turned on shows as run elsewhere.
|
||||
|
||||
## Publish your mod
|
||||
|
||||
Horizon's registry lists mods, modpacks (`.hpack`) and resource packs made for Horizon, each reviewed before it is
|
||||
published. Players find them at [playhorizon.dev/mods](https://playhorizon.dev/mods) and in the launcher (Mods, then
|
||||
**Horizon** beside Modrinth), which checks every file before it installs it.
|
||||
|
||||
1. Run `cargo horizon-mod check` on the file (above): the registry runs the same checks.
|
||||
2. Put the source somewhere public, under a licence that lets players run it: reviewers read it, and the file must be
|
||||
built from it.
|
||||
3. Open [playhorizon.dev/mods/submit](https://playhorizon.dev/mods/submit), sign in with GitHub (it reads only your
|
||||
public profile) and fill in the page: the file, its name and summary, licence, source address, and optionally a
|
||||
minisign public key with the file's `.minisig`.
|
||||
4. The form checks the file again and opens a pull request in
|
||||
[ludovic111/horizon-mods](https://github.com/ludovic111/horizon-mods) that adds `mods/<id>.toml`, with you as its
|
||||
owner. That repository's checks run the file in the sandbox and post their report on the pull request; answer the
|
||||
reviewers there.
|
||||
5. A reviewer merges it: within minutes the file is a release of horizon-mods, and the project is on the site and in
|
||||
the launcher.
|
||||
|
||||
An update is the same form with a new version; only the project's `owners` can publish one, signed with its key if it
|
||||
has one. A published file never changes. Without the form, open the pull request by hand (the repository's README
|
||||
says how). The formats: [api/mod-index.md](api/mod-index.md).
|
||||
|
||||
### Horizon's official mods
|
||||
|
||||
The Horizon extras that are mods now live in `mods/official/<name>/`, one crate each in the game's workspace, so
|
||||
`cargo clippy --workspace` and pr_ready cover them. They use only the public API, like any other mod, with the same
|
||||
options on their settings page as the extra had and the same look. Each is published by a maintainer: build it on
|
||||
`main` with the toolchain CI uses (`cd mods/official/<name> && cargo horizon-mod build`), then open a pull request in
|
||||
horizon-mods with its `mods/<id>.toml` (owners `ludovic111`, `source` pointing at the folder) and the file's
|
||||
SHA-256. The reviewer builds it the same way and merges only when the hashes match: the `.wasm` holds no local paths,
|
||||
so the same rustc and `Cargo.lock` give the same file.
|
||||
|
||||
| Mod | Id | Replaces | Settings (storage key: values) |
|
||||
|---|---|---|---|
|
||||
| FPS Counter | `fps_overlay` | Extras > FPS counter | `corner`: `top_left` (default), `top_right`, `bottom_left`, `bottom_right`; `lows`: `false` (default), `true` |
|
||||
| Keystrokes | `keystrokes` | Extras > Keystrokes | `corner`: as above, default `top_left`; `cps`: `true` (default), `false` |
|
||||
| Zoom | `zoom` | Extras > Zoom | `level`: `2`, `3`, `4` (default), `6`, `8`, `10`; `smooth`: `true` (default), `false`; `sensitivity` (slower turning): `true` (default), `false`. The key is the game's: `key.zoom.zoom` in `horizon-mods.txt`, default `key.keyboard.z` |
|
||||
| Minimap | `minimap` | Extras > Minimap | `corner`: as above, default `top_right`; `size`: `64`, `96` (default), `128`; `shape`: `square` (default), `round`; `zoom` (blocks per pixel): `0.5`, `1` (default), `2`, `4`; `rotate`: `false` (default), `true`. The game draws the map (`render.set-minimap`) |
|
||||
|
||||
## Versions and compatibility
|
||||
|
||||
- The API is the WIT package `horizon:mods@0.1.0`. New functions and
|
||||
@@ -525,12 +578,10 @@ server mod that is turned on shows as run elsewhere.
|
||||
format: a `.hmod.minisig` beside it); the index pins each project's public
|
||||
key, so an update signed by another key is refused. Unsigned local files
|
||||
stay allowed, with an "unsigned" mark on the Mods page.
|
||||
- **Where mods come from.** Modrinth is where players already look and it
|
||||
stores files with hashes, but its loader list is Modrinth's to extend: we ask
|
||||
Modrinth to add a `horizon` loader. Until then (and as a fallback), the
|
||||
launcher reads a small index of approved mods: a JSON file in a public Git
|
||||
repository (id, versions, file URLs as GitHub release assets, SHA-256,
|
||||
signing key). No server of our own is needed.
|
||||
- **Where mods come from.** Horizon's registry ([Publish your mod](#publish-your-mod)): reviewed pull requests in
|
||||
[ludovic111/horizon-mods](https://github.com/ludovic111/horizon-mods), files as its release assets, and an
|
||||
`index.json` on GitHub Pages that the launcher and the website read. A file the registry takes down
|
||||
(`revoked.toml`) is refused by the launcher and turned off where installed.
|
||||
- **The launcher.** A Mods tab per installation: browse and search the index,
|
||||
install, update, turn on and off (it writes the same `horizon-mods.txt`),
|
||||
see capabilities before installing. The launcher's CLI and MCP tools gain
|
||||
|
||||
+35
-1
@@ -20,6 +20,8 @@ python3 tools/parity.py --changed origin/main # those a branch's changes ca
|
||||
python3 tools/parity.py --changed-files paths.txt # the same for listed paths, in a copy without Git (tools/pr_ready.py)
|
||||
```
|
||||
|
||||
On CI, a pull request runs the parity job only when it changes a harness, an oracle, a probe or the runner; everything else is checked on main by `parity-main`, a batch of merges at a time, which bisects a failure to the merge that caused it (`tools/parity_main.py`; [release-flow.md](release-flow.md#parity-on-main)). Game releases wait for it.
|
||||
|
||||
Each harness runs unmodified under a tracer that records the files it depended on: its Python modules, its Java oracle and the oracle sources javac pulled in, other repository files it read, and the Rust sources of the probes it ran (from Cargo's `.d` dep-info files). A pass stands until one of those files, the pinned vanilla artifacts, `Cargo.lock` or the Rust/Java toolchains change. State and logs are in `.local/parity-runner/`; each harness's own outputs stay in its `.local/<name>/` directory.
|
||||
|
||||
Vanilla oracle runs are reused as well. `tools/parity_shim.py` stands in for `java` and `javac`: it records each oracle run's outputs and the content of every file under the paths its arguments name, and replays the run while those are unchanged. After a Rust-only change a harness pays only for its Rust side (`block_update`: 53 s to 5 s). Files an oracle writes outside its named paths aren't tracked, so a harness that fails while reusing oracle results is rerun fresh, and stops reusing them if it then passes. `--all` and `--fresh` never reuse them.
|
||||
@@ -38,7 +40,7 @@ The game logs into `HORIZON_HOME` and falls back to the player's own game folder
|
||||
|
||||
### Other machines
|
||||
|
||||
Harnesses can also run on the Mac mini and the ThinkPad (`tools/parity_hosts.json` describes them; its `default` list is empty, so pass `--hosts macmini,thinkpad` or set `PARITY_HOSTS`, after copying `shared-local/` to `~/code/horizon-parity/shared-local` on each host). The runner mirrors the worktree there with rsync (not `.git`, `.local`, `target` or ignored files) into `~/code/horizon-parity/remote/<host><path>`, whose `.local` links to the vanilla data in `~/code/horizon-parity/shared-local`, and starts `tools/parity.py --worker` over ssh. The worker builds the probes (about 80 s the first time) and runs what it is sent under the same tracer, admitting harnesses against its own free memory. One queue, longest first, feeds every machine, remote ones first: the Mac takes up to 14 harnesses, the desktop 3 and only those under 800 MB. Each pass comes back with the content hash of every file it depended on, so it is keyed on exactly what ran, and logs come back to `.local/parity-runner/logs/`; state, sharing and `gate.py` work as before. If a host can't be reached, or drops out, its harnesses run here.
|
||||
Harnesses can also run on the Mac mini, the ThinkPad and the desktop (`tools/parity_hosts.json` describes them; `desktop` uses its CI runner's environment and vanilla data, and refuses work, or stops it, while someone uses it: docs/release-flow.md, "The desktop's runner"; its `default` list is empty, so pass `--hosts macmini,thinkpad` or set `PARITY_HOSTS`, after copying `shared-local/` to `~/code/horizon-parity/shared-local` on each host). The runner mirrors the worktree there with rsync (not `.git`, `.local`, `target` or ignored files) into `~/code/horizon-parity/remote/<host><path>`, whose `.local` links to the vanilla data in `~/code/horizon-parity/shared-local`, and starts `tools/parity.py --worker` over ssh. The worker builds the probes (about 80 s the first time) and runs what it is sent under the same tracer, admitting harnesses against its own free memory. One queue, longest first, feeds every machine, remote ones first: the Mac takes up to 14 harnesses, the desktop 8. Each pass comes back with the content hash of every file it depended on, so it is keyed on exactly what ran, and logs come back to `.local/parity-runner/logs/`; state, sharing and `gate.py` work as before. If a host can't be reached, or drops out, its harnesses run here.
|
||||
|
||||
Harnesses a host can't run are listed in the file: `local_only` (`save_roundtrip` runs the game on a virtual screen) and each host's `exclude`. The Mac excludes nothing: vanilla's `Math.sin`, `pow`, `log` and the like don't round the same on an Apple silicon Mac as on Linux (HotSpot uses fdlibm there, Intel's stubs on x86-64), and Rust's float functions round like neither (they call the platform libm), so code that mirrors a vanilla `Math` call uses `horizon_core::jmath`, which computes what HotSpot computes on the host architecture. The ThinkPad helps too, gently: Linux, 2 harnesses at `nice 19`, since it hosts the Claude account pool; it finds ALSA through `~/code/horizon-parity/alsa-dev` like the desktop.
|
||||
|
||||
@@ -49,6 +51,10 @@ A harness can declare, at the top level of its script:
|
||||
- `PARITY_SHARDS = N`: it runs as `NAME#1` to `NAME#N`, in parallel, each told its share in `PARITY_SHARD=i/N` (`test_datafix_parity.py` upgrades every sixth world). `NAME` on the command line or in `--known-failures` means all of them.
|
||||
- `PARITY_RUST_SCOPE = [...]`: the Rust sources its probes can reach, as path prefixes. Cargo's dep-info names every file of every crate a probe links, so without it a probe of `horizon-world` depends on all 350 of its files. The runner keeps only the scope's files if the scope is closed: nothing in it names a module, crate-root re-export or macro outside it (`crate::`, `super::`, other workspace crates; comments and strings ignored), declares a module it doesn't cover, or includes source, and nothing outside it implements anything for a type it defines. Crate roots then count without their declarations of other modules, so adding a module elsewhere doesn't rerun the harness. If the scope isn't closed the runner says why and keeps every file. `datafix` depends on 41 files this way, not 354.
|
||||
|
||||
### Which harnesses a change affects
|
||||
|
||||
`--changed` and `--changed-files` narrow each harness's Rust sources to those its probes can reach (`tools/parity_reach.py`), so a change to one module of `horizon-client` no longer reruns every harness whose probe links the crate. The narrowing works on items, not files: from the probe modules a harness ran (or the binary it built), a free item (fn, type, const, static) is reached when a reached item names it in its own module, through a path or an import of a module that is named, or through a glob import; an inherent impl's methods count one by one once their type is reached and their name is mentioned; a trait impl counts once its trait and its type are reached (std's traits and types always are); a macro counts once invoked. Names match by spelling, so the result only over-approximates. A reached file's parent modules count through their `mod` declarations of it, compared with the merge base; Rust files a change adds take part, a dependency that was deleted counts as changed, code under `#[cfg(test)]` never counts, and a harness whose probe can't be found keeps every source. Parses are cached by content in `reach-cache.json` of the shared parity folder (beside `passes/`), so a new worktree starts warm; a harness's search stops as soon as it reaches a changed file, and after `PARITY_REACH_BUDGET` seconds (default 180) the remaining harnesses count every source their probes link, so choosing never holds a slow machine for long. `--by-crate` turns the narrowing off. On the last 20 pull requests merged on 2026-10-25, the harnesses picked went from 2255 to 1061 (2384 to 1592 harness-minutes; game-binary harnesses, which link all of `game/`, set the floor), and every harness a CI parity run failed in the week before was still picked; every source file a sample of probes executed (LLVM `-C instrument-coverage`) is among those kept. Building the graph takes 15 s cold, under a second warm, and up to a minute and a half on a change that reaches many harnesses.
|
||||
|
||||
## The gate
|
||||
|
||||
`tools/gate.py` is what a branch must pass before it is integrated: the public-tree check, rustfmt, clippy with warnings denied, the Rust and Python tests, then the harnesses whose inputs changed. It stops at the first failure and writes `.local/gate.json`. `--known-failures a,b` lets harnesses that already fail on the integration branch keep failing. `--quick` checks formatting, lints and Python tests only; `--no-parity` skips the harnesses.
|
||||
@@ -74,6 +80,34 @@ An agent working an area merges the integration branch first, uses `tools/parity
|
||||
|
||||
On ludodesktop, source `~/code/horizon-parity/env.sh` first: it sets the ALSA build path and the Cargo job cap. Debug builds carry line tables only (`[profile.dev]` in `Cargo.toml`), which keeps backtraces readable while keeping each worktree's build small; a fresh worktree builds `horizon-client` and its tests in under a minute.
|
||||
|
||||
## Server execution in game fixtures
|
||||
|
||||
`HORIZON_COMMAND_SCRIPT` runs on the integrated server's `Server thread`, with the
|
||||
headless client joined through the normal memory connection. Commands use the connected
|
||||
owner's body and dimension. The script owns the clock: each `tick` calls `tick_server`,
|
||||
while login and portal arrival pump connection-only passes. The client acknowledges
|
||||
terrain and teleports without predicting movement, matching the command oracle's stationary
|
||||
player. Script and save errors return through server shutdown; output keeps the existing
|
||||
styled messages and `CommandResultCallback` schema. `--in-frame` is not needed.
|
||||
|
||||
`HORIZON_DISPENSE_FIXTURE` and `HORIZON_SCULK_FIXTURE` are component probes. They construct
|
||||
a server `Game` on a server thread and retain the oracles' synthetic levels, seeded random
|
||||
streams and explicit entity/block phases. A synthetic sculk player controls warning levels,
|
||||
not client input; dispenser probes call one activation without running unrelated world ticks.
|
||||
Keep those controls when extending the fixtures. Player interactions belong in connected-client
|
||||
coverage alongside the components:
|
||||
|
||||
```sh
|
||||
python3 tools/test_command_exec_parity.py
|
||||
python3 tools/test_dispenser_parity.py
|
||||
python3 tools/test_sculk_parity.py
|
||||
python3 tools/lan_e2e.py --server-thread --check machines --check fireball --check sculk_container
|
||||
```
|
||||
|
||||
The LAN checks open and fill machines through the guest's inventory packets, observe a
|
||||
powered dispenser's projectile on both clients, and open a chest to activate a sculk sensor
|
||||
and shrieker. They supplement the deterministic component comparisons.
|
||||
|
||||
## Reading vanilla
|
||||
|
||||
Besides the Vineflower sources in `.local/minecraft/<version>/sources/`, `tools/rea_vanilla.py` queries the shipped bytecode through REA (callers through lambdas, overloads, a second decompiler); see [decompilation status](decompilation-status.md#querying-the-shipped-bytecode-with-rea).
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Pregeneration: `/pregen`
|
||||
|
||||
`/pregen` generates every chunk of a square or a circle ahead of the players, lights it and saves it, as
|
||||
Chunky does on a Java server. It is Horizon's own command (vanilla has none), available in single player
|
||||
with cheats on and to operators (level 2) on a server, from the chat or the server console
|
||||
(`horizon-server cmd pregen start 2500`).
|
||||
|
||||
It is off until you turn it on, so `/help` and the command tree stay vanilla's:
|
||||
|
||||
- a server: `horizon-pregen = true` under `[properties]` in `server.toml` (or `horizon-pregen=true` in a
|
||||
vanilla folder's `server.properties`), then restart it;
|
||||
- single player and LAN: start the game with `--pregen`.
|
||||
|
||||
```text
|
||||
/pregen start <radius> [square|circle] [<x> <z>] radius in blocks; the centre defaults to where you
|
||||
stand (the world spawn from the console)
|
||||
/pregen status chunks done, chunks per second, time left
|
||||
/pregen pause | continue stop scheduling new chunks, and go on
|
||||
/pregen cancel stop; what is done stays saved
|
||||
```
|
||||
|
||||
The area is the chunks within `radius / 16` chunks of the centre chunk: a square of side
|
||||
`2 * (radius / 16) + 1` (radius 2500 is 313 x 313 = 97,969 chunks), or the chunks whose distance from the
|
||||
centre chunk is at most `radius / 16`. It runs in the dimension the command was run in; that level keeps
|
||||
ticking while the task runs, whoever is in it. The progress goes to the server log every five seconds
|
||||
and to the player who started it, and once more when it is done. A task is not kept across a restart:
|
||||
start it again and the chunks already saved load instead of generating.
|
||||
|
||||
## How it works
|
||||
|
||||
- `horizon_client::pregen::Pregen` cuts the area into strips at most 256 chunks wide and sweeps each
|
||||
north to south with a band of rows (`streaming::Band`) holding about a thousand chunks.
|
||||
- Streaming treats the band like a player's area: it generates its chunks and the rings around them that
|
||||
decoration and light need, and lights its own chunks. Once every chunk of the band's first row is lit
|
||||
and post-processed (`LevelChunk.postProcessGeneration`, which vanilla runs before a chunk is FULL), the
|
||||
band moves down a row; the rows that fall out of its reach unload and are saved like any chunk the
|
||||
players leave, so memory holds only the rows in flight.
|
||||
- The chunks a band reaches are ranked for decoration row by row as they come within its reach
|
||||
(`Streaming::set_band`). Decoration is order dependent where neighbours' writes overlap
|
||||
(`DecorationOrder`), and this makes a task decorate in the same order however its jobs are timed and
|
||||
shared among the workers: the same seed gives the same chunks.
|
||||
- Between server ticks the server waits for the workers' results and hands out the next jobs at once
|
||||
(`Streaming::wait`, `pump_pregen`), instead of once a tick: a chunk passes through five jobs
|
||||
(generate, decorate, finish, light, save), each needing its neighbours' earlier ones.
|
||||
|
||||
The chunks of the band's outer ring are finished (FULL) but not lit, as at the edge of what a player has
|
||||
loaded; they light when their neighbours load later.
|
||||
@@ -0,0 +1,44 @@
|
||||
# Resource preparation and filesystem work
|
||||
|
||||
The reported preparation timings put sounds at 20–29 seconds with little CPU use, versus
|
||||
0.9–1.4 seconds for fresh client asset extraction. Prefer fewer file opens, reads and writes
|
||||
over parallelizing decompression.
|
||||
|
||||
Preparation now shares one parsed asset index between panorama, font, pack and language imports.
|
||||
Its destination verification results live only for that preparation. A subsequent invocation
|
||||
checks bytes again, so it can repair corrupt resources. Existing valid destination files do not
|
||||
require the original asset objects to remain installed. A saved asset index also lets preparation
|
||||
preserve full imports when only cached Minecraft JARs remain.
|
||||
|
||||
New imports are staged beside their destination. On Linux, FICLONE is attempted first; other
|
||||
filesystems fall back to copying while hashing. Cloned copies are hashed before publication.
|
||||
macOS attempts clonefile with the same checked streaming fallback. A whole asset group is staged and
|
||||
verified before any replacement is published; corrupt late panorama faces leave placeholders
|
||||
alone. Temporary files are cleaned up on errors. This is not a transaction for rename failures
|
||||
or process termination during publication: a later run repairs incomplete groups.
|
||||
|
||||
Unchanged JAR resources are checked by the ZIP member's size and CRC, avoiding repeated
|
||||
decompression. Valid indexed replacements take precedence over JAR placeholders. Reusing checked
|
||||
Minecraft imports also passes the verified artifact/library results directly to the exporters.
|
||||
|
||||
## An immutable store across releases
|
||||
|
||||
The official launcher's SHA-1 object store already provides an immutable source for indexed
|
||||
assets. Independent filesystem clones let installed Horizon releases share physical blocks
|
||||
where supported, without sharing writable inodes. Ordinary copies remain the fallback.
|
||||
|
||||
A separate Horizon store could additionally share complete preparations on filesystems without
|
||||
cloning. Its key would need the pinned client/server hashes, the preparer's output version (or
|
||||
the legacy source/exporter fingerprint), and the actual asset-index digest: Mojang republishes
|
||||
translations without changing the Minecraft release. Two preparations with different optional
|
||||
asset availability must not claim the same complete snapshot.
|
||||
|
||||
Before adopting that store, separate immutable runtime resources from mutable exporter scratch,
|
||||
classes and logs. Publish snapshots through a temporary directory and atomic rename, give each
|
||||
release an explicit reference, and define locking, corruption repair, migration and garbage
|
||||
collection. Exporters must never receive a shared writable directory or hard-linked files.
|
||||
The existing launcher compatibility check should choose reuse; the store should only supply its
|
||||
bytes. Keep this separate from the open work on output-version compatibility (#1946/#1947).
|
||||
|
||||
For now, retain independent release directories and clone their resource files. This reduces
|
||||
copying where the filesystem supports it without introducing a second ownership/cleanup scheme.
|
||||
+60
-6
@@ -13,7 +13,7 @@ reopened; labels never start it):
|
||||
| Job | Runs on | What | Time |
|
||||
| --- | --- | --- | --- |
|
||||
| `verify` | GitHub `ubuntu-latest` | Public-tree check, Python tests, rustfmt, clippy with warnings denied, Rust tests. Dependencies and the workspace build come from a cache saved by main's runs | ~4 min cold, less warm |
|
||||
| `parity / parity` | The Mac mini's runner (`ludovics-mac-mini`, label `horizon-game`) | The vanilla harnesses the change can affect (`tools/parity.py --changed <base>`) | seconds when nothing is affected; minutes per affected harness |
|
||||
| `parity / parity` | A runner with the label `horizon-game`: the Mac mini's two, and the desktop's while nobody uses it (below) | Only for a change to a harness, an oracle, a probe or the runner (or the `run-parity` label): the vanilla harnesses the change can affect (`tools/parity.py --changed <base>`). Other pull requests skip it: [parity-main](#parity-on-main) checks them on main | seconds when nothing is affected; minutes per affected harness |
|
||||
|
||||
Pushes to main run `verify` only; the nightly audit covers main's harnesses.
|
||||
|
||||
@@ -28,10 +28,13 @@ The job is `.github/workflows/parity.yml`, a reusable workflow: `checks` calls i
|
||||
repository, `run-parity.yml` for a fork's pull request a maintainer labels `run-parity`.
|
||||
|
||||
Horizon never downloads the game, so harnesses that compare with vanilla run only where the maintainer's own
|
||||
copy is: the Mac mini. Its runner runs as the maintainer's account and keeps its checkout between runs
|
||||
(`clean: false`), so the probes build incrementally into `.local/parity-target` and earlier passes stand.
|
||||
copy is: the Mac mini and his Linux desktop. Their runners run as the maintainer's account and keep their checkout
|
||||
between runs (`clean: false`), so the probes build incrementally into `.local/parity-target` and earlier passes
|
||||
stand.
|
||||
|
||||
1. `tools/ci/runner-env.sh` puts the machine's Python 3.13 and the JDK `research-lock.json` pins on the PATH.
|
||||
1. `tools/ci/runner-env.sh` puts the machine's Python 3.13 and the JDK `research-lock.json` pins on the PATH
|
||||
(Homebrew and `java_home` on the Mac; on NixOS what `linux-runner.sh` pinned, else nixpkgs), and sccache when
|
||||
the machine has it.
|
||||
2. `tools/ci/vanilla-data.sh` links `.local/` to the runner's copy of the vanilla data, cloned once from
|
||||
`~/code/horizon-parity/shared-local` into `~/.actions-runners/horizon/_work/horizon/shared-local`, and
|
||||
prepares `.local/horizon-client` with the pull request's own `horizon-prepare` once per preparer version
|
||||
@@ -39,10 +42,17 @@ copy is: the Mac mini. Its runner runs as the maintainer's account and keeps its
|
||||
depend only on the Minecraft version, are kept once in `shared-local/sounds/<version>/` (copied from a folder
|
||||
`horizon-prepare sounds` made from the maintainer's own game; the Mac mini has no official launcher of its own)
|
||||
and cloned into each preparation (not linked: vanilla's packs refuse symbolic links), for the audio harnesses.
|
||||
`tools/prepare_output.py check` then compares what was prepared with `crates/horizon-prepare/output-versions.txt`:
|
||||
launchers keep a player's prepared resources across releases whose preparer declares the same `OUTPUT_VERSION`
|
||||
(`crates/horizon-prepare/src/lib.rs`), so a change to the prepared files fails here until it bumps the number
|
||||
and appends the new digest (the error gives both lines).
|
||||
3. `tools/parity.py --changed <base sha>` picks the harnesses whose traced dependencies (their script, Python
|
||||
modules, Java oracles and every Rust source their probes compile) changed since the merge base, plus any
|
||||
harness nothing is recorded about yet, and runs those that have no pass for their current inputs. A change to
|
||||
`Cargo.lock` or `research-lock.json` affects every harness. Each harness has 25 minutes, the job 45.
|
||||
The selection runs with main's `tools/parity.py` and `tools/parity_reach.py` (`--changed <base> --list`), so a
|
||||
branch made before a better selection landed gets it too, and the head's own `parity.py` then runs the named
|
||||
harnesses. A branch that changes either file selects with its own code.
|
||||
|
||||
Failed harnesses' logs are uploaded as the `parity-logs` artifact.
|
||||
|
||||
@@ -64,6 +74,26 @@ release's macOS build back. Each keeps its own checkout, `target/` and Rust inst
|
||||
`_work/horizon/shared-local` links to the first's, so they share the vanilla data, the preparations (one at a
|
||||
time, under a lock) and the parity passes and slots.
|
||||
|
||||
**The desktop's runner.** `ludodesktop-horizon` (labels `self-hosted`, `Linux`, `X64`, `ludodesktop`, and
|
||||
`horizon-game` once a full trial has passed there) runs on the maintainer's Linux desktop while nobody uses it: its
|
||||
screen locked, or untouched for 15 minutes (his rule, 2026-10-26). `tools/ci/linux-runner.sh install`, run there as
|
||||
him, registers it and installs two systemd user services: `horizon-runner` (the runner, in
|
||||
`~/.actions-runners/horizon`, nice 19, in `horizon-ci.slice` with CPU and I/O weight 20, half the threads (on all of
|
||||
them the CPU package reached 92–96 °C) and memory capped at two thirds of the RAM; `CARGO_BUILD_JOBS` and the harness slots at 8, after the machine froze under ~7 cold cargo
|
||||
builds on 2026-10-14; its own Rust install; the JDK, sccache and the build libraries from nixpkgs; its own
|
||||
`vscreen` so no game it starts reaches his screen) and `horizon-runner-pause` (`tools/ci/runner_pause.py`), the
|
||||
only thing that starts the runner. The watcher stops it at once on keyboard, mouse or gamepad input (read from
|
||||
`/dev/input`: only whether bytes came, never what), while an unlocked session has had input in the last 15 minutes,
|
||||
while the CPU package is at 90 °C or more, while a game runs (Steam, gamescope, Wine, Proton or Minecraft
|
||||
processes, fleet-load's own detection, or a process outside the CI slice using the GPU at 50 % or more), or while
|
||||
`~/.actions-runners/horizon/pause` exists, and starts it again 5 minutes after the last such sign. A job already
|
||||
under way is throttled to 2 threads at the lowest weight and the runner stops after it: freezing the job would make
|
||||
GitHub drop it as lost and the harnesses time out. Old pull requests' `runner-env.sh` know only the Mac: the
|
||||
runner's `.env` and `.path` give their jobs Python, the JDK and the vanilla data (`HORIZON_SHARED_SOURCE`) all the
|
||||
same. The nightly audit and parity-main stay on the Mac mini's runners: the audit compares with the previous night,
|
||||
so it stays on one platform, and a parity-main job slowed down on the desktop because he came back could time out,
|
||||
and its failures bisect and comment on merges.
|
||||
|
||||
## Merging
|
||||
|
||||
Pull requests merge with a merge commit. The orchestrator sessions review a pull request, then turn on
|
||||
@@ -80,10 +110,34 @@ gh api -X POST repos/ludovic111/horizon/branches/main/protection/required_status
|
||||
A skipped `parity` (a fork's pull request without the label) counts as passed, so requiring it never blocks a
|
||||
fork's pull request; the maintainer decides whether to run it.
|
||||
|
||||
## Parity on main
|
||||
|
||||
Most pull requests merge on `verify` alone and leave the vanilla harnesses to `.github/workflows/parity-main.yml`,
|
||||
which runs them on main a batch of merges at a time, on the Mac mini's runner:
|
||||
|
||||
- It starts on every push to main, one run at a time (`concurrency: parity-main`). Merges that land while a run
|
||||
goes on wait in one pending run: GitHub keeps only the newest and cancels the others, so the next run takes them
|
||||
all.
|
||||
- `tools/parity_main.py base` gives the newest commit main contains whose parity-main passed (else the last
|
||||
merge's parent), and the run is `tools/parity.py --changed <that commit>`: the union of the harnesses every merge
|
||||
since then can affect, once, with every earlier pass reused.
|
||||
- On a failure, `tools/parity_main.py bisect` checks out the batch's first-parent merges by halves and runs only
|
||||
the failing harnesses, names the first merge they fail on in the run's summary and comments on its pull request
|
||||
(`🤖 Agent: parity-main found that this merge breaks ...`). Fix it with a pull request as usual; the next
|
||||
run checks from the last green commit again.
|
||||
- Game releases ship only a commit both `checks` and `parity-main` passed on (`tools/release_train.py`, see
|
||||
below), so a broken merge holds releases instead of reaching players. `release.yml` also starts when a
|
||||
parity-main run finishes. A forced release (`force=true`) doesn't wait for parity-main.
|
||||
|
||||
A pull request still runs its own parity job when it changes a harness script, an oracle
|
||||
(`mods/horizon/src/test/`), a probe (`crates/*/examples/`, `game/*_fixture.rs`, `game/*_harness.rs`), the runner
|
||||
(`tools/parity*.py`, `tools/lab.py`, `tools/parity_hosts.json`, `parity*.yml`), or carries the `run-parity` label
|
||||
(`run-parity.yml` runs it when the label is added).
|
||||
|
||||
## Game releases
|
||||
|
||||
`.github/workflows/release.yml` releases the game by itself. It starts after every green `checks` run of a push
|
||||
to main, every 10 minutes (so a release waiting for merges to settle goes out without another merge), and by hand.
|
||||
`.github/workflows/release.yml` releases the game by itself. It starts after every green `checks` or `parity-main`
|
||||
run of a push to main (it releases a commit only once both passed on it), every 10 minutes (so a release waiting for merges to settle goes out without another merge), and by hand.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
# Horizon shader packs
|
||||
|
||||
Horizon has its own shader packs: WGSL written against stages of Horizon's renderer, checked before they run. This page
|
||||
is the guide for pack authors. The design and the pack format are in [api/shaders.md](api/shaders.md); every stage's
|
||||
signature, input, resource and limit is in the generated [api/shaders-reference.md](api/shaders-reference.md).
|
||||
|
||||
Shader packs in the Iris/OptiFine format are a separate feature with its own loader; this page is only about
|
||||
Horizon's own format.
|
||||
|
||||
| Part | Where | State |
|
||||
|---|---|---|
|
||||
| Format, stages, check | `crates/horizon-shader-api` | API 0.1, experimental |
|
||||
| Authoring tool | `horizon-shader` (same crate) | `new`, `check`, `pack` |
|
||||
| Templates | `crates/horizon-shader-api/templates/` | post, sky, material |
|
||||
| Example pack | `crates/horizon-shader-api/packs/golden_hour` | a warm sky and two post passes |
|
||||
| In the game: the post stage | Options > Horizon Settings > Shader Packs | post passes, hot reload |
|
||||
| In the game: sky and material; the launcher and the registry | | not yet |
|
||||
|
||||
## Quick start
|
||||
|
||||
```sh
|
||||
cargo install --path crates/horizon-shader-api # or: cargo run -p horizon-shader-api --bin horizon-shader -- <command>
|
||||
horizon-shader new my_pack --template post # also: --template sky, --template material; --name "My Pack"
|
||||
horizon-shader check my_pack # what the game, the launcher and the registry will check
|
||||
horizon-shader pack my_pack # check, then write my_pack-0.1.0.hshader beside the folder
|
||||
```
|
||||
|
||||
`check` prints each stage with its cost, and the pack's SHA-256:
|
||||
|
||||
```
|
||||
golden_hour 1.0.0 (shader API 0.1): ok
|
||||
sky Warm horizon 99 expressions, 0 texture reads
|
||||
post Glow 192 expressions, 3 texture reads
|
||||
post Colour grade 201 expressions, 2 texture reads
|
||||
sha256 b5e0d98c...
|
||||
```
|
||||
|
||||
or every problem, at its file, line and column:
|
||||
|
||||
```
|
||||
my_pack 0.1.0 (shader API 0.1): FAILED
|
||||
post.wgsl:9:1: expected `;`, found "}"
|
||||
```
|
||||
|
||||
`--json` prints the same for tools (`ok`, `id`, `version`, `api`, `sha256`, `stages`, `problems`).
|
||||
|
||||
## Trying a pack in the game
|
||||
|
||||
Put the pack folder (or its `.hshader`) in `shaderpacks/` beside `options.txt` (Open Pack Folder opens it) and pick
|
||||
it on Options > Horizon Settings > Shader Packs, which lists Horizon's packs, marked (Horizon), beside packs in the
|
||||
`shaders/` format; one runs at a time, and clicking it again turns it off. `HORIZON_SHADER_PACK=<its folder or file
|
||||
name>` runs a pack whatever the page says, for development. The game checks the pack first, and refuses one that
|
||||
fails, with its problems in the chat. While it runs, the game looks at the pack twice a second: save a file
|
||||
and the pack is checked and rebuilt in place ("Shader pack ... reloaded"); if the new version fails, the chat says
|
||||
where and the last good version keeps drawing. The post passes run today; the sky and material stages are checked
|
||||
but not drawn yet.
|
||||
|
||||
## A pack
|
||||
|
||||
A folder (or the same files zipped as a `.hshader`) with `horizon-shaders.toml` and WGSL files:
|
||||
|
||||
```toml
|
||||
schema = 1
|
||||
id = "my_pack"
|
||||
name = "My Pack"
|
||||
version = "0.1.0"
|
||||
api = "0.1"
|
||||
|
||||
[[post]]
|
||||
file = "post.wgsl"
|
||||
|
||||
[[options]]
|
||||
id = "saturation"
|
||||
name = "Saturation"
|
||||
type = "float"
|
||||
default = 1.15
|
||||
min = 0.0
|
||||
max = 2.0
|
||||
```
|
||||
|
||||
Every key is in [api/shaders.md](api/shaders.md#the-pack-format-schema-1).
|
||||
|
||||
## Stages
|
||||
|
||||
A stage is one function your file defines. Horizon puts its prelude (the structs, `frame`, the stage's resources and
|
||||
helpers) before your file and calls the function from its own pass, so the world is still culled, batched and meshed
|
||||
by Horizon: a pack changes how things look, not how they are drawn.
|
||||
|
||||
| Stage | Your function | What it does |
|
||||
| --- | --- | --- |
|
||||
| `[sky]` | `fn sky(input: SkyInput) -> vec4<f32>` | the sky's colour along each view ray; the sun, moon, stars and clouds are drawn over it |
|
||||
| `[material]` | `fn material(input: MaterialInput) -> Surface` | the lit colour of each point of a block's surface, before the alpha test and fog |
|
||||
| `[[post]]` | `fn post(input: PostInput) -> vec4<f32>` | a full-screen pass over the world's picture (up to 8, in order), under the hand and HUD |
|
||||
|
||||
A pack has at least one stage; a stage it leaves out keeps vanilla's look. Each input says what vanilla would draw
|
||||
(`input.color` in the sky and post stages; `albedo * tint * vec4(lightmap, 1.0)` for a material), so a pack can start
|
||||
from vanilla and change only what it means to.
|
||||
|
||||
Every stage can read `frame`: the camera's matrices and position, the sun and moon directions, the time of day,
|
||||
vanilla's sky and fog colours, rain and thunder, fog distances, the light at the camera, effects and the dimension.
|
||||
Post passes also read `scene_color`, `scene_depth`, `previous` (the last pass's output), two samplers and the helpers
|
||||
`depth_at(uv)` and `view_position(uv, depth)`.
|
||||
|
||||
Rules the check enforces: your files declare no bindings (`@group`/`@binding`), no entry points and no names starting
|
||||
with `horizon_`. Code shared by several stages goes in files listed in `shared`, put before every stage.
|
||||
|
||||
## Options
|
||||
|
||||
Each `[[options]]` entry is a WGSL `override` of the same name, set when the game builds the pipeline: no text
|
||||
substitution, no recompiling a different program per value.
|
||||
|
||||
```wgsl
|
||||
override saturation: f32 = 1.15; // type = "float"; bool → bool, int → i32, choice → u32 (the value's index)
|
||||
```
|
||||
|
||||
The game shows the options on the pack's settings screen. Branches on an option are on a constant, so the GPU
|
||||
skips the side that isn't taken.
|
||||
|
||||
## What the check does
|
||||
|
||||
The game runs the same check when it loads a pack (a pack that fails is refused with the message, and the last good
|
||||
one keeps drawing), the launcher before it installs one, and the registry's CI before a pack is listed:
|
||||
|
||||
1. The manifest and the package: known keys, valid ids, every file used, sizes.
|
||||
2. Each stage built as the renderer builds it and validated by naga.
|
||||
3. The stage function's signature, and the rules above.
|
||||
4. Each `override` matches its option's type (or has a default); each option is used.
|
||||
5. Budgets: 20 000 expressions and 64 texture reads per stage.
|
||||
6. Every entry point translated for Vulkan (SPIR-V), Metal and DirectX 12 (HLSL), with the options at their
|
||||
defaults, minimums and maximums.
|
||||
|
||||
`[budget] gpu_ms` is the GPU time your pack aims to add to a frame. To compare, open F3 in the game: while it is
|
||||
open, each pass is timed on the GPU and the overlay shows the pack's total and its costliest passes, by their `name`
|
||||
(the median of the last 15 timed frames). Timing waits for nothing, so it does not slow the game.
|
||||
|
||||
## Next
|
||||
|
||||
The material and sky stages in the game, and the registry's `shader` kind with installs from the launcher.
|
||||
Reference in New Issue
Block a user