# Hosting a Horizon server: design Horizon's dedicated server should be the easiest and lightest Minecraft 26.3 server to host. It should be one small native program with no Java and no Python, one command to install it, one config file, and a CLI, a web panel and a control API to manage it. At the same view and simulation distance and with the same players, it should beat vanilla, Paper and Fabric + Lithium on TPS/MSPT, RAM, CPU, chunk generation and start time. Gameplay stays vanilla: there are no Paper-style rule changes unless the owner turns one on. This page covers what the server does today (measured), the design of `horizon-server`, and what ships for the first working version (2026-10-23). The owner's guide is [docs/hosting.md](hosting.md). ## 1. Today ### How it runs The dedicated server is the game itself, run headless: `horizon-client --resources --dedicated [--nogui] [--port N] [--world NAME] [--universe DIR] [--initSettings]`, started in the server folder (`crates/horizon-client/src/game/dedicated.rs`). - **Startup.** It follows vanilla's `Main.main` and `DedicatedServer.initServer`. It reads `server.properties` and writes it straight back with vanilla's defaults filled in (`horizon_client::server`, byte-exact with vanilla's `Properties.store`), and refuses to start until `eula.txt` says `eula=true`. It then loads the operator, whitelist and ban lists in vanilla's order and format, and opens `/` with the same `Game` as single player, minus the local player. - **Network.** Players join through the play-state hub that Open to LAN uses (`crates/horizon-client/src/lan`). Status ping, legacy ping, compression, login gate (bans, whitelist, IP bans), operator permission levels, the player limit with `bypassesPlayerLimit`, MOTD and `server-icon.png` all follow `server.properties`. - **Main loop.** It ticks at 20 TPS on one thread, with chunk generation and lighting on the worker pool. Chunks stay loaded around every player (`lan_update_streaming`), or around the spawn while nobody is online. It supports `pause-when-empty-seconds`, `player-idle-timeout` and the autosave. - **Console (stdin).** `stop`, `save-all`, `save-on`/`save-off`, `list [uuids]`, `op`/`deop`, `whitelist on|off|list|reload|add|remove`, `ban`, `ban-ip`, `pardon`, `pardon-ip`, `banlist`, `kick` and `say` behave as in `DedicatedServer`. `tempban [reason]` is Horizon's own: a ban that ends by itself ([hosting](hosting.md#temporary-bans)). Every other command goes to the game's own dispatcher as the server (permission level 4). The log follows vanilla's Log4j pattern, in `logs/latest.log` and on stdout. - **Player names.** `usercache.json` in the universe folder works as vanilla's `CachedUserNameToIdResolver`. Players are added when they join and kept for a month, and the file keeps the 1000 most recently used, newest first. The console finds a player by name in it, in any case. A name it doesn't hold is asked of the profile service (`getByName`). If the service doesn't know the name, an offline server uses the offline player of the lower-case name; an online server answers "That player does not exist". `tools/test_user_cache_parity.py` checks this against vanilla, with a mock profile service. ### Measured (2026-10-16, Mac mini M4 Pro, main at bd8dff20, release build) The server ran in a scratch folder with `online-mode=false`, `level-seed=12345` and view and simulation distance 10. The vanilla server was the pinned 26.3 `server.jar` on Java 25 with `-Xmx4G`. | | Horizon (`horizon-client --dedicated`) | Vanilla 26.3 | |---|---|---| | Start, new world (wall clock, to `Done`) | 11.4 s (`Done (9.762s)`) | 12.5 s (`Done (2.066s)`, includes the bundler's first unpack) | | Start, existing world (wall clock) | **5.8 s** (resources load in 1.6 s) | 10.7 s (`Done (0.446s)`: the JVM and DataFixerUpper take the rest) | | RAM, idle with nobody online (RSS) | 1.40–1.51 GB | **0.93–0.97 GB** | | CPU, idle with nobody online | 1.2 % of one core | **0.6 %** | | `stop` to exit | 0.6 s | 0.6 s | | What has to be installed | one 46.8 MB binary + 589 MB of prepared resources | Java 25 + the 62 MB jar | | Crates linked | 384 (wgpu, winit, cpal, gilrs, arboard, naga…) | n/a | On Linux the full game loads `libasound.so.2` (cpal) and `libudev.so.1` (gilrs) at startup. wgpu, winit and the Wayland/X11 libraries are loaded only when a window opens. The server build (`horizon-engine`, section 3) is the same program built without its `audio` and `controllers` features, so it needs neither library, and a minimal server image runs it as it is. The two clear losses are RAM and idle CPU. The dedicated server loads everything the client needs to draw (the HUD atlas, item renderer, block-entity models, panorama, fog and music tables, entity models), and it builds the meshing tables at startup. None of these are used without a window. Loading them is startup work, not tick cost, so it is in scope here (see section 9). ### Joining it - **Horizon client:** works. A headless Horizon client (`--server 127.0.0.1:PORT`, the harness mode) logged in, received its 49 chunks at render distance 2, chatted, saw `/list`, and left. The server's log matched vanilla's lines (`logged in with entity id`, `joined the game`, `[Not Secure] …`, `lost connection: Disconnected`, `left the game`). - **Vanilla 26.3 client:** checked by `tools/test_dedicated_server_parity.py`. VanillaProtocolClient, a headless client built from vanilla's own codecs, pings and joins Horizon's server and vanilla's from the same world copy. It compares every login, configuration and play packet up to the first chunk batch, the chunk bytes, chat, `/list`, failing commands, the console lines and the files left behind. Result on main: see "Harnesses on main" below. - **The real vanilla 26.3 client** (`tools/vanilla_client.py`, from the owner's own files, dev-only) joins too. On 2026-10-18 it joined the server build of the game (`horizon-engine`, section 3) on the Mac mini: `python3 tools/vanilla_client.py --name Vanilla --join localhost:PORT`. It logged in, drew the terrain around spawn and stayed connected for four minutes, with no warning or error on the server. The tool runs on Linux under vscreen and on macOS from the logged-in screen session, even a locked one, with vsync off. ### What fails or is missing | Area | Status | |---|---| | `online-mode=true` | **Works** (ServerLoginPacketListenerImpl): a 1024-bit RSA key pair at start ("Generating keypair"), the encryption request, the shared secret and challenge, AES/CFB8, and the session service's `hasJoined` check (with the address when `prevent-proxy-connections` is on), with vanilla's log lines and messages. `test_online_mode_parity.py` runs the same logins against vanilla's server and Horizon's with a mock session service. | | Secure chat | **Works** (`SignedMessageChain`, `LastSeenMessagesValidator`, `MessageSignatureCache`): the chat session update and its profile key, checked against the services' `playerCertificateKeys`; signed chat, `say`, `me` and `msg`, relayed with their signatures and last-seen lists; `enforce-secure-profile` (with `online-mode`) refuses unsigned chat; and vanilla's log lines (`[Not Secure]`, the decoder's warnings, the kicks). Offline servers and players without a chat session chat unsigned, as on vanilla. `test_secure_chat_parity.py` runs the same signed and unsigned players against vanilla's server and Horizon's, with test keys and a mock services server. | | Nether and End | **Works**: the server holds a level per dimension, and each player is in its own (portals, `execute in … tp`, respawn). `test_server_dimension_players_parity.py` checks it against vanilla. How it works, its cost and what's left: [server-levels.md](server-levels.md). | | Refused logins | Logged as vanilla does: `Disconnecting (/address): `, then ` (/address) lost connection: `, and the session errors (`Username '' tried to join with an invalid session`, `Couldn't verify username because servers are unavailable`). | | Gameplay for remote players | Checked against vanilla's server with a vanilla-codec client (#484, `tools/test_dedicated_server_parity.py`): a right click with an item on a block uses it once, a dead player's commands run, players on a team without friendly fire don't hurt each other, and a player's projectiles are theirs (their ender pearl takes them). A player's arrow, snowball or egg hits other players like vanilla's, refused by the `pvp` game rule and by teams without friendly fire (`tools/lan_e2e.py` `arrows`; also checked on a dedicated server with two protocol clients, #5785). The recipe book, status effects and block sync while digging (#500) work. Left: a mob a guest kills counts in the host's statistics and advancements, not the guest's (`mob_died` runs as the host). | | Defaults that surprise owners | `white-list=true` is vanilla 26.3's default, so a fresh server refuses everyone until they are added. That matches vanilla, so the first-run flow (section 3) asks about the whitelist up front. | | Management | Only stdin. There is no service, no backups, no status beyond `list`, no restart after a crash, and a server can't be managed while it runs in the background. | | Packaging | The server is the full game client. Resources come from `horizon-prepare`, which needs a JDK and the official launcher's client install, both awkward on a headless VPS. | | Tick times | The dedicated loop never recorded its tick times in the game clock (only the windowed loop did), so `/tick query` on a dedicated server reported 0 ms. Fixed in PR 2b, which the benchmark needs (section 9). | | Scale | Measured against vanilla on equal work (section 9, `benchmarks/server-equal-work-2026-10-17/`): 20 TPS up to 50 bots, 9 to 11 TPS at 100, where vanilla's watchdog stops it. Horizon is ahead with few players and when exploring; with 25 to 50 players near spawn vanilla's tick is shorter. | ### Harnesses on main On the tip of the code PRs (2a to 3, rebased on b4ad6538), `tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage` passed all five. That includes the vanilla protocol client joining Horizon's server and vanilla's from the same world. The full `--changed origin/main` set (309 harnesses, since the PRs touch the client crate) had passed 60 of 60 when it was stopped for disk space; CI runs it on every pull request. ## 2. Architecture: a supervisor and an engine ``` owner ──► horizon-server (CLI, TUI) browser ──► web panel AI ──► MCP (stdio) │ │ │ └────────── control API: HTTP + JSON on 127.0.0.1, token ────────┘ │ horizon-server run (the supervisor: no GPU, no game code) server.toml ──► server.properties ──► │ ◄── stdout: the vanilla log backups, updates, crash restart │ ──► stdin: console commands │ ◄─► engine endpoint: status, TPS/MSPT, players ▼ the engine: horizon-client --dedicated (the game, headless) ``` `horizon-server` is a new crate and binary (`crates/horizon-server`). It is the only program an owner runs. It depends only on the light crates (`horizon-core`, `horizon-protocol`, `horizon-world`, `horizon-bench`) plus `serde`, `toml`, `toml_edit` and `zip`, which are already in the lockfile. It doesn't link wgpu, winit, audio or controller crates. It runs the engine as a child process. The supervisor/engine split stays even after the engine becomes headless, for these reasons: - **Crash restart and diagnostics.** The supervisor outlives an engine crash. It keeps the crash report, restarts the engine with backoff, and the panel stays up to say what happened. - **Safe updates.** An update swaps the engine binary and restarts. If the new engine fails its start check, the supervisor rolls back to the previous one. - **Parity stays cheap.** The engine keeps reading vanilla's own files (`server.properties`, the four JSON lists, `eula.txt`) exactly as `test_dedicated_server_parity.py` checks them today. The clean config is a layer on top and never changes what the engine sees. - **No conflicts.** The supervisor touches none of the game code that the tick and integrated-server work (perf-server-1, perf-ticks-2) are changing. **The engine today** is `horizon-client --dedicated`. It needs one small, additive change: a status endpoint. With `--control-socket /.horizon/engine.json` (the existing control protocol: TCP on 127.0.0.1 plus a token, on every OS), the dedicated loop answers `server-status` with TPS, MSPT (average, P50/P95/P99 from the tick clock `/tick query` uses), players (name, UUID, address, ping, position), loaded chunks and uptime. It answers `console ` with the command's output. **A proxy moving a player between two servers** uses more requests on this endpoint (`lan/arrivals.rs`, `game/dedicated/transfer.rs`). They are a built-in module, **off by default**, that the owner turns on in `server.toml`: ```toml [transfer] enabled = false # true: take a proxy's player-* requests; needs Velocity forwarding (forwarding.secret) expect_seconds = 10 # how long a player the proxy announced is waited for, when it names no time max_expect_seconds = 60 # the longest the proxy may ask for max_expected = 64 # players waited for at once max_freeze_seconds = 30 # the longest a player stays frozen while it is handed over max_hold_seconds = 60 # the longest a player arriving from another server is held before it is dropped ``` The supervisor passes the section to the engine as `--transfers expect_seconds=10,...`, beside `--control-socket`, and not as a `server.properties` key: that file stays vanilla's. The section has nothing to do with vanilla's `accepts-transfers`, which is about the transfer packet a server sends a client. While it is off, every `player-*` request and `transfer-status` are answered `{"error": "transfers are off on this server"}`, the engine keeps no table and does nothing for transfers on a tick. With it on, the engine refuses to start unless Velocity forwarding is on (`forwarding.secret`, [velocity-forwarding.md](velocity-forwarding.md)). The proxy must be the only way in: a player who joined a source server directly would find there the older copy of itself that a hand-over left behind, and items would double. **Who can ask.** The requests do not widen who can reach the engine: they use the control endpoint, a Unix socket or TCP on 127.0.0.1 only (horizon-server starts it on TCP with a token). A proxy on another machine needs something local to each engine to relay for it. The token is all or nothing: whoever can move players can also run any console command. Answers are one JSON line, `{"ok": true, ...}` or `{"error": "..."}`, and a refused request changes nothing. A unique id is written as 32 hexadecimal digits with or without dashes in a request, and as lowercase text with dashes in an answer (`123e4567-e89b-12d3-a456-426614174000`). A hand-over id is 32 lowercase hexadecimal digits. `transfer-status` is what a proxy reads before it sends players to a server. It names no player and changes nothing: ```json {"ok": true, "players": 12, "held": 1, "expected": 2, "frozen": 0, "online": 13, "max_players": 20, "full": false, "stopping": false} ``` `players` are the players placed in the world (a player a `moved` release took out is no longer counted), `held` the logins held for a hand-over, `expected` the expectations still alive, and `frozen` the players this server is handing over. `online` is what the player limit counts: the placed and the held players and the logins still joining. `full` is `online` at `max_players` or above: an ordinary login, held or not, is then refused as `multiplayer.disconnect.server_full`, unless the player is an operator with `bypassesPlayerLimit`. `player-expect` counts the expected players too: it is refused once `online` and `expected` reach `max_players`. `stopping` is true once the server has begun to stop, and no player is taken in any more. A proxy asks it often, so it writes nothing to the log. `player-expect [seconds]` tells the target server that the player is about to log in: within `expect_seconds` by default, `max_expect_seconds` at most (a longer time is cut to it), and at most `max_expected` players are expected at once. The reply is `{"ok": true, "renewed": false, "ttl_seconds": 10}`; asking again for the same player renews the time and says `"renewed": true`. It is refused for a missing or malformed id, a time that is not a whole number of seconds above zero, a player already connected, a full table, a full server (`{"error": "the server is full"}`) and a server that is stopping (`{"error": "the server is stopping"}`). Each expectation holds a place until it is used up or runs out: once the places the player limit counts and those of the other expected players reach `max-players`, a new one is refused as a login would be, so two proxies sending players at once do not fill the server past its limit. As at login, an operator with `bypassesPlayerLimit` is never refused as full. The places are held against other expectations only: an ordinary login (one nobody expected) sees the vanilla limit alone, so it can take a place an expected player was counting on. That player's login is then refused as `server_full`, and the proxy aborts the hand-over on the source, where the player goes on as it was. `full` in `transfer-status` is likewise the vanilla condition alone. The player's next login uses the expectation up as it starts, once the bans, the whitelist and the player limit let it in, so a login still in configuration when the time runs out (a resource pack prompt) keeps it. A login that then fails before it reaches play (its connection drops in configuration, or the client refuses a required pack) gives the expectation back with its own deadline, so the proxy's next attempt within that time is still expected. An expectation no login used is reported in the log when its time runs out. A login that used up an expectation is a *held* player. It gets the whole join sequence and the level around it (chunks, block and light changes, entities, the level's broadcasts), and its acknowledgements are handled (teleport, chunk batch, loaded, keep-alive, ping, tick end, client information), but it is not placed: no join message, no player-list entry for the others, not among the entities they are shown, not simulated, and nothing else it sends is acted on. The world is kept loaded, and generated if need be, around a held player as around a placed one, so a server with nobody else on it sends a held player its chunks. The log says ` is held: it arrives from another server` instead of the join line. A held player nobody takes over is dropped after `max_hold_seconds` (1,200 ticks by default), with a warning, and its departure is logged as ` was dropped while held: `, with no "left the game" line. `player-export` refuses a held player. `player-drop ` forgets the player's expectation, and disconnects the held player without a save or a word to anyone. The reply is `{"ok": true, "held": true, "expected": false}`: whether a held player was disconnected, and whether an expectation was forgotten. It is refused for an id that is neither held nor expected, and leaves a placed player alone. `player-export [freeze]` reads a connected player out of the source server. It first closes the player's open menu as vanilla does when a menu closes, in the player's own level (the cursor stack, a crafting table's grid and the inventory's own 2x2 grid go back into the inventory, a trade back to its villager; the client is told to close it and is sent its inventory), then answers: ```json {"ok": true, "record": { "version": 1, "data_version": 5023, "handover": "9f2c4be0a1d34e6b8c0f1e2d3c4b5a69", "uuid": "123e4567-e89b-12d3-a456-426614174000", "name": "Alex", "dimension": "minecraft:overworld", "position": [10.5, 70.0, -3.25], "rotation": [90.0, 15.0], "velocity": [0.0, 0.0, 0.0], "game_mode": 0, "player": "", "advancements": { }, "stats": {"stats": { }, "DataVersion": 5023} }} ``` `player` is the base64 of the uncompressed named NBT (root name empty) of the player compound: what the server writes to `players/data/.dat` before it gzips it, taken from the connected player at that moment, with the values mods attached to the player. `advancements` and `stats` are the JSON the server writes to `players/advancements/.json` and `players/stats/.json`, or null on a server that keeps none. `version` is the version of this record (1); `data_version` is the world data version of the server that made it (5023 for 26.3). The other fields are a few of the compound's values, for a proxy that does not read NBT. While the player is frozen, the reply also gives `"freeze_ticks_left"` beside the record: the ticks before the hand-over ends by itself, so that a proxy does not commit on the target too late for its release to come in time. How a server reads a record (the target's `player-import`): - A record of another `version`, or of another `data_version` than the server's own, is refused. - The NBT in `player` wins over the plain fields: they are copies of its values, for a proxy. - Fields the reader does not know are ignored, so a later version 1 record may carry more. **The hand-over.** `freeze` starts one: the record gets a `handover` id, which the later requests name, and the player's own inputs (moves, clicks, chat, commands) stop being acted on, while what answers the server (teleport confirmations, chunk batch acknowledgements, keep-alives, pings, tick ends, client information and chat acknowledgements, and the messages a chat packet says the client has seen, in the order they came) still is. A frozen player is not kicked for floating. Every later export of that player, with or without `freeze`, answers with the same record, byte for byte, and does not restart the freeze: a proxy that lost the reply asks again. The hand-over ends after `max_freeze_seconds` (counted in ticks, 600 by default) with a warning in the log, and the id is then forgotten. Without `freeze` the export is a read: `handover` is null and the player goes on. The request is refused for a player who is not connected, is held, has not finished joining, is leaving, is riding, is asleep or is dead. While frozen, the player takes no damage (as vanilla's `Abilities.invulnerable`: the void and `/kill` still kill) and picks nothing up (items, arrows, experience orbs), so its record stays what it is until the release. A player who dies while frozen all the same ends the hand-over, with a warning in the log. `player-release moved [announce]` and `player-release abort` end the hand-over, on the source server. Both name the hand-over the export returned. `moved` takes the player out of the world because another server has it now: the others see its entity and its player-list entry go, nothing is written to its player file or its records (the other server has the player), the log and the `leave` event record the departure with the reason `moved to another server`, and the player's connection is closed with a generic disconnect. The "left the game" line is neither sent nor logged unless `announce` is added. Nothing is deleted: the player's file here stays as it was. `abort` lifts the freeze, and the player goes on as if nothing had happened. `moved` replies `{"ok": true, "released": "moved", "announced": false}` and `abort` replies `{"ok": true, "released": "abort"}`. Both are refused for a player who is not in a hand-over, for another hand-over than the player's current one, and for a player who died while frozen. Once the freeze has run out the hand-over is over, and a late `moved` is refused: the player has played on since, and the record the other server has is older. The proxy then fails the hand-over on the target (`player-drop`). `player-import ` applies a record to the held player `uuid` on the target server, whole or in parts, and lets it into the world: ```json {"record": { ...the record of player-export... }, "parts": ["inventory", "experience"], "announce": true, "place": true} ``` `parts` is optional (all of them by default), `announce` is optional (true by default) and `place` is optional (true by default; see below). The parts, in the order the reply lists them, and what each sets: | part | sets | | --- | --- | | `inventory` | the inventory, armour, off hand and selected slot | | `ender_chest` | the ender chest | | `experience` | the level, progress, total and seed | | `health` | health and absorption, food, saturation, exhaustion and its timer, and the body's air, fire and freezing | | `effects` | the active effects | | `game_mode` | the game mode, flight and flight speed | | `position` | where the player stands, how it looks, whether it is on the ground, its fall and motion, and the vehicle it rode | | `spawn_point` | the respawn point | | `recipe_book` | the recipe book | | `advancements` | the advancements and the statistics | A part that is not asked for keeps what the held player has, which is what this server loaded for it when it logged in: its own file, or a new player's defaults. An imported inventory or ender chest replaces the held player's whole: a slot the record leaves empty is empty afterwards. The keys of the compound that Horizon does not model, the values mods attached to the player, and the last death, the post effects and the credits, are taken only when every part is. Only the compound of the record is read: the fields above it (`position`, `rotation`, `velocity`, `dimension`) are for whoever reads the record. A record is refused, with `{"error": "..."}` and nothing changed, when its `version` is not 1, its `data_version` is not this server's, its `uuid` is not the request's, it has no `handover` id (an export without `freeze`), its compound is not valid base64 NBT, a part's name is unknown, or the player is not held or is leaving. It is refused too when its values are ones no player can have: a position, rotation, motion, health, absorption, saturation, experience progress or fall that is not a number, a position farther than 30,000,512 blocks from the origin (20,000,000 up or down), which vanilla's `Entity.load` would clamp, a health of zero or less, a health over 1,024 or an absorption over 2,048 (the bounds of `max_health` and `max_absorption`), a food exhaustion over 40 (`FoodData.addExhaustion`'s) or an effect amplifier outside 0 to 255. A stack's count out of vanilla's 1 to 99 is read as 1, as for any item. A record whose position is in another dimension than the held player's world is refused when `position` is among the parts: the client is in one dimension and only a login changes it. The record's hand-over is bound to the held player at the import: a second import of the same record is taken (a retry), one of another hand-over is refused, and `player-confirm` and `player-drop` name it. **The commit point.** On success the player is sent what the import changed the way a join sends it (game mode, abilities, held slot, a new position to confirm, the effects, with those it had from this server's own file removed, inventory, recipe book and the player list as it now is). Then, unless `"place": false`, it is placed as `player-confirm` places it: its player file, advancements and statistics are written to disk first, each to a new file that is synced and then renamed into place (on Linux and macOS the folder is synced too), then it is placed: simulated, shown to the others and taking part from the next tick, when its first tick sends its health, experience and advancements as a new player's does. Everyone gets its player-list entry, since everyone will be shown its entity; with `announce` true they also get the join line. The log says ` placed: it has arrived from another server`, and the join line when it is announced. The reply is `{"ok": true, "handover": "...", "parts": [...], "placed": true, "announced": true, "recentered": false}` only once the file is written, so a proxy sends `player-release moved` to the source after this reply: from then on a crash of the target, or a power loss, leaves the player's three files there as it arrived. When one cannot be written, the reply is an error and the player stays held and imported, to be confirmed again or dropped. **A lost reply after the commit.** A `player-import` or `player-confirm` that names the hand-over of a player already placed from it is answered `{"ok": true, "placed": true, ..., "retried": true}`, with nothing done again: a proxy that lost the reply asks again and learns the commit happened. **A refused `moved` after the commit.** The target then has the player placed and on disk, and nothing undoes that: `player-drop` takes only a held player. It happens when the freeze ran out between the confirm and the release (the proxy was late), or when an operator's `/kill` killed the frozen player (nothing else hurts it, and it does not move). The proxy keeps its client on the target and disconnects the source's connection; the source then saves its copy of the player as it is, so the two servers' files differ from that moment. To keep clear of the first case, the proxy confirms only while the export's `freeze_ticks_left` leaves it time to release, and otherwise drops the arrival and aborts. **Where the player arrives.** Only the compound of the record is read, so to put the player somewhere other than the record says (a proxy that knows where its client stands, which the frozen source may not have seen yet), the request takes four optional fields, which win over the compound: ```json {"record": {...}, "position": [300.5, 64.0, 300.5], "rotation": [90.0, 20.0], "on_ground": false, "velocity": [0.0, -0.08, 0.0]} ``` `position` is `[x, y, z]`, `rotation` is `[yaw, pitch]` in degrees, `on_ground` is a boolean and `velocity` is `[x, y, z]` in blocks a tick. The pitch is taken as vanilla's `Entity.setXRot` takes it: modulo 360, then cut to ±90; the yaw is kept as it is. A velocity component over 10 blocks a tick is taken as 0, as `Entity.load` takes a saved `Motion`. The velocity is the server's: the arrival's teleport carries no motion, as a vanilla login's does not, so the client starts still, and since a player's client moves itself, its first move replaces it. They belong to the `position` part: a request that gives one and does not import that part is refused. A position that is not finite, or farther than the record's own may be (30,000,512 blocks from the origin, 20,000,000 up or down), is refused, and so is a rotation or a velocity that is not finite numbers (a rotation past what a float holds too). A record with a vehicle still to restore (`RootVehicle`) puts the player back on it at the vehicle's own place, so a request that names a position for such a record is refused. The border, the blocks and the chunks are not checked, as a vanilla server does not check the place its player file names. The player is teleported to the position (the client confirms a new teleport id), so an anticheat never sees the arrival as a move, however far it is from the export. **The view follows the imported position.** `recentered` says whether the import moved the player to another chunk than the one its view was built around (only possible with the `position` part, and only once the player has been sent chunks). When it did, the server moves the view at once, before the position the client confirms: it sends `SetChunkCacheCenter` for the new chunk and forgets the chunks that are out of reach, as the next tick would have. The chunks around the new place are **not** sent yet: they come one batch at a time with the next ticks, and the client acknowledges each batch. Whoever reads the player's world (a proxy building a view of it) must therefore wait for new chunk batches after a reply with `"recentered": true`, as it waited for the first ones; with `false` the chunks it already has are the ones around the player. **Importing in two steps, so that a hand-over can be cancelled.** With `"place": false` the record is applied and the player's client is sent everything the import changed, but the player stays held: not placed, not simulated, not shown, not announced, and nothing is written. The reply is `{"ok": true, "handover": "...", "parts": [...], "placed": false, "announced": }`. Then either: - `player-confirm ` writes the player's files and places it as `place: true` would have, and announces it if the import's `announce` said so. What the client did since the import was not acted on, so it is sent its position to confirm again and its inventory. Reply `{"ok": true, "placed": true, "announced": true}`. It is refused, with nothing changed, for a player who is not held, is leaving, whose record was not imported, or whose record is of another hand-over. - `player-drop [hand-over]` cancels the arrival: the connection is closed and nothing is saved or said to anyone (the player was never placed, so the world never knew it). Reply `{"ok": true, "held": true, "expected": false}`. With a hand-over id, it must be the imported record's, so a late drop of an older hand-over leaves a newer one alone; before any import there is no id to name, and the drop goes by the unique id alone (a late drop of that kind can still cut a newer held player that was not imported yet, which loses nothing: the source still has the player frozen, and the proxy aborts there). Once dropped, the player can be neither imported nor confirmed. A proxy that fails after a successful `player-import` with `place: false`, and before it has sent its client the first byte of the hand-over, calls `player-drop` and the target is as it was. A proxy that dies in between leaves a held player that is dropped by itself after `max_hold_seconds`, with a warning in the log. **A hand-over, in order.** A proxy moving a player from server A to server B, without a loading screen. Both run with `[transfer]` on and behind the proxy's Velocity forwarding: 1. `player-expect ` on B: B holds the player's next login. 2. `player-export freeze` on A: the record and its `handover` id, and A stops acting on the player's inputs. A lost reply is asked again: the same record comes back. 3. The proxy logs the player in to B on its own connection: B sends the held player the world around the place B loaded for it. 4. `player-import ` on B with `"place": false` and, if the proxy knows where its client stands, the request's `position`, `rotation`, `on_ground` and `velocity`. With `"recentered": true` the proxy waits for B's next chunk batches. 5. The proxy switches its client over to B's connection. If anything fails before the client got the first byte of it, `player-drop ` on B and `player-release abort` on A, and the player goes on on A as before. 6. `player-confirm ` on B: B writes the player's files, then places it. Only after its `ok`, `player-release moved` on A: the player is out of A's world, and A saves nothing of it. Every step that is not taken in time is undone by itself: an expectation after `expect_seconds`, a held player after `max_hold_seconds`, a freeze after `max_freeze_seconds`, each with a warning in the log. A `moved` that comes after the freeze ran out is refused, so the proxy must confirm and release within `max_freeze_seconds` of the export. **A server that stops.** From the `/stop` command (the console's, a player's or the control endpoint's) or a stop signal on, `player-expect`, `player-import` and `player-confirm` are refused `{"error": "the server is stopping"}`: a player must not arrive on a server that is about to close. The proxy drops the held player there and aborts on the source. A retry after the commit is still answered, and `player-export`, `player-release` and `player-drop` stay open: they are the way out. **In the log.** Each `player-*` request writes one line with what became of it: `INFO` and what it did (`player-import Alex (): ok, parts inventory,experience, placed false, announced true, recentered false, hand-over `), or `WARN` and the reason it was refused (`player-export Alex (): refused: that player is riding`). The hand-over's id is in the lines of the export, the import, the confirm, the release and a named drop, so the lines of one hand-over can be found on both servers. Only the ids, the name when the server knows it, and a few words of the outcome are written: never the record or the request's body, which are large and are the player's. A held player has its own lines instead of the join and leave ones: ` is held: it arrives from another server`, ` placed: it has arrived from another server` and ` was dropped while held: `. **The headless engine** comes after perf-ticks-2's work lands: Resources split into shared and per-game, the game built in `Game::new`, the integrated server on its own thread. On that base: 1. The dedicated path skips everything only a window uses: the HUD atlas, item renderer, block-entity and entity models, panorama, fog, music, and mesh tables (perf-ticks-2 already stops server-side meshing). This is the RAM and start-time item. 2. The game moves into a library crate, with the window parts behind a `client` feature, so `horizon-engine` links no wgpu or winit either. Sound and controllers are already optional (the `audio` and `controllers` features, on by default): `horizon-engine` today is the game built without them (section 3). ## 3. Packaging **Binaries.** The release archives hold `horizon-client`, `horizon-ctl`, `horizon-prepare` and `horizon-server`. On Linux the release also has `horizon-server-linux-x86_64.tar.gz`: `horizon-server`, `horizon-prepare` and `horizon-engine`, the game built with `--no-default-features` (no sound, no controllers), which links neither `libasound.so.2` nor `libudev.so.1`. `release.yml` builds it after the client archive (`xtask package-server`) and fails if `tools/check_imports.py --server` finds either library; CI lints the same build. `horizon-server` runs `horizon-engine` when it is beside it or on the PATH, else `horizon-client`. Build it yourself with `cargo build --release -p horizon-client --no-default-features` and copy `target/release/horizon-client` as `horizon-engine`. macOS and Windows have no such libraries to avoid, so they keep the one archive. **Game files: the owner's own copy, as with `prepare`.** Nothing of Mojang's is redistributed and nothing is downloaded on the owner's behalf. `horizon-server` looks for prepared resources in this order: 1. `[engine] resources` in `server.toml`; 2. `resources/` in the server folder; 3. `.local/horizon-client/26.3` beside the engine or up to four folders above it: a release folder, the installer's `game-files` (below), or a checkout. If none is found, `init` says where it looked. Today the owner runs `horizon-prepare --prepare --server-jar PATH` from the release folder (it needs a JDK and the client files, as for playing), or copies a folder prepared on their own computer to the server (`scp -r`). Planned wrappers: - **On this machine:** `horizon-server prepare --server-jar PATH` runs `horizon-prepare` on the owner's own server jar plus their launcher install. - **Prepared elsewhere:** `horizon-server import-resources DIR` copies a folder prepared on the owner's own computer, for example by the launcher, to a headless machine. It first checks the folder: `horizon-resources.json` is there and names Minecraft 26.3, the derived files match their checksums, and the font and texture folders aren't empty; otherwise it lists what is wrong and changes nothing. It copies next to the destination and renames the copy in, so a failure partway keeps the old copy. The destination is the first place the server reads: `[engine] resources` when set, else `resources/` in the server folder when it exists or the server wasn't installed by `install.sh`, else the installer's `game-files/horizon-client/26.3` (where the release's `.local/horizon-client` points). It ends by saying to start or restart the server. A server-only `prepare` (from `server.jar` alone, without the client jar or a JDK) is the follow-up that removes the last Java step. It needs a list of which prepared files the server really reads, and that list comes out of the headless-engine work. **One-command install** (`packaging/server/`): - Linux and macOS: `curl -fsSL https://raw.githubusercontent.com/horizon-rust/horizon/main/packaging/server/install.sh | sh` The script picks the release archive for the OS and architecture (on Linux x86_64 the server archive, on macOS arm64 the game's), downloads it from GitHub Releases, and checks it against the release's signed `SHA256SUMS` when OpenSSL 3 is installed, else against the SHA-256 GitHub publishes for each asset (docs/security.md). It never asks for sudo. Options: `--version vX.Y.Z`, `--dir` (default `~/.local/share/horizon`), `--bin` (default `~/.local/bin`), and `--archive FILE` to install an archive already on the machine (a build of your own; no download and no checksum). A Linux release from before the server archive installs the full game, which links ALSA's and udev's libraries (`libasound.so.2`, `libudev.so.1`); minimal server images often lack them (Debian and Ubuntu: `sudo apt install libasound2 libudev1`, `libasound2t64` on Ubuntu 24.04 and later). Then the script lists any that are missing, `init` warns, and `run` stops at once with what to install, rather than restarting a game that can't load. - Windows: `irm https://raw.githubusercontent.com/horizon-rust/horizon/main/packaging/server/install.ps1 | iex` The script does the same into `%LOCALAPPDATA%\Horizon` (`-Version`, `-Dir`), with junctions instead of links (no admin rights), and adds `bin` to the user's PATH. It finds OpenSSL 3 on the PATH or in Git for Windows to check the signature. - **Layout.** Each release goes to `/releases/` and `/current` points at the one in use, so an update or a rollback is one link. `/horizon-server` and `/horizon-prepare` are two-line launchers that run `current`. The prepared game files live in `/game-files/horizon-client` and each release's `.local/horizon-client` links there, so updates keep them. The script then prints the next steps (`horizon-prepare`, `horizon-server init`). **Docker** (`packaging/server/Dockerfile`, built the same way as the relay's image): a multi-stage build that ends on `debian:bookworm-slim` as user `horizon`, with the server build as `horizon-engine`, so the image needs no ALSA or udev. It uses volume `/data` for the server folder, takes the owner's prepared game files as a read-only mount on `/opt/horizon/.local/horizon-client/26.3`, exposes port `25565/tcp`, and keeps the control API and the panel on 127.0.0.1 inside the container: `docker exec horizon-server status|cmd|backup`. On the first start, `HORIZON_EULA=true` and `HORIZON_WORLD`, `HORIZON_SEED`, `HORIZON_PORT`, `HORIZON_WHITELIST`, `HORIZON_PLAYERS` and `HORIZON_OP` answer `init`'s questions; without the EULA answer the container exits and says why. `docker stop` sends SIGTERM, which saves and stops cleanly (give it `--stop-timeout 180`). The image is published only with Ludovic's OK (it's hosted infrastructure). **Services.** - `horizon-server service install` writes and enables a systemd unit (`--user`, or a system unit with `--system`) on Linux, a launchd agent (`~/Library/LaunchAgents/dev.horizon.server..plist`) on macOS, or a Scheduled Task at logon on Windows (a real Windows service needs a wrapper and comes later). - Each runs `horizon-server run --dir ` through the installer's launcher, so an update applies at the next restart. The supervisor restarts the engine itself, and the service manager restarts the supervisor. `service uninstall` stops and removes it and leaves the server folder alone. - `service print` shows the unit or agent it would write, for owners who'd rather install it by hand. **First run (`horizon-server init`, interactive on a terminal):** 1. **EULA.** It shows the link to https://aka.ms/MinecraftEULA and asks "Do you agree? [y/N]". Only a yes writes `eula=true`. 2. **World.** It asks for the world name (`world`) and an optional seed. An existing world folder, or a vanilla server folder, is detected and kept: its `server.properties` is imported (section 4). 3. **Port.** 25565 by default, checked free right away. 4. **Players.** It asks whether to use a whitelist (yes by default, as vanilla) and who to add first, then offers to make the first player an operator. 5. **Game files.** It finds or explains the prepared resources (see above). 6. It writes `server.toml`, shows the panel address and the commands to start it in the background (`horizon-server start`) or as a service. Every question has a flag (`--eula`, `--world`, `--seed`, `--port`, `--whitelist`/`--no-whitelist`, `--player NAME`, `--op NAME`, `--yes`) and an environment variable for Docker (`HORIZON_EULA`, …; flags win). ## 4. One config file: `server.toml` The owner edits only `server.toml`. The supervisor writes `server.properties` from it before every engine start, so the engine stays exactly vanilla. The file is short: typed sections for what owners change, and a `[properties]` table that passes any other vanilla key through unchanged. ```toml # Horizon server settings (docs/server.md). The server writes them into server.properties before # every start: edit this file, not that one. [server] motd = "A Minecraft Server" port = 25565 bind = "" # listen on every address, or only on this one (server-ip) max_players = 20 online_mode = true # check players' Minecraft accounts (false: anyone joins under any name) whitelist = true # only whitelisted players and operators can join enforce_whitelist = false # kick online players taken off the whitelist view_distance = 10 simulation_distance = 10 [world] name = "world" # the world folder seed = "" # empty: a random seed on the first start game_mode = "survival" # survival, creative, adventure or spectator difficulty = "easy" # peaceful, easy, normal or hard hardcore = false # Any other server.properties key, spelled as vanilla spells it, for example: # spawn-protection = 16 [properties] [engine] path = "" # the game program; empty: the one installed beside horizon-server resources = "" # the prepared game files; empty: resources/ here, else the usual places restart_on_crash = true [backups] every = "6h" # automatic backups while the server runs: 30m, 6h, 1d...; "0" turns them off keep = 12 # automatic backups kept (backups made by hand are never deleted) [updates] keep = 1 # other releases kept by updates, besides the one in use and the one rollback goes to ``` This is the file `init` writes today, and it also writes `[panel]` (`bind = "127.0.0.1:8130"` and `allow_public = false`, section 6), `[api]`, `[transfer]` (off; a proxy's hand-overs, section 2) and `[discord]`. The defaults are vanilla 26.3's (a test checks each one). Unknown keys are errors, as are a typed key set again under `[properties]` and values vanilla would refuse. There is no `backups.before_update` setting: an update always backs up the world first (section 7). - **Import.** `horizon-server init` in a folder with a `server.properties`, or `horizon-server import server.properties`, reads it with vanilla's own parser (`ServerProperties`). Keys with typed fields go into their sections; any other key that differs from vanilla's default goes into `[properties]`. Keys left at their defaults are dropped, so the TOML stays short. The original file is kept as `server.properties.imported`. - **Changes made in game.** The engine writes `server.properties` itself, for example after `/whitelist on`. After it stops, the supervisor compares the file with what it wrote and copies any changed keys back into `server.toml`, so an in-game change survives the next start. Edits go through `toml_edit`, so the owner's comments and order are kept. - **Changes without opening the file.** `horizon-server config set KEY=VALUE...` (the launcher's Servers page uses it) writes through `toml_edit`, checks the result as `server.toml` is checked, and writes nothing if a value is wrong. On a running server it sends what vanilla changes live through its console: `difficulty`, `defaultgamemode` and `whitelist on|off`; `server.motd` and `server.max_players` go to the game as the management protocol's `serversettings/motd/set` and `serversettings/max_players/set` do, so the server list and the next logins use them at once; the backup settings apply at once because the supervisor reads them each time. Everything else waits for the next start, and the command says which. A hot reload of the view distance needs engine support and comes later. - `server.properties`, `ops.json`, `whitelist.json`, `banned-*.json` and `world/` keep vanilla's names and formats. A vanilla server folder works as is, and so does going back to vanilla. ## 5. CLI and TUI ``` horizon-server init first run (section 3) horizon-server run supervisor + engine in the foreground; the console on stdin horizon-server start | stop | restart in the background (detached `run`); start also resumes a stopped supervisor horizon-server status [--json] up?, uptime, TPS, MSPT, players, RAM, CPU, crashes horizon-server cmd one console command, with its output horizon-server console attach: the live log, and send commands (Ctrl-D detaches) horizon-server logs [-f] [-n N] horizon-server op|deop horizon-server whitelist on|off|list|add|remove [player] horizon-server players [--json] who is online, operators, whitelist, bans horizon-server kick|ban [reason] pardon ban-ip [reason] pardon-ip
horizon-server backup [NAME] backups restore [--yes] horizon-server import horizon-server config [--json] config set KEY=VALUE... [--json] horizon-server service install|uninstall|print [--system] horizon-server panel the panel's address and a one-time login link horizon-server update [--check] [--version vX.Y.Z] [--timeout S] rollback [--timeout S] horizon-server update --archive FILE --version NAME an archive you have (your own build) horizon-server mcp MCP server on stdio (section 8) horizon-server import-resources copy game files prepared elsewhere into place (checked first) Planned: horizon-server prepare --server-jar PATH ``` - Every command takes `--dir` (the server folder; default: the current folder). - While the server runs, management commands go through the control API, so the engine applies them as vanilla's console would and its lists stay right. While it's stopped, `op`, `deop`, `whitelist`, `ban`, `pardon`, `ban-ip` and `pardon-ip` edit the vanilla files directly with the same code the engine uses (`horizon_server_files::user_lists`). - **The TUI** is `horizon-server console` (built, `console.rs`): the recent log and then the live one (the control API's event stream), a one-line header (TPS, MSPT, players, RAM) that updates every second, and a command line. It uses plain ANSI with no TUI framework, and falls back to plain lines when stdout isn't a terminal. ## 6. Web panel **Scope (MVP, PR 4):** status (phase, uptime, version, crashes), live TPS, MSPT, RAM and CPU graphs (the last 10 minutes, sampled once a second), players (list with ping, op, kick), the console (live log plus a command line), and backups (list, back up now, restore with confirmation), with restart and stop. The panel lives in the supervisor, so it is up exactly when the server is: starting a stopped server stays a command (or the service manager's job). Whitelist and bans go through the console for now. **Updates:** when a newer release is out, the panel says so with an Update button, which runs the same path as `horizon-server update` (section 7) and then shows how it went. **Later:** bans and IP bans, worlds, `server.properties` import, logs and crash reports, and modpacks (with the modpack work). **Tech:** one HTML page with plain JS and CSS (`crates/horizon-server/panel/`), embedded in the binary with `include_str!`. No build step, no framework, no CDN. It uses Horizon's design system tokens (`horizon-theme`'s colours, light and dark) and draws charts on a canvas. It polls the control API's routes once a second (`status`, `metrics?since=`, `logs?since=`), served by the same small HTTP code on `std::net`, with no async runtime or new dependency. Server-sent events can replace the polling later if a tab ever costs too much. **Auth: local or tailnet only, never an open admin port.** - **Bind.** The panel listens on `127.0.0.1:8130` by default. `panel.bind` can name a tailnet address (100.64.0.0/10 or Tailscale's fd7a:115c:a1e0::/48) or another loopback address. Any other address, such as 0.0.0.0 or a public IP, is refused unless `panel.allow_public = true` is set, and even then the panel logs a warning at every start. - **Who may act.** The API token in `.horizon/api.json` (file mode 0600) is what the CLI and MCP use. Browsers get a one-time login link from `horizon-server panel`: a code good for 10 minutes, swapped for an `HttpOnly; SameSite=Strict` session cookie. Anyone who can read the server folder can manage the server, and no one else can. Sessions end when the supervisor stops. - **Protection.** The `Host` header must name the panel itself: its address, `localhost` on loopback, or a tailnet name (a MagicDNS short name or `*.ts.net`). That stops DNS rebinding. Changes (POST, PATCH, DELETE) need the `X-Horizon: 1` header, which stops CSRF. After 10 failed logins in a minute, logins are refused for a while. The page is served with a strict Content-Security-Policy (nothing from elsewhere) and can't be framed. - **Remote access** goes over Tailscale/SSH (`ssh -L 8130:127.0.0.1:8130 host`), with no TLS or passwords to manage. HTTPS comes for free with `tailscale serve`, and the doc shows how to set it up. ## 7. Backups, updates and crash restart - **Backups.** The supervisor runs `save-off`, then `save-all flush`, then zips the world plus the vanilla files and `server.toml` into `backups/-.zip`, then runs `save-on`. Players stay online. Zip works for everyone, Windows included. It runs on the `every` schedule, on demand and before an update. It keeps the last `keep` automatic backups and never deletes one made by hand. A backup is written to a temporary name and renamed when complete, so a crash never leaves a half-written backup that looks finished. A stopped server is backed up straight from its files. - **Restore.** `restore NAME` takes a file name, a unique prefix, or the name given to `backup` (the newest with it). The server stops. The current world is moved to `backups/replaced-