[PR #7671] A destroyed shulker box spills what it holds #7754

Open
opened 2026-11-03 07:23:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7671
Author: @MSedgeMC
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/container-destroyed-spills


📝 Commits (6)

  • e0f80e3 fix: a destroyed bundle spills the stacks it held
  • f8d3912 test: a bundle's contents leave it when its item entity dies
  • 0ba3af1 port_map: BundleItem.onDestroyed points at the item death spill
  • b32675a fix: a destroyed shulker box spills what it holds
  • 6d72faf test: a destroyed shulker box spills what it holds
  • 3be36cf port_map: the destroyed-item rows name the spill and its spawn

📊 Changes

5 files changed (+265 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/entities.rs (+203 -4)
📝 crates/horizon-client/src/game.rs (+23 -0)
📝 crates/horizon-items/src/bundle.rs (+18 -0)
📝 crates/horizon-items/src/item_data.rs (+18 -0)
📝 tools/port_map/game2-008.tsv (+3 -3)

📄 Description

Depends on #7645 (fix/bundle-destroyed-spills): this branch is stacked on it and carries its three commits until that one merges. Only the last three commits are this PR.

Vanilla

BlockItem.onDestroyed(ItemEntity) — every block item's, so a shulker box's — reads the entity's stack and writes ItemContainerContents.EMPTY back into DataComponents.CONTAINER, then hands the old contents to ItemUtils.onContainerDestroyed as nonEmptyItemCopyStream(). That adds one new ItemEntity(level, entity.getX(), entity.getY(), entity.getZ(), stack) per filled slot, in slot order.

So a shulker box dropped in lava, in fire or on a cactus leaves the stacks it held on the ground, in slot order, and the box itself is gone empty.

What Horizon got wrong

The same hole #7645 closed for bundles: nothing ran an item's onDestroyed when its item entity died, and no code read a stack's container for a spill at all. The ledger rows tools/port_map/game2-008.tsv:37 (BlockItem.onDestroyed) and :124 (ItemUtils.onContainerDestroyed) said missing; both now name the port.

item_data::destroyed_container is the container arm: it empties the component and returns the stacks sorted by slot (nonEmptyItemCopyStream walks the 256 slots in order — ItemData.container is a (slot, stack) list that is not otherwise ordered). ItemEntity::hurt spills both arms the stack's components name — a bundle's bundle_contents and a container item's container — and the tick path #7645 added (ItemEnvironmentTick.spilled → Game::spawn_destroyed_contents) puts each one in the level where the entity lay.

Tests

entities::item_destroyed_tests::a_destroyed_shulker_box_spills_its_container drives ItemEntity::hurt — the function environment_tick calls for every damage the game does to a dropped item, and whose spilled tick_dropped_items reads — with a box holding 3 stacks in slots 20, 0 and 3. No prepared data needed.

Fails without the fix, through the path the game calls: with the item_data::destroyed_container call taken out of ItemEntity::hurt (the whole fix in that function), cargo test -q -p horizon-client-lib --lib item_destroyed_tests fails on the spill assertion:

assertion `left == right` failed
  left: []
 right: [("minecraft:oak_log", 8), ("minecraft:cobblestone", 64), ("minecraft:diamond", 4)]

The test calls the same ItemEntity method the tick calls, not a helper written for the test; and the order in the expected value is the point (20, 0, 3 in, slots ascending out).

Not proven: the spawn half (Game::spawn_destroyed_contents, from #7645) has no unit test, because a Game needs a window, audio and prepared resources; and no in-game burn was driven.

cargo clippy -q -p horizon-items -p horizon-client-lib --lib is silent, cargo fmt --all -- --check is clean, and cargo test -q -p horizon-client-lib --lib item_destroyed_tests passes (2 passed).


🔄 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/7671 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/container-destroyed-spills` --- ### 📝 Commits (6) - [`e0f80e3`](https://github.com/horizon-rust/horizon/commit/e0f80e3de23edb5cc6826d3b44dc50034bcd1a1d) fix: a destroyed bundle spills the stacks it held - [`f8d3912`](https://github.com/horizon-rust/horizon/commit/f8d39124247b1909e024b68b9c6df96a8799b1d5) test: a bundle's contents leave it when its item entity dies - [`0ba3af1`](https://github.com/horizon-rust/horizon/commit/0ba3af1b7196f70408b062e355b12181135af0d4) port_map: BundleItem.onDestroyed points at the item death spill - [`b32675a`](https://github.com/horizon-rust/horizon/commit/b32675ae6ae0fccba3e0909d4fb320d2b3575c6a) fix: a destroyed shulker box spills what it holds - [`6d72faf`](https://github.com/horizon-rust/horizon/commit/6d72fafa8d5838369da90ac96b7e1eb1f7eb1bf3) test: a destroyed shulker box spills what it holds - [`3be36cf`](https://github.com/horizon-rust/horizon/commit/3be36cf20f0884b9aae2962de6adc56e439f4be8) port_map: the destroyed-item rows name the spill and its spawn ### 📊 Changes **5 files changed** (+265 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entities.rs` (+203 -4) 📝 `crates/horizon-client/src/game.rs` (+23 -0) 📝 `crates/horizon-items/src/bundle.rs` (+18 -0) 📝 `crates/horizon-items/src/item_data.rs` (+18 -0) 📝 `tools/port_map/game2-008.tsv` (+3 -3) </details> ### 📄 Description Depends on #7645 (`fix/bundle-destroyed-spills`): this branch is stacked on it and carries its three commits until that one merges. Only the last three commits are this PR. ## Vanilla `BlockItem.onDestroyed(ItemEntity)` — every block item's, so a shulker box's — reads the entity's stack and writes `ItemContainerContents.EMPTY` back into `DataComponents.CONTAINER`, then hands the old contents to `ItemUtils.onContainerDestroyed` as `nonEmptyItemCopyStream()`. That adds one `new ItemEntity(level, entity.getX(), entity.getY(), entity.getZ(), stack)` per filled slot, in slot order. So a shulker box dropped in lava, in fire or on a cactus leaves the stacks it held on the ground, in slot order, and the box itself is gone empty. ## What Horizon got wrong The same hole #7645 closed for bundles: nothing ran an item's `onDestroyed` when its item entity died, and no code read a stack's `container` for a spill at all. The ledger rows `tools/port_map/game2-008.tsv:37` (`BlockItem.onDestroyed`) and `:124` (`ItemUtils.onContainerDestroyed`) said `missing`; both now name the port. `item_data::destroyed_container` is the `container` arm: it empties the component and returns the stacks sorted by slot (`nonEmptyItemCopyStream` walks the 256 slots in order — `ItemData.container` is a `(slot, stack)` list that is not otherwise ordered). `ItemEntity::hurt` spills both arms the stack's components name — a bundle's `bundle_contents` and a container item's `container` — and the tick path #7645 added (`ItemEnvironmentTick.spilled` → `Game::spawn_destroyed_contents`) puts each one in the level where the entity lay. ## Tests `entities::item_destroyed_tests::a_destroyed_shulker_box_spills_its_container` drives `ItemEntity::hurt` — the function `environment_tick` calls for every damage the game does to a dropped item, and whose `spilled` `tick_dropped_items` reads — with a box holding 3 stacks in slots 20, 0 and 3. No prepared data needed. **Fails without the fix, through the path the game calls:** with the `item_data::destroyed_container` call taken out of `ItemEntity::hurt` (the whole fix in that function), `cargo test -q -p horizon-client-lib --lib item_destroyed_tests` fails on the spill assertion: ``` assertion `left == right` failed left: [] right: [("minecraft:oak_log", 8), ("minecraft:cobblestone", 64), ("minecraft:diamond", 4)] ``` The test calls the same `ItemEntity` method the tick calls, not a helper written for the test; and the order in the expected value is the point (`20, 0, 3` in, slots ascending out). **Not proven:** the spawn half (`Game::spawn_destroyed_contents`, from #7645) has no unit test, because a `Game` needs a window, audio and prepared resources; and no in-game burn was driven. `cargo clippy -q -p horizon-items -p horizon-client-lib --lib` is silent, `cargo fmt --all -- --check` is clean, and `cargo test -q -p horizon-client-lib --lib item_destroyed_tests` passes (2 passed). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7754
No description provided.