[PR #5898] [MERGED] Native mods: music a client mod chooses and layers (native_music, native_music_layers) #6549

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

📋 Pull Request Information

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

Base: main ← Head: feat/native-music


📝 Commits (3)

  • 76ba285 Native mods: music a client mod chooses and layers (native_music, native_music_layers)
  • 4c69eab Merge main into feat/native-music (beside native_biome_colors)
  • d9ad8b2 Merge main into native music (camera_distance hook kept; shader_params keeps its own doc)

📊 Changes

7 files changed (+273 additions, -9 deletions)

View changed files

📝 crates/horizon-client-render/src/sound_engine.rs (+23 -1)
📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/music.rs (+6 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+31 -7)
📝 crates/horizon-client/src/music.rs (+176 -0)
📝 docs/native-mods.md (+17 -0)
➕ tools/native-hook-fragments/music.json (+17 -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

Fixes #5863

A mod can play one-off sounds (native_play_local_sound) but can't choose the background music or build it up. This adds two client hooks, asked once a client tick from tick_music:

  • native_music(music, volume): what vanilla chose (Minecraft.getSituationalMusic, getMusicVolume) comes in; a mod can set its own Music (a content mod's sound event, its delays and replace_current_music), None for silence, or a lower volume. The music manager then plays it exactly as vanilla's (delays, Music Frequency, Now Playing toast). NeoForge's SelectMusicEvent.
  • native_music_layers(layers): looping tracks played over (or instead of) that music, each a MusicLayer { sound, volume }. MusicLayers keeps one music-source instance per sound (SoundInstance::for_music_layer: looping, unattenuated, allowed to start silent, ticked so its volume reaches the channel), eases each volume by 0.025 a tick, and stops a layer once it has faded out after being left out. Layers that first appear in the same tick start together, so the stems of one piece stay in step; a layer stopped by a level change starts again on the next tick.

Together these let a mod's soundtrack follow a value it keeps (seasons, or a village's wellbeing raising extra stems).

The hooks come as an API fragment (tools/native-hook-fragments/music.json).

Kind

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

Vanilla reference

Minecraft.getSituationalMusic, Minecraft.getMusicVolume, MusicManager.tick (unchanged; the hook sits between them). The layers are Horizon-only; they use the sound engine's tickable instance path (SoundEngine.tickInGame's volume updates).

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on vm, against upstream/main at bd8c53bfa, 8 min 43 s)

Check Result
Scope ✅ 7 files, +266 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (47 s)
rustfmt ✅ (10 s)
clippy ✅ (3 min 34 s)
tests: horizon-client, horizon-client-render ✅ 2505 passed (4 min 8 s)
doc tests ✅ 0 passed (4 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code

https://claude.ai/code/session_01XnU6QRKvdg3SMVP1onGqS3


🔄 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/5898 **Author:** [@Vaspyyy](https://github.com/Vaspyyy) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-music` --- ### 📝 Commits (3) - [`76ba285`](https://github.com/horizon-rust/horizon/commit/76ba2858e9cd45510c67b514c745c0be74c759f3) Native mods: music a client mod chooses and layers (native_music, native_music_layers) - [`4c69eab`](https://github.com/horizon-rust/horizon/commit/4c69eab447697a8000d1729751d34663a027cb85) Merge main into feat/native-music (beside native_biome_colors) - [`d9ad8b2`](https://github.com/horizon-rust/horizon/commit/d9ad8b26019ee960b4ff157f5c34d58c3124bf84) Merge main into native music (camera_distance hook kept; shader_params keeps its own doc) ### 📊 Changes **7 files changed** (+273 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/sound_engine.rs` (+23 -1) 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/music.rs` (+6 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+31 -7) 📝 `crates/horizon-client/src/music.rs` (+176 -0) 📝 `docs/native-mods.md` (+17 -0) ➕ `tools/native-hook-fragments/music.json` (+17 -0) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"Vaspyyy"} --> _Requested by **Ransom** · [project thread](https://claude.ai/code/project/chan_014LE6qsPXZ5YJ26HjaADSTZ?thread=cmsg_014LE6qsPXZ5YJ26HjaADSTZ5FViA2Ac9eywAJFW3BtEf9)_ > 🤖 Opened by Vaspyyy's AI agent (Claude Code, Claude Opus 5.5), not by Vaspyyy personally. ## What and why Fixes #5863 A mod can play one-off sounds (`native_play_local_sound`) but can't choose the background music or build it up. This adds two client hooks, asked once a client tick from `tick_music`: - `native_music(music, volume)`: what vanilla chose (`Minecraft.getSituationalMusic`, `getMusicVolume`) comes in; a mod can set its own `Music` (a content mod's sound event, its delays and `replace_current_music`), None for silence, or a lower volume. The music manager then plays it exactly as vanilla's (delays, Music Frequency, Now Playing toast). NeoForge's `SelectMusicEvent`. - `native_music_layers(layers)`: looping tracks played over (or instead of) that music, each a `MusicLayer { sound, volume }`. `MusicLayers` keeps one music-source instance per sound (`SoundInstance::for_music_layer`: looping, unattenuated, allowed to start silent, ticked so its volume reaches the channel), eases each volume by 0.025 a tick, and stops a layer once it has faded out after being left out. Layers that first appear in the same tick start together, so the stems of one piece stay in step; a layer stopped by a level change starts again on the next tick. Together these let a mod's soundtrack follow a value it keeps (seasons, or a village's wellbeing raising extra stems). The hooks come as an API fragment (`tools/native-hook-fragments/music.json`). ## Kind - [x] feature: something new for players (listed under New in the release notes) ## Vanilla reference `Minecraft.getSituationalMusic`, `Minecraft.getMusicVolume`, `MusicManager.tick` (unchanged; the hook sits between them). The layers are Horizon-only; they use the sound engine's tickable instance path (`SoundEngine.tickInGame`'s volume updates). ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on vm, against upstream/main at bd8c53bfa, 8 min 43 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +266 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (47 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (3 min 34 s) | | tests: horizon-client, horizon-client-render | ✅ 2505 passed (4 min 8 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XnU6QRKvdg3SMVP1onGqS3 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:22:46 +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#6549
No description provided.