[PR #5469] [MERGED] Native mods: mods' own sound events in native_play_sound #6307

Closed
opened 2026-11-03 06:18:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5469
Author: @levzzz5154
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: mods/mod-sound-events


📝 Commits (1)

  • d471fdc Native mods: mods' own sound events in native_play_sound

📊 Changes

3 files changed (+59 additions, -9 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_particles.rs (+7 -5)
📝 crates/horizon-client/src/game/native_hooks.rs (+47 -4)
➕ tools/native-hook-fragments/mod_sounds.json (+5 -0)

📄 Description

🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally.

Part of #4953 ("Mod particle types and sound events"): the sound half.

GameLevel::native_play_sound took minecraft: events only. Now it takes any sound event id (namespace:path, Identifier's characters):

  • A minecraft: event must still be registered. An unknown one is dropped at dispatch, as before.
  • Another namespace's event (mymod:machine_hum) is sent to nearby players by name, as vanilla sends a sound that isn't in its registry (ClientboundSoundPacket with Holder.direct, a variable range). sound_packet already encoded that; flush_native_sounds skipped it.
  • Players hear it when their resources define it: a content mod's assets/mymod/sounds.json and sounds/*.ogg already load with its assets. The client's C::Sound handler already plays a direct sound by its name.

No registry change: vanilla's sound_event registry is built in and its ids are fixed, so a mod's events travel by name, the way vanilla handles any unregistered sound. Helper-only fragment mod_sounds.json: bundles that play their own sounds need its API number.

Tested in the game (server thread)

  • A content mod testmod with assets/testmod/sounds.json (beep, a subtitle) and a generated sounds/beep.ogg, loaded with --dev-mod.
  • A temporary call in the server level tick: native_play_sound("testmod:beep", <first player>, 0, 1.0, 1.0) every 40 ticks. It was not committed.
  • Offscreen through horizon-ctl, in single player on the server thread: the server queued it 3 times (queued=true). The window, as the server's client, played testmod:beep 3 times (status → heard: {"testmod:beep": 3}, counted as it plays).

LAN guests and dedicated servers go through the same flush_native_sounds on the hub.

Self-check

tools/pr_ready.py --quick: 3 files, +59 −9. rustfmt and clippy pass. horizon-client tests 1567 passed, including sound_ids_are_identifiers. Python tests 508 passed.

🤖 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/5469 **Author:** [@levzzz5154](https://github.com/levzzz5154) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `mods/mod-sound-events` --- ### 📝 Commits (1) - [`d471fdc`](https://github.com/horizon-rust/horizon/commit/d471fdcf3497d6ae2fcec7cb1bf6adf48a698366) Native mods: mods' own sound events in native_play_sound ### 📊 Changes **3 files changed** (+59 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_particles.rs` (+7 -5) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+47 -4) ➕ `tools/native-hook-fragments/mod_sounds.json` (+5 -0) </details> ### 📄 Description > 🤖 Opened by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. Part of #4953 ("Mod particle types and sound events"): the sound half. `GameLevel::native_play_sound` took `minecraft:` events only. Now it takes any sound event id (`namespace:path`, `Identifier`'s characters): - **A `minecraft:` event** must still be registered. An unknown one is dropped at dispatch, as before. - **Another namespace's event** (`mymod:machine_hum`) is sent to nearby players by name, as vanilla sends a sound that isn't in its registry (`ClientboundSoundPacket` with `Holder.direct`, a variable range). `sound_packet` already encoded that; `flush_native_sounds` skipped it. - Players hear it when their resources define it: a content mod's `assets/mymod/sounds.json` and `sounds/*.ogg` already load with its assets. The client's `C::Sound` handler already plays a direct sound by its name. No registry change: vanilla's `sound_event` registry is built in and its ids are fixed, so a mod's events travel by name, the way vanilla handles any unregistered sound. Helper-only fragment `mod_sounds.json`: bundles that play their own sounds need its API number. ## Tested in the game (server thread) - A content mod `testmod` with `assets/testmod/sounds.json` (`beep`, a subtitle) and a generated `sounds/beep.ogg`, loaded with `--dev-mod`. - A temporary call in the server level tick: `native_play_sound("testmod:beep", <first player>, 0, 1.0, 1.0)` every 40 ticks. It was not committed. - Offscreen through horizon-ctl, in single player on the server thread: the server queued it 3 times (`queued=true`). The window, as the server's client, played `testmod:beep` 3 times (`status` → `heard: {"testmod:beep": 3}`, counted as it plays). LAN guests and dedicated servers go through the same `flush_native_sounds` on the hub. ## Self-check `tools/pr_ready.py --quick`: 3 files, +59 −9. rustfmt and clippy pass. horizon-client tests 1567 passed, including `sound_ids_are_identifiers`. Python tests 508 passed. 🤖 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-03 06:18:03 +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#6307
No description provided.