diff --git a/.dockerignore b/.dockerignore
index 417a1867c..458330c93 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -2,7 +2,6 @@
target/
.local/
**/node_modules/
-website/
benchmarks/
packs/
mods/
diff --git a/.gitattributes b/.gitattributes
index 358aeae7a..f9e1922d7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,5 +2,5 @@
# where Git for Windows' core.autocrlf would check them out with CRLF.
docs/launcher-commands.md text eol=lf
docs/horizon-ctl-commands.md text eol=lf
-website/src/tokens.css text eol=lf
+crates/horizon-theme/tokens.css text eol=lf
docs/api/*-reference.md text eol=lf
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index eff82fa99..b2fd9fa48 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -73,6 +73,42 @@ jobs:
run: |
cargo +stable test --workspace --lib --bins --tests --features horizon-client/mods,horizon-mods/pack
cargo +stable test --workspace --doc --features horizon-client/mods,horizon-mods/pack
+ # The launcher is its own workspace (launcher/Cargo.toml), so verify's cargo runs never build it. A pull request that
+ # changes it or a crate it builds is checked here, and so is every push to main: two pull requests can each pass
+ # alone and break it together (#2059 and the registry ratings did, 2026-10-26).
+ launcher:
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Does this pull request change the launcher or a crate it builds?
+ if: github.event_name == 'pull_request'
+ id: launcher
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+ run: python3 tools/ci/rust_changes.py --launcher "$BASE_SHA" "$HEAD_SHA" >> "$GITHUB_OUTPUT"
+ - name: Install Rust and the headers GPUI links against
+ if: steps.launcher.outputs.required != 'false'
+ run: |
+ sudo apt-get update && sudo apt-get install -y --no-install-recommends libxkbcommon-x11-dev libwayland-dev \
+ libx11-xcb-dev libfontconfig-dev libvulkan-dev libasound2-dev libudev-dev
+ rustup toolchain install stable --profile minimal --component rustfmt --component clippy
+ - uses: Swatinem/rust-cache@v2
+ if: steps.launcher.outputs.required != 'false'
+ with:
+ workspaces: launcher
+ shared-key: launcher
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ - name: Check the launcher's formatting, lint and tests
+ if: steps.launcher.outputs.required != 'false'
+ working-directory: launcher
+ run: |
+ cargo +stable fmt --check
+ cargo +stable clippy --all-targets --locked -- -D warnings
+ cargo +stable test --locked --lib
# Most pull requests leave the harnesses to parity-main, which runs them on main a batch of merges at a time
# (.github/workflows/parity-main.yml; releases wait for it). A pull request still runs them itself when it changes
# a harness, an oracle, a probe or the runner, or carries the run-parity label (run-parity.yml, when it is added).
@@ -108,6 +144,7 @@ jobs:
with:
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
+ full: ${{ contains(github.event.pull_request.labels.*.name, 'full-parity') }}
# Horizon never downloads the game. These jobs need a self-hosted Linux runner
# (label horizon-game) holding the maintainer's own copy: the official launcher's
# game directory in HORIZON_MINECRAFT_DIR and the pinned server jar in
diff --git a/.github/workflows/parity-main.yml b/.github/workflows/parity-main.yml
index 70fb33796..4840b98be 100644
--- a/.github/workflows/parity-main.yml
+++ b/.github/workflows/parity-main.yml
@@ -25,8 +25,8 @@ jobs:
parity-main:
# A Mac mini runner of its own (ludovics-mac-mini-2 holds only this label since 2026-10-26): behind PR parity jobs
# this run waited 2 h while every merge replaced the pending one, and on the release runner a release then waited
- # behind the next run. PR parity jobs have ludovics-mac-mini and the desktop. Not the desktop: a job slowed down
- # because the maintainer came back could time out, and a failure here bisects and comments on merges.
+ # behind the next run. PR parity jobs have ludovics-mac-mini and playhorizon. Not playhorizon: its 4 CPUs
+ # make a core-crate run several times longer, and a failure here bisects and comments on merges.
runs-on: [self-hosted, macOS, horizon-parity-main]
timeout-minutes: 240 # a core-crate batch reruns ~300 harnesses (~60-90 min), a bisect a few rounds of the failures
steps:
diff --git a/.github/workflows/parity.yml b/.github/workflows/parity.yml
index 1fc31d8cb..c850c17aa 100644
--- a/.github/workflows/parity.yml
+++ b/.github/workflows/parity.yml
@@ -1,6 +1,6 @@
name: parity
-# The vanilla harnesses a pull request's changes can affect, on the Mac mini's runner, which holds the maintainer's
-# own Minecraft files (Horizon never downloads the game). Called by ci.yml for pull requests from this repository
+# The vanilla harnesses a pull request's changes can affect, on the Mac mini's runner or playhorizon's, which hold the
+# maintainer's own Minecraft files (Horizon never downloads the game). Called by ci.yml for pull requests from this repository
# and by run-parity.yml when a maintainer labels a fork's pull request run-parity. See docs/release-flow.md.
on:
workflow_call:
@@ -13,6 +13,13 @@ on:
description: The commit to check out and test
type: string
required: true
+ full:
+ description: >-
+ The pull request carries the full-parity label (a change every harness reaches, such as a crate split): it
+ runs on playhorizon's runner only, so the Mac mini's runners stay free for the others. While that runner is
+ busy the job waits for it.
+ type: boolean
+ default: false
permissions:
contents: read
env:
@@ -21,40 +28,53 @@ env:
jobs:
parity:
- runs-on: [self-hosted, horizon-game]
- timeout-minutes: 120 # a change to core crates reruns ~300 harnesses: ~60-90 min on the Mac mini
+ runs-on: ${{ inputs.full && fromJSON('["self-hosted", "horizon-game", "playhorizon"]') || fromJSON('["self-hosted", "horizon-game"]') }}
+ # A change to core crates reruns ~350 harnesses: ~60-90 min on the Mac mini; on playhorizon (4 of its 8 vCPUs, 4
+ # harnesses at a time) up to a few hours, and any pull request's job may land there.
+ timeout-minutes: ${{ inputs.full && 360 || 180 }}
steps:
- uses: actions/checkout@v4
with:
- # The commit the event names: a fork's later pushes need another run-parity label.
+ # The commit the event names: a fork's later pushes need another run-parity label. The next step merges
+ # main into it.
ref: ${{ inputs.head }}
fetch-depth: 0
persist-credentials: false
# Keeps .local/ (parity state, probe builds, oracle results) and target/ between runs.
clean: false
+ - name: The head merged into main (what merging it would land)
+ id: merge
+ env:
+ BASE_SHA: ${{ inputs.base }}
+ HEAD_SHA: ${{ inputs.head }}
+ run: |
+ # Harness fixes and game fixes that reached main since the branch was made then apply here too: a head
+ # tested alone failed harnesses already fixed on main (server_knockback before #2114, mob_ai's heap before
+ # #2270, save_roundtrip before #2212). Selection then compares with this main, so it sees only the pull
+ # request's own changes. A head that conflicts with main is tested alone.
+ set -euo pipefail
+ git merge --abort 2>/dev/null || true
+ git fetch -q --no-tags origin +refs/heads/main:refs/remotes/origin/main
+ main=$(git rev-parse origin/main)
+ if git -c user.name=parity -c user.email=parity@localhost merge -q --no-edit --no-ff "$main" >/dev/null 2>&1; then
+ echo "base=$main" >> "$GITHUB_OUTPUT"
+ echo "Tested: head ${HEAD_SHA:0:9} merged into main ${main:0:9}" | tee -a "$GITHUB_STEP_SUMMARY"
+ else
+ git merge --abort
+ echo "base=$BASE_SHA" >> "$GITHUB_OUTPUT"
+ echo "::warning::head ${HEAD_SHA:0:9} conflicts with main ${main:0:9}: tested alone, without main's fixes"
+ echo "Tested: head ${HEAD_SHA:0:9} alone (it conflicts with main ${main:0:9})" | tee -a "$GITHUB_STEP_SUMMARY"
+ fi
- uses: dtolnay/rust-toolchain@stable
- name: Tools from the runner
run: bash tools/ci/runner-env.sh
- name: Vanilla data, and resources prepared by this preparer
- env:
- BASE_SHA: ${{ inputs.base }}
- run: |
- # main's script: one written before a fix to it left a real .local/horizon-client without sounds.json on
- # the runner, and every later job there failed `subtitle`. A branch that changes the script runs its own.
- set -euo pipefail
- if git rev-parse --verify -q origin/main >/dev/null \
- && git diff --quiet "$(git merge-base "$BASE_SHA" HEAD)" HEAD -- tools/ci/vanilla-data.sh; then
- git show origin/main:tools/ci/vanilla-data.sh > "$RUNNER_TEMP/vanilla-data.sh"
- bash "$RUNNER_TEMP/vanilla-data.sh"
- else
- bash tools/ci/vanilla-data.sh
- fi
+ run: bash tools/ci/vanilla-data.sh
- name: The prepared output is the one the preparer's OUTPUT_VERSION says
env:
- BASE_SHA: ${{ inputs.base }}
+ BASE_SHA: ${{ steps.merge.outputs.base }}
run: |
- # The job runs main's workflow on the head's files: a head made before OUTPUT_VERSION (#1947) has neither
- # the tool nor the number, so there is nothing to check.
+ # A head made before OUTPUT_VERSION (#1947) that conflicts with main has neither the tool nor the number.
if [ ! -f tools/prepare_output.py ] || ! grep -q OUTPUT_VERSION crates/horizon-prepare/src/lib.rs; then
echo "This head's preparer has no OUTPUT_VERSION: nothing to check"
exit 0
@@ -65,47 +85,8 @@ jobs:
- name: The harnesses this change can affect
env:
PARITY_HOSTS: ''
- BASE_SHA: ${{ inputs.base }}
- run: |
- # main's selection (tools/parity.py --changed --list with main's parity.py and parity_reach.py), so a
- # branch made before a better selection landed gets it too; the head's own runner then runs those
- # harnesses. A branch that changes the selection itself selects with its own code.
- set -euo pipefail
- own() { python3 tools/parity.py --changed "$BASE_SHA" --timeout 2400; } # world_spawn takes ~1480 s on a busy runner
- fork_point=$(git merge-base "$BASE_SHA" HEAD)
- if ! git rev-parse --verify -q origin/main >/dev/null || ! git diff --quiet "$fork_point" HEAD -- tools/parity.py tools/parity_reach.py; then
- own
- exit
- fi
- had_reach=$(git ls-files tools/parity_reach.py)
- git show origin/main:tools/parity.py > tools/parity.py
- git show origin/main:tools/parity_reach.py > tools/parity_reach.py
- status=0
- python3 tools/parity.py --changed "$BASE_SHA" --list > .local/parity-selection.txt || status=$?
- git checkout -- tools/parity.py
- if [ -n "$had_reach" ]; then git checkout -- tools/parity_reach.py; else rm -f tools/parity_reach.py; fi
- cat .local/parity-selection.txt
- if [ "$status" != 0 ]; then
- echo "main's selection failed: the head's own selection runs"
- own
- exit
- fi
- names=$(sed '$d' .local/parity-selection.txt | grep -E '^[A-Za-z0-9_#]+$' || true)
- # The summary line says how many would run: a count that doesn't match the names read (a format change)
- # must not let the job pass untested.
- expected=$(tail -1 .local/parity-selection.txt | sed -nE 's/^([0-9]+) of [0-9]+ harnesses would run$/\1/p')
- count=$(printf '%s' "$names" | grep -c . || true)
- if [ -z "$expected" ] || [ "$expected" != "$count" ]; then
- echo "main's selection listed $count names, its summary says '${expected:-?}': the head's own selection runs"
- own
- exit
- fi
- if [ "$count" = 0 ]; then
- echo "Nothing to run."
- exit 0
- fi
- # shellcheck disable=SC2086
- python3 tools/parity.py $names --timeout 2400
+ BASE_SHA: ${{ steps.merge.outputs.base }}
+ run: python3 tools/parity.py --changed "$BASE_SHA" --timeout 2400 # world_spawn takes ~1480 s on a busy runner
- name: Logs of the failed harnesses
if: failure()
uses: actions/upload-artifact@v4
diff --git a/.github/workflows/run-parity.yml b/.github/workflows/run-parity.yml
index a2b8e3291..9089a9a09 100644
--- a/.github/workflows/run-parity.yml
+++ b/.github/workflows/run-parity.yml
@@ -22,3 +22,4 @@ jobs:
with:
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
+ full: ${{ contains(github.event.pull_request.labels.*.name, 'full-parity') }}
diff --git a/AGENTS.md b/AGENTS.md
index dcd4ca595..489a1466b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -10,7 +10,8 @@ Feature โ files โ harness for the most-changed areas: [docs/architecture.md]
`tools/check_public_tree.py` rejects them; `git config core.hooksPath .githooks` runs it on commit.
- **Keep your runs away from real player data.** Any game or launcher you start gets fresh `mktemp -d`
folders in `HORIZON_HOME` (the game's data), `HORIZON_LAUNCHER_HOME`, `XDG_DATA_HOME` and
- `XDG_CONFIG_HOME`, plus `HORIZON_LAUNCHER_NO_SELF_UPDATE=1` and `HORIZON_NO_AUDIO=1`. Never write to
+ `XDG_CONFIG_HOME`, plus `HORIZON_LAUNCHER_NO_SELF_UPDATE=1` and `HORIZON_NO_AUDIO=1`, and, for the
+ launcher, `HORIZON_LAUNCHER_TRASH` and `HORIZON_LAUNCHER_CLIPBOARD` pointing into the scratch home. Never write to
`~/.local/share/{applications,horizon,horizon-launcher}` or `~/.local/bin`.
- **Mark what an agent posts.** A PR body starts with a line naming whose agent opened it and with what.
Ludovic's agents write `> ๐ค Opened by Ludovic's AI agent (Claude), not by Ludovic himself.`, and a
@@ -34,7 +35,9 @@ Game workspace (root `Cargo.toml`); `launcher/` and `crates/horizon-telemetry-se
| Crate | Owns |
|---|---|
-| `horizon-client` | The game: a lib (`src/lib.rs`, ~190 flat modules) and the bin (`src/main.rs` โ `game.rs` + `game/`), plus `horizon-ctl` (`src/bin/horizon-ctl/`). Also the dedicated server (`--dedicated`) |
+| `horizon-client` | The game: a lib (`src/lib.rs`, ~180 flat modules) and the bin (`src/main.rs` โ `game.rs` + `game/`), plus `horizon-ctl` (`src/bin/horizon-ctl/`). Also the dedicated server (`--dedicated`) |
+| `horizon-command` | Command parsing (Brigadier): the vanilla tree, argument types, selectors, suggestions, the tree's network form. Re-exported as `horizon_client::command` |
+| `horizon-client-core` | The client lib's bottom layer: `text.rs`, `lang.rs`, `snbt.rs`, `nbt_path.rs`, `component.rs`, `scoreboard.rs`, `bossbar.rs`, `gamerules.rs`, `block_entity_nbt.rs`, registry/particle/sound tables. Re-exported under the old paths (`horizon_client::text`...) |
| `horizon-world` | Vanilla world data with no gameplay loop: NBT, regions, chunks, `datafix/`, `worldgen/`, `level/` (server-side block behaviour, ticks, redstone), entity physics, items, effects, food, damage |
| `horizon-core` | Simulation primitives: Java `Random`s, `jmath` (HotSpot-exact `Math`), positions, noise, density, paletted storage, `version.rs` (the pinned version) |
| `horizon-protocol` | Network protocol 777: codecs, framing, encryption, `packets/{handshake,status,login,configuration,play}.rs`, `entity_data.rs` |
@@ -54,7 +57,8 @@ Game workspace (root `Cargo.toml`); `launcher/` and `crates/horizon-telemetry-se
Other top-level folders: `tools/` (harnesses and dev scripts), `tests/` (Python unit tests: `python3 -m
unittest discover -s tests`), `mods/horizon/src/test/java/dev/horizonlab/parity/` (Java oracles),
-`website/` (playhorizon.dev; its paths are relative to `website/`), `docs/`, `.github/workflows/`.
+`docs/`, `.github/workflows/`. The website (playhorizon.dev) is the private ludovic111/horizon-site: its build
+reads `README.md`, `launcher/links.json`, `docs/api/`, `roadmap/roadmap.json` and `crates/horizon-theme/tokens.css` from main.
## Build and test fast
@@ -117,16 +121,16 @@ python3 tools/agent_control_e2e.py # horizon-ctl / MCP end to end
| Other entities | L: `entities.rs`, `projectiles.rs`, `arrows.rs`; G: `boats.rs`, `minecarts.rs`, `mounts.rs`, `armor_stands.rs`, `paintings.rs`, `frames.rs`, `fireworks.rs`, `tnt.rs`, `explosion.rs` |
| Player actions | game.rs (`fn use_hand`, `fn use_item`, `fn attack`, `fn tick_mining`, `fn break_block`); G: `hand.rs`, `combat.rs`, `consume.rs`, `potions.rs`, `shield.rs`, `crossbow.rs`, `trident.rs`, `fishing.rs`; L: `motion.rs` + `motion/` (movement), `collisions.rs`, `items.rs`, `item_data.rs` |
| Inventory and containers | L: `menu.rs` (`AbstractContainerMenu.clicked`), `container_screen.rs`, `containers.rs`, `creative.rs`, `crafting.rs`, `recipe_book*.rs`, `stations.rs`, `merchant.rs`; game.rs `fn menu_ops`, `fn click_inventory`; G: `stations.rs`, `trading.rs`, `recipe_book.rs`, `machines.rs` |
-| Commands | parse: L: `command/` (`args.rs`, `selector.rs`, `tree_*.rs`, `vanilla.rs`); run: G: `commands.rs` (dispatch) + `commands/*.rs` (`admin`, `execute`, `items`, `players`, `world_cmds`...); L: `scoreboard_cmd.rs`, `data_cmd.rs`, `nbt_path.rs`; G: `functions.rs`, `command_blocks.rs` |
+| Commands | parse: crate `horizon-command` (`args.rs`, `selector.rs`, `tree_*.rs`, `vanilla.rs`); run: G: `commands.rs` (dispatch) + `commands/*.rs` (`admin`, `execute`, `items`, `players`, `world_cmds`...); L: `scoreboard_cmd.rs`, `data_cmd.rs`; `horizon-client-core`: `nbt_path.rs`, `scoreboard.rs`; G: `functions.rs`, `command_blocks.rs` |
| UI screens | `Screen` enum in game.rs; L: `title.rs` + `title/`, `options_ui.rs`, `multiplayer.rs`, `pack_screen.rs`, `graphics_ui.rs`, `screen_draw.rs`, `ui.rs` (widgets), `hud.rs`, `hud_layout.rs`, `hud_overlays.rs`, `chat.rs`, `tab_list.rs`; G: `startup_menu.rs`, `screens.rs` (pause, death), `options.rs`, `lan_screen.rs`, `chat.rs`, `sign_edit.rs`, `books.rs` |
| Multiplayer client | L: `net.rs` (network thread); G: `remote.rs` (`fn handle_packet`, `fn tick_remote`), `remote_*.rs` (mob data, objects, projectiles, vehicles, stations) |
| LAN host / server side | L: `lan/` (`conn.rs` handshake + login threads, `hub.rs` + `hub/` play state, `chunks.rs`, `entity.rs`, `tracking.rs`, `guest.rs`, `playerdata.rs`); G: `lan.rs` (`LanHost`), `lan_actions.rs` (`fn as_guest`, `fn tick_guests`), `lan_*.rs` per feature, `lan_entities.rs` (tracked entities) |
| Integrated server | G: `integrated.rs` (the server thread), `levels.rs` (one level per dimension, `fn tick_server`), `server_travel.rs` |
| Dedicated server | G: `dedicated.rs`, `dedicated/status.rs`; crates `horizon-server-files`, `horizon-server` |
-| Save and load | L: `save.rs` (level.dat, regions, playerdata), `entity_nbt.rs`, `block_entity_nbt.rs`, `options_file.rs`; G: `saving.rs`, `persist.rs` (entities); `crates/horizon-world/src/{region.rs,nbt.rs,datafix/}` |
+| Save and load | L: `save.rs` (level.dat, regions, playerdata), `entity_nbt.rs`, `options_file.rs`; `horizon-client-core/src/block_entity_nbt.rs`; G: `saving.rs`, `persist.rs` (entities); `crates/horizon-world/src/{region.rs,nbt.rs,datafix/}` |
| Input | game.rs `fn window_event`, `fn key_pressed`, `fn play_mouse`; L: `keybinds.rs`, `keymapping.rs`, `key_names.rs`, `mouse.rs`, `input.rs`, `interaction_input.rs`, `gamepad.rs`, `osk.rs`, `clipboard.rs`; G: `pad.rs`, `pad_menu.rs` |
| Audio | L: `audio.rs` (mixer), `sound_engine.rs`, `sound_events.rs`, `music.rs`, `ambience.rs`; G: `music.rs`, `subtitle_hud.rs` |
-| Resource packs | L: `packs.rs` + `packs/`, `pack_screen.rs`, `atlas_sources.rs`, `sprites.rs`, `mipmap.rs`, `model_library.rs`, `font.rs`, `lang.rs`; crate `horizon-assets`; G: `packs.rs` |
+| Resource packs | L: `packs.rs` + `packs/`, `pack_screen.rs`, `atlas_sources.rs`, `sprites.rs`, `mipmap.rs`, `model_library.rs`, `font.rs`; `horizon-client-core/src/lang.rs`; crate `horizon-assets`; G: `packs.rs` |
| Agent control | L: `control.rs` (socket), `bin/horizon-ctl/`; G: `control.rs`, `agent.rs`, `events.rs`, `ui_control.rs` ([docs/agent-control.md](docs/agent-control.md)) |
| Mods | crate `horizon-mods`; G: `mods.rs`; L: `mod_content.rs`, `mod_list.rs` |
| Horizon extras, settings | L: `extras.rs`, `graphics.rs`, `settings.rs`, `minimap.rs`; G: `extras.rs`, `tweaks.rs`, `options.rs` |
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 21951c083..03f3bd97b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,8 +4,8 @@ Thanks for helping. Horizon is Minecraft: Java Edition 26.3 rewritten in Rust, a
everything is that **it plays exactly like vanilla**. This page is the short version of how we work; questions are
welcome on [Discord](https://discord.gg/HcTeMZxe5E).
-This repository holds the game, the launcher and the website, plus the tools, tests and docs that build, check and
-release them. Anything else (videos, Discord and other community material) lives elsewhere.
+This repository holds the game and the launcher, plus the tools, tests and docs that build, check and release them.
+The website (playhorizon.dev) is built in a separate repository from this one's README, `docs/api/` and roadmap. Anything else (videos, Discord and other community material) lives elsewhere.
**Where to start: [playhorizon.dev/hub](https://playhorizon.dev/hub).** It shows what is being done now and next
([ROADMAP.md](ROADMAP.md) in the repository), the work board, good first tasks, and the forms to report a bug or
diff --git a/Cargo.lock b/Cargo.lock
index 0e93bba0e..0e0a39038 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -216,6 +216,13 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+[[package]]
+name = "beacons"
+version = "0.1.0"
+dependencies = [
+ "horizon-mod-sdk",
+]
+
[[package]]
name = "bit-set"
version = "0.10.0"
@@ -1365,9 +1372,12 @@ dependencies = [
"glam",
"horizon-assets",
"horizon-bench",
+ "horizon-client-core",
+ "horizon-command",
"horizon-core",
"horizon-dualsense",
"horizon-friends",
+ "horizon-hdr",
"horizon-mods",
"horizon-protocol",
"horizon-server-files",
@@ -1395,6 +1405,23 @@ dependencies = [
"zip",
]
+[[package]]
+name = "horizon-client-core"
+version = "0.1.0"
+dependencies = [
+ "horizon-world",
+ "serde_json",
+]
+
+[[package]]
+name = "horizon-command"
+version = "0.1.0"
+dependencies = [
+ "horizon-client-core",
+ "horizon-protocol",
+ "horizon-world",
+]
+
[[package]]
name = "horizon-core"
version = "0.1.0"
@@ -1426,6 +1453,14 @@ dependencies = [
"spake2",
]
+[[package]]
+name = "horizon-hdr"
+version = "0.1.0"
+dependencies = [
+ "ash",
+ "wgpu",
+]
+
[[package]]
name = "horizon-mod-sdk"
version = "0.1.0"
@@ -2962,6 +2997,13 @@ dependencies = [
"objc2-quartz-core 0.3.2",
]
+[[package]]
+name = "recipes"
+version = "1.0.0"
+dependencies = [
+ "horizon-mod-sdk",
+]
+
[[package]]
name = "redox_syscall"
version = "0.4.1"
diff --git a/Cargo.toml b/Cargo.toml
index e4628f962..933901dce 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,45 @@
[workspace]
exclude = ["launcher", "crates/horizon-telemetry-server", "crates/horizon-mod-registry", "third_party/wgpu-hal"]
-members = ["crates/horizon-core", "crates/horizon-dualsense", "crates/horizon-threads", "crates/horizon-world", "crates/horizon-client", "crates/horizon-server-files", "crates/horizon-server", "crates/horizon-bots", "crates/horizon-assets", "crates/horizon-protocol", "crates/horizon-theme", "crates/horizon-prepare", "crates/horizon-telemetry", "crates/horizon-bench", "crates/horizon-friends", "crates/horizon-relay", "crates/horizon-mod-sdk", "crates/horizon-mods", "crates/horizon-mods/tests/guest", "crates/horizon-mods/tests/ui_guest", "crates/cargo-horizon-mod", "crates/horizon-port-pack", "crates/horizon-shaders", "crates/horizon-shader-api", "crates/horizon-release-sign", "crates/horizon-mod-sdk/examples/coords-hud", "crates/horizon-mod-sdk/examples/predator-missile", "crates/horizon-mod-sdk/examples/welcome", "mods/official/fps-overlay", "mods/official/keystrokes", "mods/official/minimap", "mods/official/zoom", "xtask"]
+members = [
+ "crates/horizon-core",
+ "crates/horizon-dualsense",
+ "crates/horizon-threads",
+ "crates/horizon-hdr",
+ "crates/horizon-world",
+ "crates/horizon-client",
+ "crates/horizon-client-core",
+ "crates/horizon-command",
+ "crates/horizon-server-files",
+ "crates/horizon-server",
+ "crates/horizon-bots",
+ "crates/horizon-assets",
+ "crates/horizon-protocol",
+ "crates/horizon-theme",
+ "crates/horizon-prepare",
+ "crates/horizon-telemetry",
+ "crates/horizon-bench",
+ "crates/horizon-friends",
+ "crates/horizon-relay",
+ "crates/horizon-mod-sdk",
+ "crates/horizon-mods",
+ "crates/horizon-mods/tests/guest",
+ "crates/horizon-mods/tests/ui_guest",
+ "crates/cargo-horizon-mod",
+ "crates/horizon-port-pack",
+ "crates/horizon-shaders",
+ "crates/horizon-shader-api",
+ "crates/horizon-release-sign",
+ "crates/horizon-mod-sdk/examples/coords-hud",
+ "crates/horizon-mod-sdk/examples/predator-missile",
+ "crates/horizon-mod-sdk/examples/welcome",
+ "crates/horizon-mod-sdk/examples/beacons",
+ "mods/official/fps-overlay",
+ "mods/official/keystrokes",
+ "mods/official/minimap",
+ "mods/official/zoom",
+ "xtask",
+ "mods/official/recipes",
+]
resolver = "2"
[workspace.package]
diff --git a/ROADMAP.md b/ROADMAP.md
index 4a2b90643..9b82f4fac 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -134,7 +134,7 @@ Better tools for mod makers: a test runner that needs no game window, templates
`cargo horizon-mod test` runs a mod's test scripts against a fake game snapshot ([#1816](https://github.com/ludovic111/horizon/issues/1816)) and, for server mods, scripted server events ([#1837](https://github.com/ludovic111/horizon/issues/1837)); the content template and the guides are merged ([#1859](https://github.com/ludovic111/horizon/issues/1859), [#1810](https://github.com/ludovic111/horizon/issues/1810), [docs/api/stability.md](docs/api/stability.md)). Left: templates for hud, server and machine mods, typed wrappers in the SDK, a frozen 0.1 compatibility mod that every runtime must load, a CI check that fails when a stable reference entry is removed without a new major version, and the SDK on crates.io once the API is stable.
-More: [website/docs/test-a-mod.md](website/docs/test-a-mod.md)
+More: [https://playhorizon.dev/docs/test-a-mod](https://playhorizon.dev/docs/test-a-mod)
@@ -310,7 +310,7 @@ Horizon should run well on small machines: integrated graphics, the Steam Deck,
Partly done: an opt-in 60 FPS cap with fewer workers on battery, Far Detail Reduced for integrated GPUs and animated textures on the GPU (both shipped). Left: measured targets and fixes per class of machine (memory use, worker counts, startup) on a Steam Deck, old Intel and Apple Silicon Macs and 8 GB computers, reported on the Benchmarks page.
-More: [docs/benchmark.md](docs/benchmark.md) ยท [website/docs/performance.md](website/docs/performance.md)
+More: [docs/benchmark.md](docs/benchmark.md) ยท [https://playhorizon.dev/docs/performance](https://playhorizon.dev/docs/performance)
@@ -600,7 +600,9 @@ You can port a mod to Horizon with your own AI agent on your own computer. Horiz
Technical
-A player runs their own agent locally with `horizon-ctl` and the MCP servers ([docs/agent-control.md](docs/agent-control.md)), `cargo horizon-mod`, `horizon-port-pack` and the parity harnesses as the check. Horizon writes the guide ([website/docs/agents.md](website/docs/agents.md), [docs/modpacks.md](docs/modpacks.md)) and runs no agents, accounts or keys for players. The No AI switch turns all of it off.
+A player runs their own agent locally with `horizon-ctl` and the MCP servers ([docs/agent-control.md](docs/agent-control.md)), `cargo horizon-mod`, `horizon-port-pack` and the parity harnesses as the check. Horizon writes the guide (playhorizon.dev/docs/agents, [docs/modpacks.md](docs/modpacks.md)) and runs no agents, accounts or keys for players. The No AI switch turns all of it off.
+
+More: [https://playhorizon.dev/docs/agents](https://playhorizon.dev/docs/agents)
@@ -936,7 +938,9 @@ Run Horizon's built-in benchmark and share the report: every new computer makes
Technical
-`horizon-launcher play --arg=--benchmark --arg=standard` writes a JSON report; `horizon-launcher data benchmark ` shows what would be sent and uploads it ([website/docs/performance.md](website/docs/performance.md)). Results from three installs with the same hardware appear on the Benchmarks page. Example: [#1711](https://github.com/ludovic111/horizon/issues/1711).
+`horizon-launcher play --arg=--benchmark --arg=standard` writes a JSON report; `horizon-launcher data benchmark ` shows what would be sent and uploads it (playhorizon.dev/docs/performance). Results from three installs with the same hardware appear on the Benchmarks page. Example: [#1711](https://github.com/ludovic111/horizon/issues/1711).
+
+More: [https://playhorizon.dev/docs/performance](https://playhorizon.dev/docs/performance)
diff --git a/crates/cargo-horizon-mod/src/check.rs b/crates/cargo-horizon-mod/src/check.rs
index f42674da8..988ba826d 100644
--- a/crates/cargo-horizon-mod/src/check.rs
+++ b/crates/cargo-horizon-mod/src/check.rs
@@ -200,7 +200,7 @@ fn play(path: &Path, report: &mut Report) -> Result<(), String> {
return Err(format!("it didn't start: {reason}"));
}
let client: Vec = mods.commands().map(str::to_owned).collect();
- let server: Vec = mods.server_commands().map(str::to_owned).collect();
+ let server: Vec = mods.server_commands().map(|c| c.name.clone()).collect();
report.commands = [client.clone(), server.clone()].concat();
// A server mod plays with one player on, who joins, chats and leaves.
let steve = ServerPlayer {
@@ -262,9 +262,21 @@ fn play(path: &Path, report: &mut Report) -> Result<(), String> {
format!("{}: {text}", if error { "error" } else { "feedback" })
}
Output::Command { line } => format!("command: /{line}"),
+ Output::QuietCommands { lines, .. } => {
+ format!("{} quiet command(s)", lines.len())
+ }
Output::Stopped { reason, .. } => return Err(format!("it stopped: {reason}")),
+ Output::SetBlocks {
+ dimension, blocks, ..
+ } => {
+ format!("set {} block(s) in {dimension}", blocks.len())
+ }
Output::OpenScreen { .. } => "opened a screen".to_string(),
Output::CloseScreen { .. } => "closed its screen".to_string(),
+ Output::PlaceRecipe { book_id, all } => {
+ format!("placed recipe {book_id}{}", if all { " (all)" } else { "" })
+ }
+ Output::Give { item, count, .. } => format!("gave {count} {item}"),
Output::Shake { strength, seconds } => {
format!("shook the camera: {strength:.2} for {seconds:.1} s")
}
diff --git a/crates/horizon-assets/src/item_model.rs b/crates/horizon-assets/src/item_model.rs
index 5999805eb..d567bc6ac 100644
--- a/crates/horizon-assets/src/item_model.rs
+++ b/crates/horizon-assets/src/item_model.rs
@@ -1031,19 +1031,22 @@ pub struct ItemModels {
}
impl ItemModels {
- pub fn components(&self, stack: &StackView) -> Components {
- let mut out = self
- .prototypes
- .get(&stack.item)
- .cloned()
- .unwrap_or_default();
+ /// The stack's components: its item's defaults with the stack's patch on top. A stack
+ /// with no patch (most stacks a screen draws) borrows the defaults instead of copying them.
+ pub fn components(&self, stack: &StackView) -> std::borrow::Cow<'_, Components> {
+ static NONE: Components = BTreeMap::new();
+ let prototype = self.prototypes.get(&stack.item).unwrap_or(&NONE);
+ if stack.patch.is_empty() {
+ return std::borrow::Cow::Borrowed(prototype);
+ }
+ let mut out = prototype.clone();
for (key, value) in &stack.patch {
match value {
Some(v) => out.insert(key.clone(), v.clone()),
None => out.remove(key),
};
}
- out
+ std::borrow::Cow::Owned(out)
}
/// `ItemModelResolver.updateForTopItem`.
pub fn resolve(&self, stack: &StackView, ctx: &Context, env: &dyn ItemEnv) -> ResolvedItem {
diff --git a/crates/horizon-client-core/Cargo.toml b/crates/horizon-client-core/Cargo.toml
new file mode 100644
index 000000000..8809a5216
--- /dev/null
+++ b/crates/horizon-client-core/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "horizon-client-core"
+version = "0.1.0"
+edition.workspace = true
+license.workspace = true
+rust-version = "1.90"
+description = "The client's lowest layer: chat text and translations, SNBT and NBT paths, the scoreboard, boss bars, game rules and the registry and particle tables commands name"
+
+[dependencies]
+horizon-world = { path = "../horizon-world" }
+serde_json = { version = "1.0.151", features = ["raw_value"] }
+
+[lints]
+workspace = true
diff --git a/crates/horizon-client/src/block_entity_nbt.rs b/crates/horizon-client-core/src/block_entity_nbt.rs
similarity index 97%
rename from crates/horizon-client/src/block_entity_nbt.rs
rename to crates/horizon-client-core/src/block_entity_nbt.rs
index 54d230eb4..6e214fd61 100644
--- a/crates/horizon-client/src/block_entity_nbt.rs
+++ b/crates/horizon-client-core/src/block_entity_nbt.rs
@@ -259,7 +259,7 @@ fn is_pos(tag: &Tag) -> bool {
matches!(tag, Tag::IntArray(v) if v.len() == 3)
}
/// The loaded `SignText` of one side, or the empty text.
-pub(crate) fn sign_side(tag: Option<&Tag>) -> Tag {
+pub fn sign_side(tag: Option<&Tag>) -> Tag {
let empty = || string("");
let mut messages: Vec = match tag.and_then(|t| t.get("messages")) {
Some(Tag::List(list)) => list.iter().filter_map(component).collect(),
@@ -664,7 +664,9 @@ pub fn canonical(tag: &Tag) -> Option {
}
"minecraft:trial_spawner" => {
// `TrialSpawnerStateData.Packed` and `FullConfig`: every key is optional
- // and defaulted by vanilla; they are kept as loaded.
+ // and defaulted by vanilla; they are kept as loaded. No `spawn_data` is
+ // added: an absent one loads as Optional.empty and is not stored, and
+ // an empty entity would keep the spawner from ever picking a mob.
if let Tag::Compound(c) = tag {
for (k, v) in c {
let key = k.to_string_lossy();
@@ -676,12 +678,6 @@ pub fn canonical(tag: &Tag) -> Option {
}
}
}
- if !f.out.contains_key(&"spawn_data".into()) {
- f.put(
- "spawn_data",
- Tag::compound([("entity", Tag::Compound(Compound::new()))]),
- );
- }
}
"minecraft:vault" => {
// `VaultConfig.DEFAULT` (when the config is absent): the trial key and the
@@ -827,6 +823,21 @@ mod tests {
canonical(&snbt(s)).expect("known type")
}
+ #[test]
+ fn a_trial_spawner_without_spawn_data_saves_none() {
+ let fresh = canon(
+ r#"{id:"minecraft:trial_spawner",x:1,y:2,z:3,normal_config:"minecraft:trial_chamber/ranged/skeleton/normal"}"#,
+ );
+ assert_eq!(fresh.get("spawn_data"), None);
+ let picked = canon(
+ r#"{id:"minecraft:trial_spawner",x:1,y:2,z:3,spawn_data:{entity:{id:"minecraft:skeleton"}}}"#,
+ );
+ assert_eq!(
+ picked.get("spawn_data"),
+ Some(&snbt(r#"{entity:{id:"minecraft:skeleton"}}"#))
+ );
+ }
+
#[test]
fn every_type_has_defaults() {
for id in TYPES.iter().chain(NEWEST.iter()) {
diff --git a/crates/horizon-client/src/bossbar.rs b/crates/horizon-client-core/src/bossbar.rs
similarity index 100%
rename from crates/horizon-client/src/bossbar.rs
rename to crates/horizon-client-core/src/bossbar.rs
diff --git a/crates/horizon-client/src/component.rs b/crates/horizon-client-core/src/component.rs
similarity index 99%
rename from crates/horizon-client/src/component.rs
rename to crates/horizon-client-core/src/component.rs
index fced49898..5b828b305 100644
--- a/crates/horizon-client/src/component.rs
+++ b/crates/horizon-client-core/src/component.rs
@@ -252,7 +252,7 @@ pub fn to_text_with(
} else if let Some(sel) = o.get("selector").and_then(Value::as_str) {
resolve(sel)
} else if let Some(key) = o.get("keybind").and_then(Value::as_str) {
- crate::keybinds::display_name(key)
+ crate::key_display::display_name(key)
} else {
Text::empty()
};
diff --git a/crates/horizon-client/src/fastutil_order.rs b/crates/horizon-client-core/src/fastutil_order.rs
similarity index 100%
rename from crates/horizon-client/src/fastutil_order.rs
rename to crates/horizon-client-core/src/fastutil_order.rs
diff --git a/crates/horizon-client/src/gamerules.rs b/crates/horizon-client-core/src/gamerules.rs
similarity index 90%
rename from crates/horizon-client/src/gamerules.rs
rename to crates/horizon-client-core/src/gamerules.rs
index 7198fd202..6715e01ec 100644
--- a/crates/horizon-client/src/gamerules.rs
+++ b/crates/horizon-client-core/src/gamerules.rs
@@ -292,27 +292,4 @@ mod tests {
assert_eq!(GameRules::load(&dir), rules);
let _ = fs::remove_dir_all(dir);
}
- /// The world's save (Level.write) writes the rules as they are now, and a
- /// world opened again reads them back (#74).
- #[test]
- fn level_save_keeps_changed_rules() {
- let dir =
- std::env::temp_dir().join(format!("horizon-gamerules-level-{}", std::process::id()));
- let _ = fs::remove_dir_all(&dir);
- let mut level = crate::save::Level::default();
- level.write(&dir).unwrap();
- // Rules changed while playing, then saved and loaded again.
- let mut rules = GameRules::load(&dir);
- assert_eq!(rules, GameRules::default());
- assert!(rules.set("advance_time", Value::Bool(false)));
- assert!(rules.set("advance_weather", Value::Bool(false)));
- assert!(rules.set("random_tick_speed", Value::Int(0)));
- level.game_rules = rules.by_name();
- level.write(&dir).unwrap();
- assert_eq!(GameRules::load(&dir), rules);
- let read = crate::save::Level::read(&dir).unwrap();
- assert_eq!(read.game_rules, rules.by_name());
- assert_eq!(read.game_rule("advance_time"), 0);
- let _ = fs::remove_dir_all(dir);
- }
}
diff --git a/crates/horizon-client-core/src/identifier.rs b/crates/horizon-client-core/src/identifier.rs
new file mode 100644
index 000000000..1e76f7731
--- /dev/null
+++ b/crates/horizon-client-core/src/identifier.rs
@@ -0,0 +1,18 @@
+//! Resource identifiers (`Identifier`).
+
+/// Identifier.parse: `ns:path` or `path`, validated.
+pub fn parse_identifier(raw: &str) -> Option {
+ let (ns, path) = match raw.split_once(':') {
+ Some(("", path)) => ("minecraft", path),
+ Some((ns, path)) => (ns, path),
+ None => ("minecraft", raw),
+ };
+ let ns_ok = ns != ".."
+ && ns
+ .chars()
+ .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || matches!(c, '_' | '.' | '-'));
+ let path_ok = path.chars().all(|c| {
+ c.is_ascii_lowercase() || c.is_ascii_digit() || matches!(c, '_' | '.' | '-' | '/')
+ });
+ (ns_ok && path_ok).then(|| format!("{ns}:{path}"))
+}
diff --git a/crates/horizon-client-core/src/key_display.rs b/crates/horizon-client-core/src/key_display.rs
new file mode 100644
index 000000000..fc57c97bd
--- /dev/null
+++ b/crates/horizon-client-core/src/key_display.rs
@@ -0,0 +1,38 @@
+//! Key display names (`InputConstants.Key.getDisplayName`), shared by key
+//! mappings and `keybind` text components.
+use crate::text::Text;
+
+/// InputConstants.Key.getDisplayName: one-character keys as the upper-case
+/// character, others by translation.
+pub fn display_name(key: &str) -> Text {
+ if let Some(rest) = key.strip_prefix("key.keyboard.")
+ && rest.chars().count() == 1
+ {
+ let c = rest.to_uppercase();
+ return Text::literal(c);
+ }
+ let symbol = match key {
+ "key.keyboard.minus" => Some("-"),
+ "key.keyboard.equal" => Some("="),
+ "key.keyboard.left.bracket" => Some("["),
+ "key.keyboard.right.bracket" => Some("]"),
+ "key.keyboard.backslash" => Some("\\"),
+ "key.keyboard.semicolon" => Some(";"),
+ "key.keyboard.apostrophe" => Some("'"),
+ "key.keyboard.grave.accent" => Some("`"),
+ "key.keyboard.comma" => Some(","),
+ "key.keyboard.period" => Some("."),
+ "key.keyboard.slash" => Some("/"),
+ _ => None,
+ };
+ if let Some(s) = symbol {
+ return Text::literal(s);
+ }
+ if let Some(n) = key.strip_prefix("key.mouse.")
+ && n.parse::().is_ok()
+ && !crate::lang::has(key)
+ {
+ return Text::translate("key.mouse", &[Text::literal(n)]);
+ }
+ Text::translate(key, &[])
+}
diff --git a/crates/horizon-client/src/lang.rs b/crates/horizon-client-core/src/lang.rs
similarity index 96%
rename from crates/horizon-client/src/lang.rs
rename to crates/horizon-client-core/src/lang.rs
index cb96cc373..6213cedc8 100644
--- a/crates/horizon-client/src/lang.rs
+++ b/crates/horizon-client-core/src/lang.rs
@@ -42,8 +42,12 @@ struct Bundled;
impl ResourceSource for Bundled {
fn read(&self, path: &str) -> Option> {
let body = match path {
- "assets/horizon/lang/en_us.json" => include_str!("../assets/horizon/lang/en_us.json"),
- "assets/horizon/lang/ru_ru.json" => include_str!("../assets/horizon/lang/ru_ru.json"),
+ "assets/horizon/lang/en_us.json" => {
+ include_str!("../../horizon-client/assets/horizon/lang/en_us.json")
+ }
+ "assets/horizon/lang/ru_ru.json" => {
+ include_str!("../../horizon-client/assets/horizon/lang/ru_ru.json")
+ }
_ => return None,
};
Some(body.as_bytes().to_vec())
diff --git a/crates/horizon-client-core/src/lib.rs b/crates/horizon-client-core/src/lib.rs
new file mode 100644
index 000000000..ca40141d1
--- /dev/null
+++ b/crates/horizon-client-core/src/lib.rs
@@ -0,0 +1,23 @@
+//! The client's lowest layer, below commands and gameplay: chat text and
+//! translations, SNBT and NBT paths, text components, the scoreboard, boss
+//! bars, game rules, block entity NBT tables, and the registry, particle and
+//! sound source tables commands name. horizon-client re-exports each module
+//! under its old path (`horizon_client::text`, ...).
+#![forbid(unsafe_code)]
+pub mod block_entity_nbt;
+pub mod bossbar;
+pub mod component;
+pub mod fastutil_order;
+pub mod gamerules;
+pub mod identifier;
+pub mod key_display;
+pub mod lang;
+pub mod nbt_path;
+pub mod particle_type;
+pub mod registries;
+pub mod scoreboard;
+pub mod snbt;
+pub mod sound_source;
+pub mod text;
+pub mod uuid;
+pub type Result = std::result::Result>;
diff --git a/crates/horizon-client/src/nbt_path.rs b/crates/horizon-client-core/src/nbt_path.rs
similarity index 100%
rename from crates/horizon-client/src/nbt_path.rs
rename to crates/horizon-client-core/src/nbt_path.rs
diff --git a/crates/horizon-client-core/src/particle_type.rs b/crates/horizon-client-core/src/particle_type.rs
new file mode 100644
index 000000000..98de2380b
--- /dev/null
+++ b/crates/horizon-client-core/src/particle_type.rs
@@ -0,0 +1,209 @@
+//! Particle types (`ParticleTypes`): the vanilla particle types with a client
+//! implementation, by registry name, and their per-type flags.
+
+macro_rules! particle_types {
+ ($($variant:ident = $name:literal),* $(,)?) => {
+ /// Vanilla particle types with a client implementation here.
+ #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+ pub enum ParticleType { $($variant),* }
+ impl ParticleType {
+ pub const ALL: &'static [ParticleType] = &[$(ParticleType::$variant),*];
+ /// Registry path (`minecraft:`), also the sprite-set file name.
+ pub fn name(self) -> &'static str {
+ match self { $(ParticleType::$variant => $name),* }
+ }
+ pub fn from_name(name: &str) -> Option {
+ let name = name.strip_prefix("minecraft:").unwrap_or(name);
+ match name { $($name => Some(ParticleType::$variant),)* _ => None }
+ }
+ }
+ };
+}
+particle_types! {
+ Block = "block",
+ BlockCrumble = "block_crumble",
+ Trail = "trail",
+ DustPillar = "dust_pillar",
+ FallingDust = "falling_dust",
+ Smoke = "smoke",
+ LargeSmoke = "large_smoke",
+ WhiteSmoke = "white_smoke",
+ Flame = "flame",
+ SoulFireFlame = "soul_fire_flame",
+ CopperFireFlame = "copper_fire_flame",
+ SmallFlame = "small_flame",
+ Lava = "lava",
+ DrippingWater = "dripping_water",
+ FallingWater = "falling_water",
+ DrippingLava = "dripping_lava",
+ FallingLava = "falling_lava",
+ LandingLava = "landing_lava",
+ DrippingHoney = "dripping_honey",
+ FallingHoney = "falling_honey",
+ LandingHoney = "landing_honey",
+ FallingNectar = "falling_nectar",
+ FallingSporeBlossom = "falling_spore_blossom",
+ SporeBlossomAir = "spore_blossom_air",
+ DrippingObsidianTear = "dripping_obsidian_tear",
+ FallingObsidianTear = "falling_obsidian_tear",
+ LandingObsidianTear = "landing_obsidian_tear",
+ DrippingDripstoneWater = "dripping_dripstone_water",
+ FallingDripstoneWater = "falling_dripstone_water",
+ DrippingDripstoneLava = "dripping_dripstone_lava",
+ FallingDripstoneLava = "falling_dripstone_lava",
+ Splash = "splash",
+ Rain = "rain",
+ Bubble = "bubble",
+ SulfurBubbles = "sulfur_bubbles",
+ BubblePop = "bubble_pop",
+ BubbleColumnUp = "bubble_column_up",
+ CurrentDown = "current_down",
+ Underwater = "underwater",
+ Portal = "portal",
+ ReversePortal = "reverse_portal",
+ Enchant = "enchant",
+ Nautilus = "nautilus",
+ VaultConnection = "vault_connection",
+ Crit = "crit",
+ EnchantedHit = "enchanted_hit",
+ DamageIndicator = "damage_indicator",
+ Heart = "heart",
+ AngryVillager = "angry_villager",
+ HappyVillager = "happy_villager",
+ Composter = "composter",
+ Mycelium = "mycelium",
+ Dolphin = "dolphin",
+ EggCrack = "egg_crack",
+ Poof = "poof",
+ Explosion = "explosion",
+ ExplosionEmitter = "explosion_emitter",
+ CampfireCosySmoke = "campfire_cosy_smoke",
+ CampfireSignalSmoke = "campfire_signal_smoke",
+ Note = "note",
+ Dust = "dust",
+ TotemOfUndying = "totem_of_undying",
+ Firework = "firework",
+ EndRod = "end_rod",
+ Ash = "ash",
+ WhiteAsh = "white_ash",
+ CrimsonSpore = "crimson_spore",
+ WarpedSpore = "warped_spore",
+ CherryLeaves = "cherry_leaves",
+ PaleOakLeaves = "pale_oak_leaves",
+ TintedLeaves = "tinted_leaves",
+ Effect = "effect",
+ InstantEffect = "instant_effect",
+ EntityEffect = "entity_effect",
+ Witch = "witch",
+ Infested = "infested",
+ Cloud = "cloud",
+ Sneeze = "sneeze",
+ Snowflake = "snowflake",
+ Soul = "soul",
+ SculkSoul = "sculk_soul",
+ DragonBreath = "dragon_breath",
+ Gust = "gust",
+ SmallGust = "small_gust",
+ GustEmitterLarge = "gust_emitter_large",
+ GustEmitterSmall = "gust_emitter_small",
+ DustColorTransition = "dust_color_transition",
+ SculkCharge = "sculk_charge",
+ SculkChargePop = "sculk_charge_pop",
+ Shriek = "shriek",
+ SonicBoom = "sonic_boom",
+ Vibration = "vibration",
+ SweepAttack = "sweep_attack",
+ Glow = "glow",
+ WaxOn = "wax_on",
+ WaxOff = "wax_off",
+ ElectricSpark = "electric_spark",
+ Scrape = "scrape",
+ SquidInk = "squid_ink",
+ GlowSquidInk = "glow_squid_ink",
+ Item = "item",
+ ItemSlime = "item_slime",
+ ItemSnowball = "item_snowball",
+ ItemCobweb = "item_cobweb",
+ SulfurCubeGoo = "sulfur_cube_goo",
+ Flash = "flash",
+ Firefly = "firefly",
+ TrialSpawnerDetection = "trial_spawner_detection",
+ TrialSpawnerDetectionOminous = "trial_spawner_detection_ominous",
+ TrialOmen = "trial_omen",
+ RaidOmen = "raid_omen",
+ OminousSpawning = "ominous_spawning",
+ Spit = "spit",
+ Fishing = "fishing",
+ DustPlume = "dust_plume",
+ RedPoplarLeaves = "red_poplar_leaves",
+ OrangePoplarLeaves = "orange_poplar_leaves",
+ YellowPoplarLeaves = "yellow_poplar_leaves",
+ PauseMobGrowth = "pause_mob_growth",
+ ResetMobGrowth = "reset_mob_growth",
+ BlockMarker = "block_marker",
+}
+impl ParticleType {
+ /// `ParticleType.getOverrideLimiter` (`ParticleTypes.register(name, true)`):
+ /// spawned regardless of distance.
+ pub fn override_limiter(self) -> bool {
+ matches!(
+ self,
+ Self::BlockMarker
+ | Self::DamageIndicator
+ | Self::ExplosionEmitter
+ | Self::Explosion
+ | Self::Gust
+ | Self::GustEmitterLarge
+ | Self::GustEmitterSmall
+ | Self::SonicBoom
+ | Self::SculkCharge
+ | Self::SculkChargePop
+ | Self::Vibration
+ | Self::Poof
+ | Self::Spit
+ | Self::SquidInk
+ | Self::SweepAttack
+ | Self::CampfireCosySmoke
+ | Self::CampfireSignalSmoke
+ | Self::GlowSquidInk
+ | Self::Glow
+ | Self::WaxOn
+ | Self::WaxOff
+ | Self::ElectricSpark
+ | Self::Scrape
+ | Self::TrialSpawnerDetection
+ | Self::TrialSpawnerDetectionOminous
+ | Self::VaultConnection
+ | Self::OminousSpawning
+ )
+ }
+ /// `SingleQuadParticle.Layer.translucent`: types whose vanilla particle class
+ /// hardcodes the translucent layer, drawn after translucent terrain.
+ /// `TerrainParticle`, `BreakingItemParticle` and `BlockMarker` resolve their
+ /// layer from the sprite instead (`Layer.bySprite`); see the `translucent`
+ /// sprite set on the engine.
+ pub fn translucent_layer(self) -> bool {
+ match self {
+ // CampfireSmokeParticle.
+ Self::CampfireCosySmoke | Self::CampfireSignalSmoke
+ // PlayerCloudParticle.
+ | Self::Cloud | Self::Sneeze
+ // SpellParticle.
+ | Self::Effect | Self::InstantEffect | Self::EntityEffect
+ | Self::Witch | Self::Infested | Self::TrialOmen | Self::RaidOmen
+ // EmissiveRisingParticle.
+ | Self::Soul | Self::SculkSoul
+ // SculkChargeParticle, SculkChargePopParticle, ShriekParticle,
+ // VibrationSignalParticle, FireflyParticle, OverlayParticle.
+ | Self::SculkCharge | Self::SculkChargePop | Self::Shriek
+ | Self::Vibration | Self::Firefly | Self::Flash
+ // SimpleAnimatedParticle and its subclasses: EndRodParticle,
+ // SparkParticle (firework), SquidInkParticle, TotemParticle.
+ | Self::EndRod | Self::Firework | Self::SquidInk | Self::GlowSquidInk
+ | Self::TotemOfUndying
+ // FlyTowardsPositionParticle: its LifetimeAlpha(0, 0.6, 0.25, 1) is not opaque.
+ | Self::VaultConnection => true,
+ _ => false,
+ }
+ }
+}
diff --git a/crates/horizon-client-core/src/registries.rs b/crates/horizon-client-core/src/registries.rs
new file mode 100644
index 000000000..310115cf8
--- /dev/null
+++ b/crates/horizon-client-core/src/registries.rs
@@ -0,0 +1,188 @@
+//! Registry contents and source state that commands validate and complete
+//! arguments against (what the server's registry access holds).
+use std::collections::BTreeMap;
+
+/// Registry contents and source state used to validate and complete arguments.
+#[derive(Clone, Debug, Default)]
+pub struct Registries {
+ /// Permission level of the command source.
+ pub permission: u8,
+ pub items: Vec,
+ pub item_tags: Vec,
+ /// Block id -> (property, allowed values).
+ pub blocks: BTreeMap)>>,
+ pub block_tags: Vec,
+ /// Entity types that `summon` can create.
+ pub summonable: Vec,
+ /// Every entity type (selector `type=`).
+ pub entity_types: Vec,
+ pub effects: Vec,
+ pub enchantments: Vec,
+ pub structures: Vec,
+ pub biomes: Vec,
+ pub dimensions: Vec,
+ pub clocks: Vec,
+ pub timelines: Vec,
+ pub time_markers: Vec,
+ pub advancements: Vec,
+ /// Game rule name -> integer-valued.
+ pub game_rules: Vec<(String, bool)>,
+ pub players: Vec,
+ /// Scoreboard objective names, team names and tracked score holders.
+ pub objectives: Vec,
+ pub teams: Vec,
+ pub tracked: Vec,
+ /// Loaded datapack functions (`ns:path`) and function tags (`ns:path`).
+ pub functions: Vec,
+ /// `/data ... storage` ids.
+ pub storages: Vec,
+ /// Boss bar ids and datapack predicate ids.
+ pub bossbars: Vec,
+ pub predicates: Vec,
+ pub item_modifiers: Vec,
+ pub schedules: Vec,
+ pub stopwatches: Vec,
+ pub recipes: Vec,
+ pub sounds: Vec,
+ pub damage_types: Vec,
+ pub attributes: Vec,
+ pub loot_tables: Vec,
+ pub templates: Vec,
+ pub random_sequences: Vec,
+ pub datapacks_enabled: Vec,
+ pub datapacks_disabled: Vec,
+ pub function_tags: Vec,
+ /// The block the source is looking at (relevant coordinates).
+ pub target_block: Option<[i32; 3]>,
+ /// Every registry's element and tag ids (`minecraft:item` -> ...), as
+ /// the server's registry access and reloadable registries hold them.
+ pub by_registry: BTreeMap,
+ /// Blocks whose default state has a block entity.
+ pub block_entities: std::collections::BTreeSet,
+ /// Block tag -> member blocks.
+ pub block_tag_members: BTreeMap>,
+ /// Data component types with a codec (not transient).
+ pub persistent_components: Vec,
+ /// Recipes `/recipe` can give (not special).
+ pub learnable_recipes: Vec,
+ /// Advancement id -> criterion names.
+ pub advancement_criteria: BTreeMap>,
+ /// World clock -> time markers shown in commands.
+ pub clock_time_markers: BTreeMap>,
+ /// Trigger objectives the source may use (`/trigger` suggestions).
+ pub trigger_objectives: Vec,
+ /// Objectives with the `trigger` criterion -> holder -> whether its score is locked.
+ pub trigger_scores: BTreeMap>,
+}
+/// The ids and tag ids of one registry.
+#[derive(Clone, Debug, Default)]
+pub struct RegistryIds {
+ pub ids: Vec,
+ pub tags: Vec,
+}
+const EMPTY: &[String] = &[];
+impl Registries {
+ /// Fill what the game did not build itself from vanilla's exported
+ /// registries (`command-registries.json`, written by
+ /// `VanillaCommandParseOracle registries`): built-in registries such as
+ /// mob effects, data component types and dialogs, block entities and tag
+ /// members. Registries that data packs reload stay with the game.
+ pub fn fill_from_export(&mut self, r: &serde_json::Value) {
+ fn strings(v: &serde_json::Value) -> Vec {
+ v.as_array()
+ .map(|a| {
+ a.iter()
+ .filter_map(|x| x.as_str().map(str::to_owned))
+ .collect()
+ })
+ .unwrap_or_default()
+ }
+ let fill = |field: &mut Vec, key: &str| {
+ if field.is_empty() {
+ *field = strings(&r[key]);
+ }
+ };
+ fill(&mut self.effects, "effects");
+ fill(&mut self.enchantments, "enchantments");
+ fill(&mut self.attributes, "attributes");
+ fill(&mut self.damage_types, "damage_types");
+ fill(&mut self.templates, "templates");
+ fill(&mut self.persistent_components, "persistent_components");
+ fill(&mut self.learnable_recipes, "learnable_recipes");
+ const RELOADED: [&str; 5] = [
+ "minecraft:advancement",
+ "minecraft:recipe",
+ "minecraft:loot_table",
+ "minecraft:predicate",
+ "minecraft:item_modifier",
+ ];
+ for (name, entry) in r["by_registry"].as_object().into_iter().flatten() {
+ if RELOADED.contains(&name.as_str()) || self.by_registry.contains_key(name) {
+ continue;
+ }
+ self.by_registry.insert(
+ name.clone(),
+ RegistryIds {
+ ids: strings(&entry["ids"]),
+ tags: strings(&entry["tags"]),
+ },
+ );
+ }
+ if self.block_entities.is_empty() {
+ self.block_entities = strings(&r["block_entities"]).into_iter().collect();
+ }
+ if self.block_tag_members.is_empty() {
+ for (tag, members) in r["block_tag_members"].as_object().into_iter().flatten() {
+ self.block_tag_members.insert(tag.clone(), strings(members));
+ }
+ }
+ if self.clock_time_markers.is_empty() {
+ for (clock, markers) in r["clock_time_markers"].as_object().into_iter().flatten() {
+ self.clock_time_markers
+ .insert(clock.clone(), strings(markers));
+ }
+ }
+ if self.advancement_criteria.is_empty() {
+ for (id, criteria) in r["advancement_criteria"].as_object().into_iter().flatten() {
+ self.advancement_criteria
+ .insert(id.clone(), strings(criteria));
+ }
+ }
+ }
+ /// The element ids of a registry (sorted).
+ pub fn ids(&self, registry: &str) -> &[String] {
+ if let Some(r) = self.by_registry.get(registry) {
+ return &r.ids;
+ }
+ match registry {
+ "minecraft:item" => &self.items,
+ "minecraft:entity_type" => &self.entity_types,
+ "minecraft:mob_effect" => &self.effects,
+ "minecraft:enchantment" => &self.enchantments,
+ "minecraft:worldgen/structure" => &self.structures,
+ "minecraft:worldgen/biome" => &self.biomes,
+ "minecraft:world_clock" => &self.clocks,
+ "minecraft:timeline" => &self.timelines,
+ "minecraft:attribute" => &self.attributes,
+ "minecraft:damage_type" => &self.damage_types,
+ "minecraft:sound_event" => &self.sounds,
+ "minecraft:predicate" => &self.predicates,
+ "minecraft:item_modifier" => &self.item_modifiers,
+ "minecraft:loot_table" => &self.loot_tables,
+ "minecraft:recipe" => &self.recipes,
+ "minecraft:advancement" => &self.advancements,
+ _ => EMPTY,
+ }
+ }
+ /// The tag ids of a registry (sorted).
+ pub fn tags(&self, registry: &str) -> &[String] {
+ if let Some(r) = self.by_registry.get(registry) {
+ return &r.tags;
+ }
+ match registry {
+ "minecraft:item" => &self.item_tags,
+ "minecraft:block" => &self.block_tags,
+ _ => EMPTY,
+ }
+ }
+}
diff --git a/crates/horizon-client/src/scoreboard.rs b/crates/horizon-client-core/src/scoreboard.rs
similarity index 99%
rename from crates/horizon-client/src/scoreboard.rs
rename to crates/horizon-client-core/src/scoreboard.rs
index 4796be51a..3e820e4eb 100644
--- a/crates/horizon-client/src/scoreboard.rs
+++ b/crates/horizon-client-core/src/scoreboard.rs
@@ -2,9 +2,9 @@
//! `ObjectiveCriteria`, `NumberFormat`) and its saved data
//! (`data/minecraft/scoreboard.dat`, `ScoreboardSaveData.Packed`).
use crate::{
- command::Registries,
component,
fastutil_order::{HashSetOrder, OpenOrder},
+ registries::Registries,
text::{self, Style, Text},
};
use horizon_world::nbt::Tag;
@@ -1266,7 +1266,7 @@ fn entity_uuids(tag: &mut Tag) {
})
.collect::