[PR #123] [MERGED] horizon-prepare sounds: sound copy in Rust, run by the launcher (no Python for players) #2338

Closed
opened 2026-11-02 15:55:05 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/123
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: feat/sounds-rust


📝 Commits (1)

  • 8355a6f horizon-prepare sounds: the sound copy in Rust, run by the launcher

📊 Changes

15 files changed (+408 additions, -65 deletions)

View changed files

📝 README.md (+1 -1)
📝 crates/horizon-prepare/src/artifacts.rs (+8 -3)
📝 crates/horizon-prepare/src/lib.rs (+3 -0)
📝 crates/horizon-prepare/src/main.rs (+16 -2)
➕ crates/horizon-prepare/src/sounds.rs (+299 -0)
📝 docs/native-client.md (+6 -5)
📝 launcher/README.md (+3 -1)
📝 launcher/src/backend.rs (+48 -1)
📝 launcher/src/cli.rs (+3 -1)
📝 launcher/src/main.rs (+10 -8)
📝 launcher/src/mcp.rs (+5 -1)
📝 packaging/PLAY.txt (+4 -4)
📝 tools/audio_harness.py (+1 -1)
➖ tools/fetch_sounds.py (+0 -36)
📝 tools/package_native_client.py (+1 -1)

📄 Description

What changed

tools/fetch_sounds.py (player-facing: PLAY.txt told players to run it, "needs Python 3.10+") is now Rust:

  • horizon-prepare sounds [--minecraft-dir PATH] [--root PATH] (library: horizon_prepare::sounds, new crates/horizon-prepare/src/sounds.rs). Same behaviour as the script and the tools/lab.py functions it used (config, import_manifest, launcher_assets, launcher_object, import_copy): the pinned version JSON is imported and checked as --prepare checks it (writes .local/minecraft/<v>/manifest.json), the asset index is checked against the manifest's SHA-1 and copied to .local/horizon-client/<id>/asset-index.json, and minecraft/sounds.json + minecraft/sounds/** are copied from the launcher's asset store into .local/horizon-client/<id>/assets/, each object's SHA-1 verified (already-verified copies are kept). Nothing is downloaded. Same messages (Sound assets ready: N files, X MB, the launcher hint, "Corrupt asset object …; let the launcher repair it"). Added: asset names and hashes are checked to stay inside their folders.
  • Launcher: Prepare (GUI, horizon-launcher prepare, MCP prepare_resources) copies the sounds after its checks and before preparing: in-process when the version ships the launcher's preparer sources, the version's own horizon-prepare sounds when its sources differ and its --help lists the subcommand, in-process otherwise (older versions read sounds where fetch_sounds.py put them). Sound is optional, so a launcher install without the assets logs No sound (the game will be silent): Missing …/assets/indexes/34.json. … and preparing continues.
  • tools/fetch_sounds.py removed (nothing else used it); dev-tool hints (audio_harness.py, package_native_client.py) point at cargo run -p horizon-prepare -- sounds. PLAY.txt, README.md, docs/native-client.md and launcher/README.md no longer mention Python for sound.

Why

Ludovic's rule: everything player-facing is Rust. Players without the launcher run ./horizon-prepare sounds; launcher players get sound with no extra step.

Identical-output proof (Mac mini)

No machine has the official launcher installed, so the launcher directory is synthetic, built from the real 26.3 files in shared-local: the launcher's version JSON (versions/26.3/26.3.json, sha1 4fe1aa1e…, an accepted manifest), the real asset index (assets/indexes/34.json, sha1 abfaa525…) and the 4962 real sound files stored as assets/objects/xx/<sha1> (each re-hashed while building).

# Python, from origin/main's tools/ + research-lock.json
python3.13 py/tools/fetch_sounds.py --minecraft-dir $PWD/mc
#   Sound assets ready: 4962 files, 377.3 MB
# Rust
horizon-prepare sounds --root $PWD/rs --minecraft-dir $PWD/mc
#   Sound assets ready: 4962 files, 377.3 MB
diff -r py/.local rs/.local && echo IDENTICAL          # IDENTICAL
(cd X/.local && find . -type f | sort | xargs shasum)   # py.sums == rs.sums, 4964 files
(cd X/.local && find . | sort)                          # same tree, 5340 entries

Through the launcher (HORIZON_LAUNCHER_HOME scratch, a fake installed version): in-process, the version's own binary (sources changed), and an old binary without sounds (fallback in-process) each produced a .local/horizon-client identical to the Python one (diff -r). With an install missing assets/, the launcher logged the "No sound" line and went on to prepare; the CLI exits 1 with the same message as the Python script.

Tests

  • cargo test -p horizon-prepare (Mac mini): 12 passed, 4 new in sounds::tests: layout (sounds where the game reads them, non-sound assets not copied, asset-index.json and manifest.json written, second run keeps verified copies), every object checked (corrupt → "Corrupt asset object", missing → "Missing asset object", nothing half-copied), the pinned index only, object paths from real hashes / is_sound.
  • cargo clippy -p horizon-prepare --all-targets -D warnings; launcher cargo clippy --features gpui/runtime_shaders --all-targets -D warnings and cargo test (Mac mini): clean.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/123 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/sounds-rust` --- ### 📝 Commits (1) - [`8355a6f`](https://github.com/horizon-rust/horizon/commit/8355a6ff14add2bb34cf2d30037b3ea5ef721bc6) horizon-prepare sounds: the sound copy in Rust, run by the launcher ### 📊 Changes **15 files changed** (+408 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -1) 📝 `crates/horizon-prepare/src/artifacts.rs` (+8 -3) 📝 `crates/horizon-prepare/src/lib.rs` (+3 -0) 📝 `crates/horizon-prepare/src/main.rs` (+16 -2) ➕ `crates/horizon-prepare/src/sounds.rs` (+299 -0) 📝 `docs/native-client.md` (+6 -5) 📝 `launcher/README.md` (+3 -1) 📝 `launcher/src/backend.rs` (+48 -1) 📝 `launcher/src/cli.rs` (+3 -1) 📝 `launcher/src/main.rs` (+10 -8) 📝 `launcher/src/mcp.rs` (+5 -1) 📝 `packaging/PLAY.txt` (+4 -4) 📝 `tools/audio_harness.py` (+1 -1) ➖ `tools/fetch_sounds.py` (+0 -36) 📝 `tools/package_native_client.py` (+1 -1) </details> ### 📄 Description ## What changed `tools/fetch_sounds.py` (player-facing: PLAY.txt told players to run it, "needs Python 3.10+") is now Rust: - **`horizon-prepare sounds [--minecraft-dir PATH] [--root PATH]`** (library: `horizon_prepare::sounds`, new `crates/horizon-prepare/src/sounds.rs`). Same behaviour as the script and the `tools/lab.py` functions it used (`config`, `import_manifest`, `launcher_assets`, `launcher_object`, `import_copy`): the pinned version JSON is imported and checked as `--prepare` checks it (writes `.local/minecraft/<v>/manifest.json`), the asset index is checked against the manifest's SHA-1 and copied to `.local/horizon-client/<id>/asset-index.json`, and `minecraft/sounds.json` + `minecraft/sounds/**` are copied from the launcher's asset store into `.local/horizon-client/<id>/assets/`, each object's SHA-1 verified (already-verified copies are kept). Nothing is downloaded. Same messages (`Sound assets ready: N files, X MB`, the launcher hint, "Corrupt asset object …; let the launcher repair it"). Added: asset names and hashes are checked to stay inside their folders. - **Launcher**: Prepare (GUI, `horizon-launcher prepare`, MCP `prepare_resources`) copies the sounds after its checks and before preparing: in-process when the version ships the launcher's preparer sources, the version's own `horizon-prepare sounds` when its sources differ and its `--help` lists the subcommand, in-process otherwise (older versions read sounds where fetch_sounds.py put them). Sound is optional, so a launcher install without the assets logs `No sound (the game will be silent): Missing …/assets/indexes/34.json. …` and preparing continues. - `tools/fetch_sounds.py` removed (nothing else used it); dev-tool hints (`audio_harness.py`, `package_native_client.py`) point at `cargo run -p horizon-prepare -- sounds`. PLAY.txt, README.md, docs/native-client.md and launcher/README.md no longer mention Python for sound. ## Why Ludovic's rule: everything player-facing is Rust. Players without the launcher run `./horizon-prepare sounds`; launcher players get sound with no extra step. ## Identical-output proof (Mac mini) No machine has the official launcher installed, so the launcher directory is synthetic, built from the **real** 26.3 files in shared-local: the launcher's version JSON (`versions/26.3/26.3.json`, sha1 `4fe1aa1e…`, an accepted manifest), the real asset index (`assets/indexes/34.json`, sha1 `abfaa525…`) and the 4962 real sound files stored as `assets/objects/xx/<sha1>` (each re-hashed while building). ```sh # Python, from origin/main's tools/ + research-lock.json python3.13 py/tools/fetch_sounds.py --minecraft-dir $PWD/mc # Sound assets ready: 4962 files, 377.3 MB # Rust horizon-prepare sounds --root $PWD/rs --minecraft-dir $PWD/mc # Sound assets ready: 4962 files, 377.3 MB diff -r py/.local rs/.local && echo IDENTICAL # IDENTICAL (cd X/.local && find . -type f | sort | xargs shasum) # py.sums == rs.sums, 4964 files (cd X/.local && find . | sort) # same tree, 5340 entries ``` Through the launcher (`HORIZON_LAUNCHER_HOME` scratch, a fake installed version): in-process, the version's own binary (sources changed), and an old binary without `sounds` (fallback in-process) each produced a `.local/horizon-client` identical to the Python one (`diff -r`). With an install missing `assets/`, the launcher logged the "No sound" line and went on to prepare; the CLI exits 1 with the same message as the Python script. ## Tests - `cargo test -p horizon-prepare` (Mac mini): 12 passed, 4 new in `sounds::tests`: layout (sounds where the game reads them, non-sound assets not copied, asset-index.json and manifest.json written, second run keeps verified copies), every object checked (corrupt → "Corrupt asset object", missing → "Missing asset object", nothing half-copied), the pinned index only, object paths from real hashes / `is_sound`. - `cargo clippy -p horizon-prepare --all-targets -D warnings`; launcher `cargo clippy --features gpui/runtime_shaders --all-targets -D warnings` and `cargo test` (Mac mini): clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:05 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2338
No description provided.