[PR #2805] [MERGED] Jukebox keeps its disc on the server thread: the off hand never ejects it #4626

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2805
Author: @ASOwnerYT
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/28/2026
Merged by: @ludovic111

Base: main ← Head: fix/2775-jukebox-offhand-eject


📝 Commits (1)

  • b38fe43 Jukebox: keep the disc on the server thread; the off hand never ejects it

📊 Changes

2 files changed (+32 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/jukebox.rs (+29 -0)
📝 crates/horizon-client/src/game/remote.rs (+3 -0)

📄 Description

🤖 Opened by asowneryt's AI agent (Claude Code), not by asowneryt himself.

What and why

Fixes #2775. When you put a disc in a jukebox, the jukebox spat it straight back out and played nothing. This happened on the default single-player path (the server thread) and for any server client.

The cause was two bugs that only showed up together:

  • The client sent an off-hand click. remote_block_reacts runs horizon_world's use_item_on, which knows nothing about jukeboxes (they live in game/jukebox.rs). So the client predicted PASS for the main hand. The disc isn't a block item, so the click didn't stop there, and the client also sent an off-hand UseItemOn (and a UseItem).
  • The server ejected the disc on an off-hand turn. By then the server had inserted the disc from the main hand. For the off-hand turn, use_jukebox saw a full jukebox and called eject_record, but vanilla only pops the disc out from the main hand.

The fix:

  • use_jukebox ejects only on a main-hand turn (same self.hand != Hand::Main guard as decorated_pot.rs).
  • New jukebox_takes predicts JukeboxBlock.useItemOn for the main hand on the client: a jukebox with has_record=true, or a held jukebox_playable item, takes the click. So the client ends the click the way vanilla's MultiPlayerGameMode.useItemOn does.

Vanilla reference

  • JukeboxBlock.useItemOn: if (state.getValue(HAS_RECORD)) return TRY_WITH_EMPTY_HAND;, otherwise JukeboxPlayable.tryInsertIntoJukebox. That returns SUCCESS on both sides; the client skips only the insert itself.
  • JukeboxBlock.useWithoutItem: popOutTheItem() when HAS_RECORD.
  • ServerPlayerGameMode.useItemOn / MultiPlayerGameMode.performUseItemOn: TRY_WITH_EMPTY_HAND goes on to useWithoutItem only for InteractionHand.MAIN_HAND. A consumed result ends Minecraft.startUseItem, so the off hand is never tried.

There's no jukebox harness. I checked it by hand with horizon-ctl (offscreen, fresh temporary homes): setblock a jukebox, give music_disc_cat, interact the jukebox.

Build Path After the first click Second click (empty hand)
before (main) server thread has_record=false, the disc was ejected and picked up (2 discs in the creative inventory)
this branch server thread has_record=true, no item entity has_record=false, the disc drops as an item entity
this branch --in-frame has_record=true, no item entity

Self-check

pr_ready (tools/pr_ready.py --base upstream/main on cachyos, against upstream/main at ab080a540, 35 min 30 s)

Check Result
Scope ✅ 2 files, +32 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 331 passed (17 s)
rustfmt ✅ (4 s)
clippy ✅ (1 min 19 s)
tests: horizon-client ✅ 1329 passed (2 min 14 s)
doc tests ✅ 0 passed (37 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 ❌ 39 affected, 30 passed, failed: entity_model, friends_integration, remote_fireball, remote_fireworks, save_roundtrip, server_player_sculk, spawn_loot, world_reopen (30 min 56 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The self-check ran the LAN and friends harnesses windowed, and those games never loaded (chunks: 0) because this machine has no vscreen. Run headless, they pass:

  • HORIZON_E2E_HEADLESS=1 python3 tools/parity.py remote_fireball remote_fireworks server_player_sculk: 3 passed.
  • tools/test_friends.py --baseline --offscreen: passed.

The other four can't run here: save_roundtrip, spawn_loot and world_reopen need vscreen, and entity_model's oracle fails on JDK 27 (the pinned JDK is 25). None of them touches jukeboxes; CI covers them.

🤖 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/2805 **Author:** [@ASOwnerYT](https://github.com/ASOwnerYT) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/28/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/2775-jukebox-offhand-eject` --- ### 📝 Commits (1) - [`b38fe43`](https://github.com/horizon-rust/horizon/commit/b38fe43b09d919bf5aadbdfc4d57042fd2d6fdd3) Jukebox: keep the disc on the server thread; the off hand never ejects it ### 📊 Changes **2 files changed** (+32 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/jukebox.rs` (+29 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+3 -0) </details> ### 📄 Description > 🤖 Opened by asowneryt's AI agent (Claude Code), not by asowneryt himself. ## What and why Fixes #2775. When you put a disc in a jukebox, the jukebox spat it straight back out and played nothing. This happened on the default single-player path (the server thread) and for any server client. The cause was two bugs that only showed up together: - **The client sent an off-hand click.** `remote_block_reacts` runs `horizon_world`'s `use_item_on`, which knows nothing about jukeboxes (they live in `game/jukebox.rs`). So the client predicted PASS for the main hand. The disc isn't a block item, so the click didn't stop there, and the client also sent an off-hand `UseItemOn` (and a `UseItem`). - **The server ejected the disc on an off-hand turn.** By then the server had inserted the disc from the main hand. For the off-hand turn, `use_jukebox` saw a full jukebox and called `eject_record`, but vanilla only pops the disc out from the main hand. The fix: - `use_jukebox` ejects only on a main-hand turn (same `self.hand != Hand::Main` guard as `decorated_pot.rs`). - New `jukebox_takes` predicts `JukeboxBlock.useItemOn` for the main hand on the client: a jukebox with `has_record=true`, or a held `jukebox_playable` item, takes the click. So the client ends the click the way vanilla's `MultiPlayerGameMode.useItemOn` does. ## Vanilla reference - `JukeboxBlock.useItemOn`: `if (state.getValue(HAS_RECORD)) return TRY_WITH_EMPTY_HAND;`, otherwise `JukeboxPlayable.tryInsertIntoJukebox`. That returns SUCCESS on both sides; the client skips only the insert itself. - `JukeboxBlock.useWithoutItem`: `popOutTheItem()` when `HAS_RECORD`. - `ServerPlayerGameMode.useItemOn` / `MultiPlayerGameMode.performUseItemOn`: `TRY_WITH_EMPTY_HAND` goes on to `useWithoutItem` only for `InteractionHand.MAIN_HAND`. A consumed result ends `Minecraft.startUseItem`, so the off hand is never tried. There's no jukebox harness. I checked it by hand with `horizon-ctl` (offscreen, fresh temporary homes): setblock a jukebox, give `music_disc_cat`, `interact` the jukebox. | Build | Path | After the first click | Second click (empty hand) | | --- | --- | --- | --- | | before (main) | server thread | `has_record=false`, the disc was ejected and picked up (2 discs in the creative inventory) | | | this branch | server thread | `has_record=true`, no item entity | `has_record=false`, the disc drops as an item entity | | this branch | `--in-frame` | `has_record=true`, no item entity | | ## Self-check **pr_ready** (`tools/pr_ready.py --base upstream/main` on cachyos, against upstream/main at ab080a540, 35 min 30 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +32 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 331 passed (17 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 min 19 s) | | tests: horizon-client | ✅ 1329 passed (2 min 14 s) | | doc tests | ✅ 0 passed (37 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 | ❌ 39 affected, 30 passed, failed: entity_model, friends_integration, remote_fireball, remote_fireworks, save_roundtrip, server_player_sculk, spawn_loot, world_reopen (30 min 56 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The self-check ran the LAN and friends harnesses windowed, and those games never loaded (`chunks: 0`) because this machine has no `vscreen`. Run headless, they pass: - `HORIZON_E2E_HEADLESS=1 python3 tools/parity.py remote_fireball remote_fireworks server_player_sculk`: 3 passed. - `tools/test_friends.py --baseline --offscreen`: passed. The other four can't run here: `save_roundtrip`, `spawn_loot` and `world_reopen` need `vscreen`, and `entity_model`'s oracle fails on JDK 27 (the pinned JDK is 25). None of them touches jukeboxes; CI covers them. 🤖 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:06:45 +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#4626
No description provided.