[PR #3442] [MERGED] Copper chests join into double chests #4981

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

📋 Pull Request Information

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

Base: main ← Head: fix-copper-chest-double


📝 Commits (1)

  • 8bb8239 Copper chests join into double chests

📊 Changes

8 files changed (+363 additions, -78 deletions)

View changed files

📝 crates/horizon-client-render/src/containers.rs (+52 -0)
➕ crates/horizon-client/examples/probe/chest_pair_fixture.rs (+74 -0)
📝 crates/horizon-client/examples/probe/main.rs (+2 -0)
📝 crates/horizon-client/src/game/hand.rs (+5 -4)
📝 crates/horizon-client/src/game/machines.rs (+13 -26)
📝 crates/horizon-client/src/game/storage.rs (+51 -48)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaChestPairOracle.java (+97 -0)
➕ tools/test_chest_pair_parity.py (+69 -0)

📄 Description

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

What and why

Two copper chests placed side by side join into a double chest on screen (the placement and updateShape code already handles copper chests), but opening one showed a 27-slot "Chest" with only that half's items. In vanilla 26.3 they open as a "Large Chest", right half first, like chests and trapped chests do.

The cause: the game's own pairing (Game::chest_partner, used by the server's lan_open_container, the in-frame menu, the open/close sound position and the container's reach check) only accepted minecraft:chest and minecraft:trapped_chest. The hopper and comparator view (machines.rs) and the spectator crosshair had the same name check, so a hopper above a double copper chest filled only the half under it.

The fix moves the pairing into horizon_client::containers:

  • is_chest_block: every ChestBlock, meaning chests, trapped chests and copper chests in all 8 states (4 weathering states, waxed or not). Ender chests stay single.
  • ChestHalf::connected_step / pairs_with: ChestBlock.getConnectedDirection and DoubleBlockCombiner.combineWithNeigbour, which needs the same block, a half of the other type and the same facing. Horizon didn't check the facing for any chest. Two halves facing different ways (for example after /setblock) now stay single, as in vanilla.

chest_partner, chest_menu_blocked, the hopper and comparator view, the spectator crosshair and the in-frame chest_rows all use it. With chest_rows, an in-frame copper chest now gets ChestMenu's geometry; before, it used the 166-px default layout.

About oxidation: vanilla never pairs two different copper blocks. combineWithNeigbour needs neighbourState.is(state.getBlock()). Instead, CopperChestBlock keeps both halves in one state. getStateForPlacement takes the less weathered block of the two (getLeastOxidizedChestOfConnectedBlocks), and updateShape copies the connected half's block (neighbour.getBlock().withPropertiesOf(..)). Horizon already does both in horizon-world (copper_chest_least_oxidized, the CopperChest arm of shapes.rs), so this PR doesn't touch them, and pairs_with still needs the same block.

Vanilla reference

  • ChestBlock.combine, getContainer, getMenuProvider, getConnectedDirection, getBlockType. CopperChestBlock extends ChestBlock and doesn't override combine (its blockEntityType is BlockEntityTypes.CHEST).
  • DoubleBlockCombiner.combineWithNeigbour.
  • CopperChestBlock.getStateForPlacement / getLeastOxidizedChestOfConnectedBlocks / updateShape / chestCanConnectTo (checked; already ported).
  • HopperBlockEntity.getBlockContainer → ChestBlock.getContainer for any ChestBlock.

New harness tools/test_chest_pair_parity.py: VanillaChestPairOracle puts a chest and a neighbour (each with the block entity its block makes) on a stand-in level. It runs combineWithNeigbour as ChestBlock.combine(.., true) calls it and prints the halves of the double chest, right first, or single. chest_pair_fixture answers with containers::ChestHalf. There are 3660 cases: 10 chest blocks (chest, trapped chest, 8 copper states) × 3 types × both sides, next to each of the 10 with 2 facings and 3 types, and next to a barrel.

  • With the fix: 3660/3660 cases match.
  • With the old rule (chests and trapped chests only, no facing check): 3640/3660. Every copper chest pair fails, and so do chests and trapped chests whose halves face different ways.

Also new: the bin test copper_chests_join_like_chests. double_chest_halves_connect_around_the_facing is moved over to ChestHalf.

Self-check

Run on Windows 11, without tools/pr_ready.py (tools/parity.py stops on signal.SIGHUP on Windows):

  • cargo fmt --all --check: clean
  • cargo clippy -p horizon-client --features mods --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --features mods --bins: 140 + 18 passed
  • cargo test -p horizon-client --features mods --lib: 1111 passed, 1 failed: save::tests::session_lock_is_exclusive, which also fails on main on Windows
  • python tools/test_chest_pair_parity.py: 3660/3660 (3640/3660 with the old rule)

Not run here: the harnesses tools/parity.py --changed selects for game/machines.rs, game/storage.rs and game/hand.rs (parity.py doesn't start on Windows).

Screenshots

Single player (server thread). A copper chest and a chest, each placed next to a second one with horizon-ctl place, so each pair joined through getStateForPlacement. Gold is in the right half, iron in the left.

Before: the copper pair looks double, but opening it shows "Chest" with 27 slots and only the iron (the half that was clicked).
copper before world
copper before open

After: "Large Chest" with 54 slots, gold in slot 0 and iron in slot 27, as vanilla orders a double chest.
copper after world
copper after open

--in-frame, before and after:
copper inframe before
copper after open

Also checked by hand: a hopper above the left half of the double copper chest (after the fix) put its diamond in the right half's slot 1. CompoundContainer starts with the right half, and slot 0 there held the gold.

Seen but not changed here: copper chests play block.chest.open/close (container_edge_sound matches on contains("chest")). Vanilla plays each weathering state's own copper chest sounds (CopperChestBlock.getOpenChestSound).

🤖 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/3442 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix-copper-chest-double` --- ### 📝 Commits (1) - [`8bb8239`](https://github.com/horizon-rust/horizon/commit/8bb8239603c14f953e9b2dda59ca03b2c33462d8) Copper chests join into double chests ### 📊 Changes **8 files changed** (+363 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/containers.rs` (+52 -0) ➕ `crates/horizon-client/examples/probe/chest_pair_fixture.rs` (+74 -0) 📝 `crates/horizon-client/examples/probe/main.rs` (+2 -0) 📝 `crates/horizon-client/src/game/hand.rs` (+5 -4) 📝 `crates/horizon-client/src/game/machines.rs` (+13 -26) 📝 `crates/horizon-client/src/game/storage.rs` (+51 -48) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaChestPairOracle.java` (+97 -0) ➕ `tools/test_chest_pair_parity.py` (+69 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Two copper chests placed side by side join into a double chest on screen (the placement and `updateShape` code already handles copper chests), but opening one showed a 27-slot "Chest" with only that half's items. In vanilla 26.3 they open as a "Large Chest", right half first, like chests and trapped chests do. The cause: the game's own pairing (`Game::chest_partner`, used by the server's `lan_open_container`, the in-frame menu, the open/close sound position and the container's reach check) only accepted `minecraft:chest` and `minecraft:trapped_chest`. The hopper and comparator view (`machines.rs`) and the spectator crosshair had the same name check, so a hopper above a double copper chest filled only the half under it. The fix moves the pairing into `horizon_client::containers`: - `is_chest_block`: every `ChestBlock`, meaning chests, trapped chests and copper chests in all 8 states (4 weathering states, waxed or not). Ender chests stay single. - `ChestHalf::connected_step` / `pairs_with`: `ChestBlock.getConnectedDirection` and `DoubleBlockCombiner.combineWithNeigbour`, which needs the same block, a half of the other type and the **same facing**. Horizon didn't check the facing for any chest. Two halves facing different ways (for example after `/setblock`) now stay single, as in vanilla. `chest_partner`, `chest_menu_blocked`, the hopper and comparator view, the spectator crosshair and the in-frame `chest_rows` all use it. With `chest_rows`, an in-frame copper chest now gets ChestMenu's geometry; before, it used the 166-px default layout. About oxidation: vanilla never pairs two different copper blocks. `combineWithNeigbour` needs `neighbourState.is(state.getBlock())`. Instead, `CopperChestBlock` keeps both halves in one state. `getStateForPlacement` takes the less weathered block of the two (`getLeastOxidizedChestOfConnectedBlocks`), and `updateShape` copies the connected half's block (`neighbour.getBlock().withPropertiesOf(..)`). Horizon already does both in `horizon-world` (`copper_chest_least_oxidized`, the `CopperChest` arm of `shapes.rs`), so this PR doesn't touch them, and `pairs_with` still needs the same block. ## Vanilla reference - `ChestBlock.combine`, `getContainer`, `getMenuProvider`, `getConnectedDirection`, `getBlockType`. `CopperChestBlock` extends `ChestBlock` and doesn't override `combine` (its `blockEntityType` is `BlockEntityTypes.CHEST`). - `DoubleBlockCombiner.combineWithNeigbour`. - `CopperChestBlock.getStateForPlacement` / `getLeastOxidizedChestOfConnectedBlocks` / `updateShape` / `chestCanConnectTo` (checked; already ported). - `HopperBlockEntity.getBlockContainer` → `ChestBlock.getContainer` for any `ChestBlock`. **New harness `tools/test_chest_pair_parity.py`**: `VanillaChestPairOracle` puts a chest and a neighbour (each with the block entity its block makes) on a stand-in level. It runs `combineWithNeigbour` as `ChestBlock.combine(.., true)` calls it and prints the halves of the double chest, right first, or `single`. `chest_pair_fixture` answers with `containers::ChestHalf`. There are 3660 cases: 10 chest blocks (chest, trapped chest, 8 copper states) × 3 types × both sides, next to each of the 10 with 2 facings and 3 types, and next to a barrel. - With the fix: `3660/3660 cases match`. - With the old rule (chests and trapped chests only, no facing check): `3640/3660`. Every copper chest pair fails, and so do chests and trapped chests whose halves face different ways. Also new: the bin test `copper_chests_join_like_chests`. `double_chest_halves_connect_around_the_facing` is moved over to `ChestHalf`. ## Self-check Run on Windows 11, without `tools/pr_ready.py` (`tools/parity.py` stops on `signal.SIGHUP` on Windows): - `cargo fmt --all --check`: clean - `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --features mods --bins`: 140 + 18 passed - `cargo test -p horizon-client --features mods --lib`: 1111 passed, 1 failed: `save::tests::session_lock_is_exclusive`, which also fails on main on Windows - `python tools/test_chest_pair_parity.py`: 3660/3660 (3640/3660 with the old rule) Not run here: the harnesses `tools/parity.py --changed` selects for `game/machines.rs`, `game/storage.rs` and `game/hand.rs` (parity.py doesn't start on Windows). ## Screenshots Single player (server thread). A copper chest and a chest, each placed next to a second one with `horizon-ctl place`, so each pair joined through `getStateForPlacement`. Gold is in the right half, iron in the left. Before: the copper pair looks double, but opening it shows "Chest" with 27 slots and only the iron (the half that was clicked). ![copper before world](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/copper-before-world.png) ![copper before open](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/copper-before-open.png) After: "Large Chest" with 54 slots, gold in slot 0 and iron in slot 27, as vanilla orders a double chest. ![copper after world](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/copper-after-world.png) ![copper after open](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/copper-after-open.png) `--in-frame`, before and after: ![copper inframe before](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/copper-inframe-before.png) ![copper after open](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/copper-after-open.png) Also checked by hand: a hopper above the left half of the double copper chest (after the fix) put its diamond in the right half's slot 1. `CompoundContainer` starts with the right half, and slot 0 there held the gold. Seen but not changed here: copper chests play `block.chest.open`/`close` (`container_edge_sound` matches on `contains("chest")`). Vanilla plays each weathering state's own copper chest sounds (`CopperChestBlock.getOpenChestSound`). 🤖 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:21 +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#4981
No description provided.