[PR #5410] [MERGED] Native mods: native_play_local_sound plays a client mod's sound, later #6268

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5410
Author: @Vaspyyy
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/native-local-sound


📝 Commits (10+)

  • de92159 Native mods: native_spawn_falling_block throws a block from a server mod
  • 46598a2 Native mods: native_play_local_sound plays a client mod's sound, later
  • 1ec53c7 Merge remote-tracking branch 'upstream/main' into feat/native-falling-blocks
  • a209fab Native hooks: finite keeps its own doc comment
  • a844d55 Merge main into #5409
  • 27fb1b4 Merge main into #5410
  • 68b5f9e native_play_local_sound: check the event with sound_id, as native_play_sound does
  • a8b7cdc Merge remote-tracking branch 'upstream/main' into feat/native-falling-blocks
  • c6a5386 Merge remote-tracking branch 'upstream/main' into feat/native-local-sound
  • 59d8117 Merge main into #5409

📊 Changes

7 files changed (+245 additions, -2 deletions)

View changed files

📝 crates/horizon-client-render/src/audio.rs (+12 -2)
📝 crates/horizon-client/src/game.rs (+1 -0)
➕ crates/horizon-client/src/game/native_falling.rs (+130 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+65 -0)
📝 docs/native-mods.md (+24 -0)
➕ tools/native-hook-fragments/native_falling_block.json (+8 -0)
➕ tools/native-hook-fragments/native_local_sound.json (+5 -0)

📄 Description

Requested by Ransom · project thread

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

What and why

native_play_local_sound(sound, at, volume, pitch, delay) plays a sound event for this player only, up to 1200 ticks later, through SoundEngine.playDelayed. The event can be vanilla's or the mod's own: a content mod's assets/<id>/sounds.json and sounds/*.ogg already load with the rest of its assets into the resource root, but the server's native_play_sound only takes minecraft: events.

A client mod that hears from its server half (mod messages, API 40) where something happened can time a sound to the distance, such as an explosion heard when its shock wave reaches the player. Audio::play_after is new and play_distance_delayed now goes through it.

Kind

  • feature: something new for players (listed under New in the release notes)

Vanilla reference

SoundManager.playDelayed / SoundEngine.playDelayed, as ClientLevel.playLocalSound with distanceDelay uses it.

Other projects' code

none

Self-check

Run from the fork against upstream/main (d30588e), Rust 1.97:

cargo fmt -p horizon-client: clean
cargo test -p horizon-client --bin horizon-client local_sound: pass
cargo clippy -p horizon-client --bins --tests -- -D warnings -A clippy::manual_range_contains: pass
  (the allow is for horizon-world/src/worldgen/aquifer/noise_based.rs:476, a lint new in Rust 1.97 that fails on main too)

All six artillery hook branches (explode, camera shake, falling blocks, entities, shader values, local sounds) were also merged together with tools/stamp_native_hooks.py run locally (not committed) and their tests run there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XnU6QSxLfzUbudHhcvZtgy


🔄 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/5410 **Author:** [@Vaspyyy](https://github.com/Vaspyyy) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-local-sound` --- ### 📝 Commits (10+) - [`de92159`](https://github.com/horizon-rust/horizon/commit/de92159b98dfbb9ba0c4fc7317c75d49190a8019) Native mods: native_spawn_falling_block throws a block from a server mod - [`46598a2`](https://github.com/horizon-rust/horizon/commit/46598a2bc52ac26151a20a2e55688d7b36862639) Native mods: native_play_local_sound plays a client mod's sound, later - [`1ec53c7`](https://github.com/horizon-rust/horizon/commit/1ec53c7a3f2009cdc8739dfb2d56436ea0e4b868) Merge remote-tracking branch 'upstream/main' into feat/native-falling-blocks - [`a209fab`](https://github.com/horizon-rust/horizon/commit/a209fab13eab95be14ebba8f91b98718318a76f3) Native hooks: finite keeps its own doc comment - [`a844d55`](https://github.com/horizon-rust/horizon/commit/a844d558153f562ee61afe38fffb31005c11e319) Merge main into #5409 - [`27fb1b4`](https://github.com/horizon-rust/horizon/commit/27fb1b40c62bd2dedffe32f9e75685dcea77c462) Merge main into #5410 - [`68b5f9e`](https://github.com/horizon-rust/horizon/commit/68b5f9e5256932bcfac40d12851da94a647d30ac) native_play_local_sound: check the event with sound_id, as native_play_sound does - [`a8b7cdc`](https://github.com/horizon-rust/horizon/commit/a8b7cdc12e9b0d08244dc8fa1112ab0cd3e48685) Merge remote-tracking branch 'upstream/main' into feat/native-falling-blocks - [`c6a5386`](https://github.com/horizon-rust/horizon/commit/c6a5386e9fd5829b165c398c02badca54d8c960a) Merge remote-tracking branch 'upstream/main' into feat/native-local-sound - [`59d8117`](https://github.com/horizon-rust/horizon/commit/59d8117f64c277bd1e7884ae5f0a83a17870b82a) Merge main into #5409 ### 📊 Changes **7 files changed** (+245 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/audio.rs` (+12 -2) 📝 `crates/horizon-client/src/game.rs` (+1 -0) ➕ `crates/horizon-client/src/game/native_falling.rs` (+130 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+65 -0) 📝 `docs/native-mods.md` (+24 -0) ➕ `tools/native-hook-fragments/native_falling_block.json` (+8 -0) ➕ `tools/native-hook-fragments/native_local_sound.json` (+5 -0) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"Vaspyyy"} --> _Requested by **Ransom** · [project thread](https://claude.ai/code/project/chan_014LE6qsPXZ5YJ26HjaADSTZ?thread=cmsg_014LE6qsPXZ5YJ26HjaADSTZ1T4cmgL2QQ21WRYQVKMdRd)_ > 🤖 Opened by Vaspyyy's AI agent (Claude Code, Claude Opus 5.5), not by Vaspyyy personally. ## What and why `native_play_local_sound(sound, at, volume, pitch, delay)` plays a sound event for this player only, up to 1200 ticks later, through `SoundEngine.playDelayed`. The event can be vanilla's or the mod's own: a content mod's `assets/<id>/sounds.json` and `sounds/*.ogg` already load with the rest of its assets into the resource root, but the server's `native_play_sound` only takes `minecraft:` events. A client mod that hears from its server half (mod messages, API 40) where something happened can time a sound to the distance, such as an explosion heard when its shock wave reaches the player. `Audio::play_after` is new and `play_distance_delayed` now goes through it. ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference `SoundManager.playDelayed` / `SoundEngine.playDelayed`, as `ClientLevel.playLocalSound` with `distanceDelay` uses it. ## Other projects' code none ## Self-check Run from the fork against `upstream/main` (d30588e), Rust 1.97: ``` cargo fmt -p horizon-client: clean cargo test -p horizon-client --bin horizon-client local_sound: pass cargo clippy -p horizon-client --bins --tests -- -D warnings -A clippy::manual_range_contains: pass (the allow is for horizon-world/src/worldgen/aquifer/noise_based.rs:476, a lint new in Rust 1.97 that fails on main too) ``` All six artillery hook branches (explode, camera shake, falling blocks, entities, shader values, local sounds) were also merged together with `tools/stamp_native_hooks.py` run locally (not committed) and their tests run there. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XnU6QSxLfzUbudHhcvZtgy --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:16:56 +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#6268
No description provided.