Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.
Rust differential-testinggame-enginegamedevlinuxminecraftminecraft-javareimplementationrustvoxelvulkanwgpu
Agent control: a hello command answers the protocol, the release and the command groups
Akirabane1e03f61c9885
diff --git a/crates/horizon-client/src/bin/horizon-ctl/commands.rs b/crates/horizon-client/src/bin/horizon-ctl/commands.rsindex 39318b25c..70b4e26da 100644--- a/crates/horizon-client/src/bin/horizon-ctl/commands.rs+++ b/crates/horizon-client/src/bin/horizon-ctl/commands.rs@@ -214,6 +214,9 @@ pub const COMMANDS: &[Cmd] = &[mcp: true, local: true),cmd!("status", Session, "status", "game, renderer and streaming state (the scripting socket's original summary)","Also what F3 shows: the overlay flags, the renderer, chunk streaming and memory.", ["horizon-ctl status"], &[], mcp: true, local: false),+ cmd!("hello", Session, "hello", "the control protocol's version, the game's release and the command groups it serves",+ "Replies protocol (MAJOR.MINOR.PATCH of the control protocol, docs/api/stability.md), release (the game's version, the string MCP serverInfo carries too) and features (the command groups the game answers, so a script can test for one before calling it).",+ ["horizon-ctl hello"], &[], mcp: true, local: false),cmd!("worlds", Session, "worlds", "the saved worlds, newest first: folder, name, mode, last played, version","folder is what open, world-rename, world-backup and world-delete take.", ["horizon-ctl worlds"], &[], mcp: true, local: false),cmd!("world-rename", Session, "world-rename FOLDER NAME", "rename a world, as Edit World does (its folder stays)",diff --git a/crates/horizon-client/src/game/control.rs b/crates/horizon-client/src/game/control.rsindex fe75e8890..c9a6f3a5a 100644--- a/crates/horizon-client/src/game/control.rs+++ b/crates/horizon-client/src/game/control.rs@@ -10,7 +10,27 @@ use std::{};use winit::{event::MouseButton, keyboard::KeyCode};+/// The control protocol's version (`docs/api/stability.md`): before 1.0 an+/// addition makes the next patch and a breaking change the next line.+const PROTOCOL: &str = "0.1.0";++/// The command groups the game serves, as `help` chains them: what `hello` reports as its features.+const FEATURES: &[&str] = &[+ "game", "station", "blocks", "lan", "friends", "render", "sculk", "agent", "ui", "options",+ "events", "saves", "pad",+];++/// `hello`: the protocol the socket speaks, the game's release and the command groups it serves.+fn hello() -> Value {+ json!({+ "protocol": PROTOCOL,+ "release": horizon_core::release::VERSION,+ "features": FEATURES,+ })+}+const HELP: &[&str] = &[+ "hello the control protocol's version, the game's release and the command groups it serves","status game, player, streaming and renderer state","simulation authoritative projectiles in the owner's level","server-hold on|off hold simulation and player packets at a control-fixture barrier",@@ -355,6 +375,7 @@ impl Game<'_> {Ok(Some(json!({ "ok": true, "sides": r.section_sides() })))}"sculk" => Ok(Some(self.sculk_command(&words)?)),+ "hello" => Ok(Some(hello())),"status" => Ok(Some(self.control_status())),"stall" => {let millis: u64 = arg(1)?.parse()?;@@ -1403,6 +1424,25 @@ fn key_code(name: &str) -> Option<KeyCode> {mod tests {use super::*;+ #[test]+ fn hello_names_the_protocol_the_release_and_the_command_groups() {+ let reply = hello();+ assert_eq!(reply["release"], horizon_core::release::VERSION);+ let protocol = reply["protocol"].as_str().unwrap();+ let parts: Vec<_> = protocol.split('.').collect();+ assert!(+ parts.len() == 3 && parts.iter().all(|p| p.parse::<u32>().is_ok()),+ "{protocol}"+ );+ let features = reply["features"].as_array().unwrap();+ assert!(!features.is_empty());+ let mut names: Vec<_> = features.iter().filter_map(Value::as_str).collect();+ assert_eq!(names.len(), features.len());+ names.sort_unstable();+ names.dedup();+ assert_eq!(names.len(), features.len(), "a group is named twice");+ }+#[test]fn taps_and_ups_always_release_their_key() {for line in ["key shift tap", "key shift up", "key Shift up"] {diff --git a/docs/api/agent-control.md b/docs/api/agent-control.mdindex fb686d199..b34b123c4 100644--- a/docs/api/agent-control.md+++ b/docs/api/agent-control.md@@ -42,8 +42,8 @@ API offers; the other commands the game's socket answers are test hooks and expe## Not there yet-- **A version.** A `hello` command that answers the protocol version, the game's release and the features it has;- MCP `serverInfo` carries the same version; `horizon-ctl` refuses a game whose major it doesn't speak.+- **A version that is checked.** `hello` answers it (and MCP `serverInfo` carries the release), but `horizon-ctl`+ still drives any game: it should refuse one whose line it doesn't speak (`horizon-ctl --api 0.1`).- **Reply schemas.** Each command's reply described in the table (fields, types, units), so the reference documentsreplies as well as arguments and MCP tools declare an output schema.- **Events as a stream.** `events --since` polls today; a subscription that pushes events as they happen.@@ -52,4 +52,6 @@ API offers; the other commands the game's socket answers are test hooks and expe## Changelog-- Unversioned so far: the command table and the generated reference are the contract.+- 0.1.0: the first numbered line. `hello` answers `protocol`, `release` (the game's version, which MCP `serverInfo`+ carries too) and `features` (the command groups the game serves). Before it the command table and the generated+ reference were the contract.diff --git a/docs/api/stability.md b/docs/api/stability.mdindex e5817610a..5616e8f3f 100644--- a/docs/api/stability.md+++ b/docs/api/stability.md@@ -18,7 +18,7 @@ promise, how something is deprecated and removed, and the tests that keep old mo| --- | --- | --- || Content mods | the manifest's `api` line | `api = "0.2"` in `horizon-mod.toml` || Native mods | the Horizon and horizon-mixins revisions the bundle pins | `horizon_revision` in `horizon-mixin.toml` |-| Agent control | the control protocol's version (planned: a `hello` reply and MCP `serverInfo`) | `horizon-ctl --api 1` (planned) |+| Agent control | the control protocol's version (`hello` replies it; MCP `serverInfo` carries the release) | `horizon-ctl --api 0.1` (planned) || Server control API | the path (`/api/v1/`) | the path || `server.toml` | the file's keys; a key is never renamed in place | nothing: old files keep loading || Launcher commands | the command names and their `--json` output | nothing |diff --git a/docs/horizon-ctl-commands.md b/docs/horizon-ctl-commands.mdindex 2bcfde074..fb6a49bf6 100644--- a/docs/horizon-ctl-commands.md+++ b/docs/horizon-ctl-commands.md@@ -12,6 +12,7 @@ Every command `horizon-ctl` takes, its MCP tool in `horizon-ctl mcp` (the launch| `wait-ready [SECONDS]` | `wait_ready` | Wait until the player has spawned and no chunks are pending | `seconds` (number): how long to wait (default 120) || `logs [--lines N] [--crash]` | `logs` | The end of the game's log, or its newest crash report | `--lines` (integer): how many lines of latest.log (default 100)<br>`--crash` (boolean): the newest crash report instead || `status` | `status` | Game, renderer and streaming state (the scripting socket's original summary) | none |+| `hello` | `hello` | The control protocol's version, the game's release and the command groups it serves | none || `worlds` | `worlds` | The saved worlds, newest first: folder, name, mode, last played, version | none || `world-rename FOLDER NAME` | `world_rename` | Rename a world, as Edit World does (its folder stays) | `folder` (string, required): world folder from worlds<br>`name` (text, required): the new name || `world-backup FOLDER` | `world_backup` | Zip a world into backups/, as Edit World's Make Backup does | `folder` (string, required): world folder from worlds |