[PR #5321] [MERGED] fix(blocks): a hopper can put a disc in a jukebox, and it plays #6209

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

📋 Pull Request Information

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

Base: main ← Head: fix/jukebox-hopper-disc


📝 Commits (3)

  • 2f6e9fd fix(blocks): a hopper can put a disc in a jukebox, and it plays
  • ca4eeab fix(blocks): a hopper taking a jukebox's disc stops the song
  • aa68b66 Merge remote-tracking branch 'origin/main' into pr-5321

📊 Changes

8 files changed (+110 additions, -18 deletions)

View changed files

📝 crates/horizon-client-render/src/chunk/block_entity.rs (+9 -1)
📝 crates/horizon-client-render/src/containers.rs (+23 -3)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+3 -3)
📝 crates/horizon-client/src/game/jukebox.rs (+46 -6)
📝 crates/horizon-client/src/game/machines.rs (+24 -0)
📝 crates/horizon-client/src/game/spill.rs (+1 -1)
📝 crates/horizon-client/src/save.rs (+2 -2)
📝 tools/port_map/game2-017.tsv (+2 -2)

📄 Description

🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally.

What and why

A hopper cannot put a disc in a jukebox. JukeboxBlockEntity keeps its disc in a ContainerSingleItem, so in vanilla a hopper or a dropper reaches it like any other container and the disc that lands starts the song. Here the disc was a bare Jukebox.record that BlockEntity::slots() did not expose, so HopperBlockEntity.getContainerAt found no container at all and nothing could be inserted — the JukeboxBlockEntity.setTheItem and JukeboxBlockEntity.canPlaceItem rows of #3516.

Now:

  • Jukebox.record becomes items: [Option<ItemStack>; 1] (vanilla's one-slot NonNullList), with a record() accessor for the existing readers, and slots/slots_mut/contents hand it out — so the container machinery sees a one-slot container and its other users keep working;
  • Containers learns Kind::Jukebox and its canPlaceItem: a jukebox_playable disc into the one empty slot;
  • a successful transfer calls the new Game::jukebox_inserted, which starts the song exactly as the player's own use does (set_has_record, start_song, the neighbour and comparator updates).

Vanilla reference

JukeboxBlockEntity (ContainerSingleItem slot, canPlaceItem, setTheItem), HopperBlockEntity.getContainerAt/addItem, and JukeboxSongPlayer's start — all already ported here for the player's hand, which is what Game::use_jukebox shows.

Test: containers::tests::a_jukebox_offers_its_record_as_its_one_container_slot — the block entity reports one slot, an empty one until a disc lands, and contents() follows. It needs no prepared game data.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Other projects' code

none

Self-check

cargo fmt --all --check                                     clean
cargo clippy -p horizon-client --lib --bins --tests -- -D warnings
  Finished (no warnings)
cargo test -p horizon-client --lib
  1006 passed, 0 failed, 29 ignored
cargo test -p horizon-client-render --lib a_jukebox
  a_jukebox_offers_its_record_as_its_one_container_slot ... ok
python3 tools/check_public_tree.py
  Public tree check passed.

tools/pr_ready.py still cannot run here (Python 3.11+ needed, 3.9 is installed) — the block above is its Rust half. The harnesses this can reach are the dispenser and container ones; CI runs them.

tools/port_map/game2-017.tsv: both JukeboxBlockEntity rows are port now.

One thing I left alone: the play_record statistic, which only a player using the block earns (a hopper earns nothing), matching where the existing code already awards it.

🤖 Generated with DeepSeek Harness (deepseek-v4.1-flash)


🔄 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/5321 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/jukebox-hopper-disc` --- ### 📝 Commits (3) - [`2f6e9fd`](https://github.com/horizon-rust/horizon/commit/2f6e9fd50aa4dcef0dcd83d993726b0196a213b2) fix(blocks): a hopper can put a disc in a jukebox, and it plays - [`ca4eeab`](https://github.com/horizon-rust/horizon/commit/ca4eeab63e95a7c74fb6cdad6ff7bc5a67de3ba5) fix(blocks): a hopper taking a jukebox's disc stops the song - [`aa68b66`](https://github.com/horizon-rust/horizon/commit/aa68b6653fee9f3e0874667347910d5b56efacef) Merge remote-tracking branch 'origin/main' into pr-5321 ### 📊 Changes **8 files changed** (+110 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/chunk/block_entity.rs` (+9 -1) 📝 `crates/horizon-client-render/src/containers.rs` (+23 -3) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+3 -3) 📝 `crates/horizon-client/src/game/jukebox.rs` (+46 -6) 📝 `crates/horizon-client/src/game/machines.rs` (+24 -0) 📝 `crates/horizon-client/src/game/spill.rs` (+1 -1) 📝 `crates/horizon-client/src/save.rs` (+2 -2) 📝 `tools/port_map/game2-017.tsv` (+2 -2) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally. ## What and why A hopper cannot put a disc in a jukebox. `JukeboxBlockEntity` keeps its disc in a `ContainerSingleItem`, so in vanilla a hopper or a dropper reaches it like any other container and the disc that lands starts the song. Here the disc was a bare `Jukebox.record` that `BlockEntity::slots()` did not expose, so `HopperBlockEntity.getContainerAt` found no container at all and nothing could be inserted — the `JukeboxBlockEntity.setTheItem` and `JukeboxBlockEntity.canPlaceItem` rows of #3516. Now: - `Jukebox.record` becomes `items: [Option<ItemStack>; 1]` (vanilla's one-slot `NonNullList`), with a `record()` accessor for the existing readers, and `slots`/`slots_mut`/`contents` hand it out — so the container machinery sees a one-slot container and its other users keep working; - `Containers` learns `Kind::Jukebox` and its `canPlaceItem`: a `jukebox_playable` disc into the one empty slot; - a successful transfer calls the new `Game::jukebox_inserted`, which starts the song exactly as the player's own use does (`set_has_record`, `start_song`, the neighbour and comparator updates). ## Vanilla reference `JukeboxBlockEntity` (`ContainerSingleItem` slot, `canPlaceItem`, `setTheItem`), `HopperBlockEntity.getContainerAt`/`addItem`, and `JukeboxSongPlayer`'s start — all already ported here for the player's hand, which is what `Game::use_jukebox` shows. Test: `containers::tests::a_jukebox_offers_its_record_as_its_one_container_slot` — the block entity reports one slot, an empty one until a disc lands, and `contents()` follows. It needs no prepared game data. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Other projects' code none ## Self-check ``` cargo fmt --all --check clean cargo clippy -p horizon-client --lib --bins --tests -- -D warnings Finished (no warnings) cargo test -p horizon-client --lib 1006 passed, 0 failed, 29 ignored cargo test -p horizon-client-render --lib a_jukebox a_jukebox_offers_its_record_as_its_one_container_slot ... ok python3 tools/check_public_tree.py Public tree check passed. ``` `tools/pr_ready.py` still cannot run here (Python 3.11+ needed, 3.9 is installed) — the block above is its Rust half. The harnesses this can reach are the dispenser and container ones; CI runs them. `tools/port_map/game2-017.tsv`: both `JukeboxBlockEntity` rows are `port` now. One thing I left alone: the `play_record` statistic, which only a player using the block earns (a hopper earns nothing), matching where the existing code already awards it. 🤖 Generated with [DeepSeek Harness](https://www.deepseek.com) (deepseek-v4.1-flash) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:15:54 +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#6209
No description provided.