[PR #875] [MERGED] Mining: harness for a player's mining (#844); tools count as used, wear damage_per_block, pots shatter #2876

Closed
opened 2026-11-02 15:59:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/container-break-drops


📝 Commits (1)

  • 62cacfa Mining: the block-removal harness mines blocks as a survival player

📊 Changes

5 files changed (+221 additions, -28 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+71 -18)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+57 -4)
📝 crates/horizon-client/src/items.rs (+10 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java (+71 -3)
📝 tools/test_block_removal_parity.py (+12 -3)

📄 Description

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

Refs #844 (items disappear when you break a furnace, reported by adore on Discord). The fix for #844 itself is the contributor's #855: creaking_heart_broken took any block entity out of the map and dropped it when it wasn't a creaking heart, before the removal could spill it. Merge #855 first. This PR adds the harness that proves it, plus three mining gaps that harness found in Horizon.

The harness

tools/test_block_removal_parity.py gains a mine removal (8% of cases): a survival player mines the block holding a diamond or wooden pickaxe, a stone axe, an iron shovel, an iron sword, shears, a mace or nothing.

  • Vanilla: VanillaDispenserOracle.mine runs the real ServerPlayerGameMode.destroyBlock (playerWillDestroy, removeBlock with preRemoveSideEffects, mineBlock, playerDestroy).
  • Horizon: the dispense fixture calls break_block. That is the path every player's mining takes: single player, the server thread / LAN host, and LAN guests (lan_actions).
  • Both print the drops, the spilled contents, experience orbs, events, sounds, the statistics and the held stack.

Every container in HOLDERS is covered: chests, trapped and copper chests, barrels, hoppers, dispensers, droppers, crafters, furnaces, blast furnaces, smokers, brewing stands, shulker boxes (which keep their contents in the dropped item), shelves, chiseled bookshelves, decorated pots, campfires, jukeboxes and lecterns. Blocks without contents are covered too. Furnaces start empty of stored recipes, as a fresh or loaded furnace would.

What it found on main (4000 cases, seed default)

  • #844: every mined container lost its contents (e.g. a furnace with redstone, arrows and iron: vanilla spills 7 stacks, Horizon none).
  • ItemStack.mineBlock: vanilla awards minecraft:used for any item with a tool component. It wears the tool by damage_per_block: 2 for swords, the mace and the trident, and the mace and trident have a tool component without rules. Shears wear on any block but fire (ShearsItem.mineBlock). Horizon awarded no statistic and always wore 1, and only for tools with rules.
  • DecoratedPotBlock.playerWillDestroy: a pot mined with an item in #breaks_decorated_pots (unless an enchantment in #prevents_decorated_pot_shattering is on it) is set cracked=true with flags 260 first, so it shatters (shatter sound, sherds, no pot). Horizon dropped the whole pot.

Fixed here: ItemInfo::tool_damage_per_block, Game::mine_block_with_held and Game::crack_mined_pot in the break path. #855's file (creaking.rs) is untouched, so the two PRs don't overlap.

Results (block_removal, 4000 cases, default seed, commit 62cacfa6)

tree block_removal
this branch alone 3870/4000: all 130 failures are mine cases of containers whose contents vanish (chests, copper chests, barrels, hoppers, dispensers, droppers, crafters, furnaces, blast furnaces, smokers, brewing stands, plus the jukebox's disc and the lectern's book): #844
this branch + #855 4000/4000, including 319 mine cases across the eight held items

Before the fixes here, on main + this harness, every mine case also differed by the used statistic, and pots mined with a tool didn't shatter.

The tool is picked from the case's existing roll, not a new random draw, so every other case is the one main generates. A new draw shifts the sequence and turns up a Level.setBlock crafter-to-crafter case (seed 206451183393) where Horizon lists an empty crafter's block entity and the oracle doesn't. The oracle level makes block entities on demand, so an untouched crafter has none there. Plain origin/main prints the same line for that case, so this PR doesn't touch it. It's a harness artifact worth its own small fix: create crafters' block entities up front, as the oracle already does for spawners.

Without #855 this harness fails (#844). Merge #855 first, then this.

Self-check (commit 62cacfa6, on origin/main 6d238a89)

cargo fmt --all --check                                   ok
cargo clippy --workspace --all-targets -- -D warnings      ok
cargo test -p horizon-client --no-fail-fast               ok (957 passed)
tools/parity.py block_removal dispenser crafter composter mace use_item_on   (with #855 applied)
  PASS composter, crafter, dispenser, mace, use_item_on, block_removal (4000/4000)
tools/parity.py block_removal   (this branch alone)        FAIL 3870/4000, the #844 cases

parity.py --changed origin/main selects 95 harnesses because game.rs and items.rs feed most of them. I ran the six that share the changed oracle and fixture; CI's parity job runs the 95.

Needs Ludovic

Nothing. Kira can tell adore that once #855 and this PR are out, breaking a furnace (or any container) drops its contents again, whether it was just placed or loaded from a save.

🤖 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/875 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/18/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/container-break-drops` --- ### 📝 Commits (1) - [`62cacfa`](https://github.com/horizon-rust/horizon/commit/62cacfa6074f9a34832bef070d43445341ef712d) Mining: the block-removal harness mines blocks as a survival player ### 📊 Changes **5 files changed** (+221 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+71 -18) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+57 -4) 📝 `crates/horizon-client/src/items.rs` (+10 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java` (+71 -3) 📝 `tools/test_block_removal_parity.py` (+12 -3) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Refs #844 (items disappear when you break a furnace, reported by **adore** on Discord). The fix for #844 itself is the contributor's #855: `creaking_heart_broken` took any block entity out of the map and dropped it when it wasn't a creaking heart, before the removal could spill it. **Merge #855 first.** This PR adds the harness that proves it, plus three mining gaps that harness found in Horizon. ## The harness `tools/test_block_removal_parity.py` gains a `mine` removal (8% of cases): a survival player mines the block holding a diamond or wooden pickaxe, a stone axe, an iron shovel, an iron sword, shears, a mace or nothing. - Vanilla: `VanillaDispenserOracle.mine` runs the real `ServerPlayerGameMode.destroyBlock` (playerWillDestroy, removeBlock with `preRemoveSideEffects`, `mineBlock`, playerDestroy). - Horizon: the dispense fixture calls `break_block`. That is the path every player's mining takes: single player, the server thread / LAN host, and LAN guests (`lan_actions`). - Both print the drops, the spilled contents, experience orbs, events, sounds, the statistics and the held stack. Every container in `HOLDERS` is covered: chests, trapped and copper chests, barrels, hoppers, dispensers, droppers, crafters, furnaces, blast furnaces, smokers, brewing stands, shulker boxes (which keep their contents in the dropped item), shelves, chiseled bookshelves, decorated pots, campfires, jukeboxes and lecterns. Blocks without contents are covered too. Furnaces start empty of stored recipes, as a fresh or loaded furnace would. ## What it found on main (4000 cases, seed default) - **#844**: every mined container lost its contents (e.g. a furnace with redstone, arrows and iron: vanilla spills 7 stacks, Horizon none). - `ItemStack.mineBlock`: vanilla awards `minecraft:used` for any item with a `tool` component. It wears the tool by `damage_per_block`: 2 for swords, the mace and the trident, and the mace and trident have a tool component without rules. Shears wear on any block but fire (`ShearsItem.mineBlock`). Horizon awarded no statistic and always wore 1, and only for tools with rules. - `DecoratedPotBlock.playerWillDestroy`: a pot mined with an item in `#breaks_decorated_pots` (unless an enchantment in `#prevents_decorated_pot_shattering` is on it) is set `cracked=true` with flags 260 first, so it shatters (shatter sound, sherds, no pot). Horizon dropped the whole pot. Fixed here: `ItemInfo::tool_damage_per_block`, `Game::mine_block_with_held` and `Game::crack_mined_pot` in the break path. #855's file (`creaking.rs`) is untouched, so the two PRs don't overlap. ## Results (block_removal, 4000 cases, default seed, commit 62cacfa6) | tree | block_removal | | --- | --- | | this branch alone | 3870/4000: all 130 failures are `mine` cases of containers whose contents vanish (chests, copper chests, barrels, hoppers, dispensers, droppers, crafters, furnaces, blast furnaces, smokers, brewing stands, plus the jukebox's disc and the lectern's book): **#844** | | this branch + #855 | **4000/4000**, including 319 `mine` cases across the eight held items | Before the fixes here, on main + this harness, every `mine` case also differed by the `used` statistic, and pots mined with a tool didn't shatter. The tool is picked from the case's existing roll, not a new random draw, so every other case is the one main generates. A new draw shifts the sequence and turns up a `Level.setBlock` crafter-to-crafter case (seed 206451183393) where Horizon lists an empty crafter's block entity and the oracle doesn't. The oracle level makes block entities on demand, so an untouched crafter has none there. Plain origin/main prints the same line for that case, so this PR doesn't touch it. It's a harness artifact worth its own small fix: create crafters' block entities up front, as the oracle already does for spawners. **Without #855 this harness fails** (#844). Merge #855 first, then this. ## Self-check (commit 62cacfa6, on origin/main 6d238a89) ``` cargo fmt --all --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-client --no-fail-fast ok (957 passed) tools/parity.py block_removal dispenser crafter composter mace use_item_on (with #855 applied) PASS composter, crafter, dispenser, mace, use_item_on, block_removal (4000/4000) tools/parity.py block_removal (this branch alone) FAIL 3870/4000, the #844 cases ``` `parity.py --changed origin/main` selects 95 harnesses because `game.rs` and `items.rs` feed most of them. I ran the six that share the changed oracle and fixture; CI's parity job runs the 95. ## Needs Ludovic Nothing. Kira can tell adore that once #855 and this PR are out, breaking a furnace (or any container) drops its contents again, whether it was just placed or loaded from a save. 🤖 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-02 15:59:48 +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#2876
No description provided.