[PR #3556] [MERGED] Jukebox: a server's client plays the song of level event 1010 #5046

Closed
opened 2026-11-03 05:09:51 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix-3173


📝 Commits (1)

  • d94e4cb Jukebox: a server's client plays the song of level event 1010

📊 Changes

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

View changed files

📝 crates/horizon-client/src/game.rs (+8 -4)
📝 crates/horizon-client/src/game/jukebox.rs (+72 -3)

📄 Description

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

What and why

Fixes #3173

A disc put into a jukebox on a server stays in, and note particles rise above the jukebox, but no song plays. This also happens in single player: the window joins its own server thread as a client. #3379 (single player, no sound from discs) may be the same bug.

A server's jukebox tells its clients about the song with level event 1010. The event's data is the song's id in the jukebox_song registry the server sent during configuration. The client's LevelEventHandler looks that id up and calls playJukeboxSong, which plays the SimpleSoundInstance.forJukeboxSong, shows "Now Playing: …" and makes the nearby parrots dance. Level event 1011 calls stopJukeboxSongAndNotifyNearby.

Horizon's handling of 1010 and 1011 only made the parrots dance or stop. Songs started only from tick_jukebox, for a jukebox this Game plays itself. A server's client never has one, so it heard nothing. Two changes:

  • process_level_events: 1010 resolves its data in the remote's jukebox_song registry and starts that song with the existing start_song (sound, overlay, parrots). 1011 stops the song and stops the parrots. An id the registry doesn't have does nothing, as ifPresent does. A level that plays its own jukeboxes (no server registry) starts their songs from the jukebox's own tick, as before.
  • update_song_volumes used to drop any song whose jukebox in this Game wasn't playing. On a server's client that jukebox never plays, so the song would stop as soon as it started. A server's client now keeps the song until 1011 or until it ends, as LevelRenderer.playingJukeboxSongs does.

Vanilla reference

  • net.minecraft.client.renderer.LevelEventHandler.levelEvent, case 1010: level.registryAccess().lookupOrThrow(Registries.JUKEBOX_SONG).get(data).ifPresent(song -> playJukeboxSong(song, pos)). Case 1011: stopJukeboxSongAndNotifyNearby(pos).
  • LevelEventHandler.playJukeboxSong: stopJukeboxSong(pos), SimpleSoundInstance.forJukeboxSong(soundEvent, Vec3.atCenterOf(pos)), which goes into playingJukeboxSongs, then SoundManager.play, Hud.setNowPlaying(description) and notifyNearbyEntities(level, pos, true).

Read with javap -c -p on the 26.3 client jar. No parity harness covers the client's level events.

Test: game::jukebox::tests::a_server_clients_jukebox_song_comes_from_level_event_1010 checks the two rules. Event data 2 in a jukebox_song registry of [11, 13, cat] names minecraft:cat, and unknown ids, negative ids and a missing registry name nothing. A server client's song stays on while it is active, even though its own jukebox isn't playing.

Before (the two helpers answering as main does: the data ignored, the song kept only while this level's jukebox plays):

test game::jukebox::tests::a_server_clients_jukebox_song_comes_from_level_event_1010 ... FAILED
assertion `left == right` failed
  left: None
 right: Some("minecraft:cat")
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 145 filtered out

After:

test game::jukebox::tests::a_server_clients_jukebox_song_comes_from_level_event_1010 ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 145 filtered out

Self-check

Run on Windows 11. tools/pr_ready.py stops on Windows at signal.SIGHUP, so I ran the steps by hand:

cargo fmt --all -- --check                                                       ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings      ok
cargo test -p horizon-client --features mods --bin horizon-client jukebox        1 passed
python tools/check_public_tree.py                                                passed

In game

Default single player (server thread), creative. A disc of cat goes into a jukebox. The test games ran with HORIZON_NO_AUDIO=1, which reports no sound instances at all, so the check looks at the other half of playJukeboxSong instead: the "Now Playing" overlay. start_song sets it right after it starts the sound.

These runs were on the branch before its rebase onto the current main. Before (a build of main at b19b4e92d, plus the unrelated #3424 change to the remote item-use rule): the jukebox has has_record=true, and horizon-ctl messages shows no action bar. Holding the button made the disc go in and out more than once, which left a stray disc on the ground.

After (this change): one click puts the disc in (has_record=true), and the overlay reads "Now Playing: C418 - cat".

🤖 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/3556 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3173` --- ### 📝 Commits (1) - [`d94e4cb`](https://github.com/horizon-rust/horizon/commit/d94e4cb7a42614e00aad66d189233ff871b3a24c) Jukebox: a server's client plays the song of level event 1010 ### 📊 Changes **2 files changed** (+80 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+8 -4) 📝 `crates/horizon-client/src/game/jukebox.rs` (+72 -3) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3173 A disc put into a jukebox on a server stays in, and note particles rise above the jukebox, but no song plays. This also happens in single player: the window joins its own server thread as a client. #3379 (single player, no sound from discs) may be the same bug. A server's jukebox tells its clients about the song with level event 1010. The event's data is the song's id in the `jukebox_song` registry the server sent during configuration. The client's `LevelEventHandler` looks that id up and calls `playJukeboxSong`, which plays the `SimpleSoundInstance.forJukeboxSong`, shows "Now Playing: …" and makes the nearby parrots dance. Level event 1011 calls `stopJukeboxSongAndNotifyNearby`. Horizon's handling of 1010 and 1011 only made the parrots dance or stop. Songs started only from `tick_jukebox`, for a jukebox this `Game` plays itself. A server's client never has one, so it heard nothing. Two changes: - `process_level_events`: 1010 resolves its data in the remote's `jukebox_song` registry and starts that song with the existing `start_song` (sound, overlay, parrots). 1011 stops the song and stops the parrots. An id the registry doesn't have does nothing, as `ifPresent` does. A level that plays its own jukeboxes (no server registry) starts their songs from the jukebox's own tick, as before. - `update_song_volumes` used to drop any song whose jukebox in this `Game` wasn't playing. On a server's client that jukebox never plays, so the song would stop as soon as it started. A server's client now keeps the song until 1011 or until it ends, as `LevelRenderer.playingJukeboxSongs` does. ## Vanilla reference - `net.minecraft.client.renderer.LevelEventHandler.levelEvent`, case 1010: `level.registryAccess().lookupOrThrow(Registries.JUKEBOX_SONG).get(data).ifPresent(song -> playJukeboxSong(song, pos))`. Case 1011: `stopJukeboxSongAndNotifyNearby(pos)`. - `LevelEventHandler.playJukeboxSong`: `stopJukeboxSong(pos)`, `SimpleSoundInstance.forJukeboxSong(soundEvent, Vec3.atCenterOf(pos))`, which goes into `playingJukeboxSongs`, then `SoundManager.play`, `Hud.setNowPlaying(description)` and `notifyNearbyEntities(level, pos, true)`. Read with `javap -c -p` on the 26.3 client jar. No parity harness covers the client's level events. **Test:** `game::jukebox::tests::a_server_clients_jukebox_song_comes_from_level_event_1010` checks the two rules. Event data 2 in a `jukebox_song` registry of `[11, 13, cat]` names `minecraft:cat`, and unknown ids, negative ids and a missing registry name nothing. A server client's song stays on while it is active, even though its own jukebox isn't playing. Before (the two helpers answering as main does: the data ignored, the song kept only while this level's jukebox plays): ``` test game::jukebox::tests::a_server_clients_jukebox_song_comes_from_level_event_1010 ... FAILED assertion `left == right` failed left: None right: Some("minecraft:cat") test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 145 filtered out ``` After: ``` test game::jukebox::tests::a_server_clients_jukebox_song_comes_from_level_event_1010 ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 145 filtered out ``` ## Self-check Run on Windows 11. `tools/pr_ready.py` stops on Windows at `signal.SIGHUP`, so I ran the steps by hand: ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --features mods --bin horizon-client jukebox 1 passed python tools/check_public_tree.py passed ``` ## In game Default single player (server thread), creative. A disc of `cat` goes into a jukebox. The test games ran with `HORIZON_NO_AUDIO=1`, which reports no sound instances at all, so the check looks at the other half of `playJukeboxSong` instead: the "Now Playing" overlay. `start_song` sets it right after it starts the sound. These runs were on the branch before its rebase onto the current main. Before (a build of main at b19b4e92d, plus the unrelated #3424 change to the remote item-use rule): the jukebox has `has_record=true`, and `horizon-ctl messages` shows no action bar. Holding the button made the disc go in and out more than once, which left a stray disc on the ground. After (this change): one click puts the disc in (`has_record=true`), and the overlay reads "Now Playing: C418 - cat". 🤖 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 05:09:51 +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#5046
No description provided.