Merge main (#1895: world takes level 4): recipes moves to API level 5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+58
-8
@@ -285,6 +285,7 @@ A step's parts happen in this order:
|
||||
| --- | --- |
|
||||
| `reload = true` | stops the mod and starts it again, as a rebuild does in the game: its memory starts over, its `storage` stays |
|
||||
| `title-screen = true` | no player and no clock until a step sets them |
|
||||
| `blocks = [{ x = 0, y = 63, z = 0, state = "minecraft:stone" }]` | server mods with `world`: those blocks of the Overworld, before the rest of the step (every other block is air, every biome the dimension's plainest: plains, nether wastes, the end) |
|
||||
| `player = { x = 3.0, ... }`, `clock = { day-time = 0 }` | changes those fields (`x y z yaw pitch health food dimension`, `game-time day-time`) |
|
||||
| `ticks = n`, `frames = n` | that many ticks (the game's tick counter and the clock move on), then frames 1/60 s apart |
|
||||
| `chat = "<Steve> hi"` | a chat line the player receives |
|
||||
@@ -310,6 +311,7 @@ checked:
|
||||
| `feedback = "..."`, `error = "..."` | the command's answer, shown plain or in red |
|
||||
| `panel = ["..."]`, `corner = "top-left"` | its HUD panel's lines (`[]`: no panel) and corner |
|
||||
| `told = ["Alex: Welcome!"]`, `broadcast = ["..."]` | server mods: every `players.tell` (as `name: text`) and `players.broadcast`, in order |
|
||||
| `blocks = [{ x = 2, y = 64, z = 0, state = "minecraft:glowstone" }]` | server mods with `world`: those blocks of the Overworld after the step, the mod's `set-blocks` made (the script checks a state's shape; the game checks its name) |
|
||||
| `stopped = "panic"` | the mod was turned off, for a reason holding this text; without it, a mod that traps, panics or overruns fails the test |
|
||||
|
||||
Unknown keys are errors, so a typo never passes silently. The same runner is
|
||||
@@ -478,6 +480,7 @@ its component targets the WIT world `horizon-server-mod` instead of
|
||||
| `log` | always | as for client mods |
|
||||
| `storage` | `storage` | as for client mods, in the server's `horizon-mods/` |
|
||||
| `players` | `players` | `online()`: id, name, position, dimension, game mode, health of each player on; `tell(id, text)`, `broadcast(text)`: system messages after the mod's name, 8 per call |
|
||||
| `world` | `world` | `get-block(dimension, x, y, z)`: the state in a loaded chunk, `minecraft:oak_log[axis=y]`; `get-biome(dimension, x, y, z)`: `minecraft:plains`, ...; `set-blocks(dimension, changes)`: up to 4096 per call, checked at once, made as `/setblock` makes them (neighbours, light, block entities, every player told) after the call, before that dimension's next tick |
|
||||
|
||||
| Hook (export `server-events`) | When |
|
||||
|---|---|
|
||||
@@ -491,10 +494,53 @@ its component targets the WIT world `horizon-server-mod` instead of
|
||||
Capabilities that act on a local player (`game-read`, `chat`, `hud`) are for
|
||||
client mods; `players` is for server mods. In Rust: `impl
|
||||
horizon_mod_sdk::server::ServerMod` and `export_server_mod!`; the example is
|
||||
[`welcome`](../crates/horizon-mod-sdk/examples/welcome/src/lib.rs). The
|
||||
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.
|
||||
[`welcome`](../crates/horizon-mod-sdk/examples/welcome/src/lib.rs), and with
|
||||
`world`, [`beacons`](../crates/horizon-mod-sdk/examples/beacons/src/lib.rs).
|
||||
|
||||
**Capability `world`.** Reads are of the server's loaded chunks as they are
|
||||
during the call: the game lends a server mod's call the levels' chunk maps
|
||||
(moved, not copied, and only while a running mod has `world`), so a read
|
||||
costs a map lookup and no copy of the world. A dimension with no chunk loaded
|
||||
at a position reads as none. Writes go through the same code as `/setblock`,
|
||||
so block updates, light, block entities and every client (LAN guests,
|
||||
dedicated server players) see them as vanilla's; the parity harnesses test
|
||||
that code. Changes for a dimension whose level isn't ticking wait for it
|
||||
(in-frame single player ticks only the player's), up to 65,536 blocks; a
|
||||
change in a chunk that isn't loaded when it is made is skipped, as `/setblock`
|
||||
refuses one.
|
||||
|
||||
**Where they run.** The game that simulates the world starts the server mods
|
||||
that are on, and only that one:
|
||||
|
||||
| Mode | Runs server mods | Players they see |
|
||||
|---|---|---|
|
||||
| Single player (default) | the server thread | the window's player, a connection like any other |
|
||||
| Single player `--in-frame` | the window's own game, beside its client mods | the window's player |
|
||||
| Open to LAN, Play with Friends | the host's server thread (or its window, in-frame) | the host and every guest |
|
||||
| Dedicated server (`--dedicated`, `horizon-server`) | the server | every connected player |
|
||||
|
||||
A window that is a client of a server (single player's window, a LAN guest,
|
||||
any multiplayer server) never runs them; its Mods page lists a server mod with
|
||||
the others, and its switch takes effect the next time a world opens. The mods
|
||||
live in `horizon-mods/` of the game folder, or of the server's folder on a
|
||||
dedicated server, and are turned on as client mods are: Options > Mods, or
|
||||
`mod.<id>:true` in `horizon-mods.txt`. `--dev-mod <file>` runs one always
|
||||
on and reloads it when its file changes, on a server too.
|
||||
|
||||
**When hooks run.** At the end of each server tick the game tells the server
|
||||
mods who joined and who left since the last one, then what players said,
|
||||
broke and placed, in order, then calls `tick`. A command a player types
|
||||
reaches its mod at once, whatever the player's permission level, and its
|
||||
answer goes to that player. `tell` reaches one player, the window's own
|
||||
chat for the in-frame player and a system message for a connection;
|
||||
`broadcast` reaches every player and the server's log. With no server mod
|
||||
on, each of these points costs one branch (measured in the PR that added
|
||||
them).
|
||||
|
||||
**Not yet.** Clients aren't sent server mods' commands with vanilla's
|
||||
command tree, so a player's chat box doesn't complete or colour them; typing
|
||||
them works. Block events are a player's own breaking and placing, not
|
||||
explosions, pistons or other mods.
|
||||
|
||||
## Publish your mod
|
||||
|
||||
@@ -515,6 +561,10 @@ published. Players find them at [playhorizon.dev/mods](https://playhorizon.dev/m
|
||||
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.
|
||||
|
||||
Once it is published, its page and its card in the launcher show its downloads (GitHub's counts of its files,
|
||||
refreshed every hour) and its rating: players signed in with GitHub on its page give it 1 to 5 stars, one rating per
|
||||
account, which they can change. Its owners can't rate it, and nobody sees who rated.
|
||||
|
||||
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).
|
||||
@@ -561,10 +611,10 @@ so the same rustc and `Cargo.lock` give the same file.
|
||||
in single player and on any server, vanilla or Horizon. They see only what
|
||||
the client already knows (the snapshot), like F3 does, and act only on the
|
||||
local screen and chat. A server cannot see them.
|
||||
- **Server mods** (`side = "server"`) will run where the world is simulated:
|
||||
Horizon's integrated server in single player and LAN, and the dedicated
|
||||
server. Vanilla clients can join if the mod only uses vanilla content
|
||||
(rules, commands, events).
|
||||
- **Server mods** (`side = "server"`, API 0.3) run where the world is
|
||||
simulated: single player's server thread (or the window, in-frame), a LAN
|
||||
host and the dedicated server ([Server mods](#server-mods-api-03-experimental)).
|
||||
They use only vanilla messages, so any client, vanilla or Horizon, can join.
|
||||
- **Both** (`side = "both"`): a server mod with a client half (new blocks,
|
||||
their textures, a custom screen). On join the Horizon server announces its
|
||||
mods (id, version, SHA-256) on a `horizon:mods` custom payload channel; a
|
||||
|
||||
Reference in New Issue
Block a user