[GH-ISSUE #3889] Explosion drops merge with a hardcoded 16 stack size and drop item components #1132

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

Originally created by @ccclosed on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3889

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

Severity: Medium — dropped items merge into invalid stacks and lose components
Snapshot: origin/main 7c1e0f979 (2026-10-30)

What happens

Explosion drops are merged by item + damage with a hardcoded 16 limit, ignoring the item's actual max stack size and its components:

  • crates/horizon-client/src/game/explosion.rs:712-728 — add_or_append_stack: existing.item == stack.item && existing.damage == stack.damage && existing.count < 16.

Consequences on a normal explosion (TNT, creeper, bed, crystal):

  1. Two max-stack-1 items (swords, books, potions, tools, armour) that survive the blast merge into one count-2 stack — an invalid stack the rest of the code treats as one item (it can then be split/duped by the normal inventory code).
  2. Two stacks of the same item with different components (custom name, enchantments, potion data, banner pattern…) merge, and the second stack's components are silently dropped — the merged stack takes the first one's data.
  3. Items with a larger max stack (e.g. ender pearls) are artificially capped at 16 per merged pile.

Repro

Blow up two dropped enchanted books / two named swords / a stack of potions with TNT and pick the result up: one stack with count 2 and only the first item's components.

Expected

Vanilla ItemEntity merging uses ItemStack.isSameItemSameComponents and the item's own getMaxStackSize().

Suggested fix

Use the item's max stack size and same_item_same_components in add_or_append_stack (the audit's container sweep lists this as the same class as the count-0 stack invariant; happy to provide the minimal test).

Originally created by @ccclosed on GitHub (Oct 29, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3889 > 🤖 Filed by ccclosed's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by ccclosed personally. **Severity:** Medium — dropped items merge into invalid stacks and lose components **Snapshot:** `origin/main` `7c1e0f979` (2026-10-30) ### What happens Explosion drops are merged by `item` + `damage` with a **hardcoded 16** limit, ignoring the item's actual max stack size and its components: - `crates/horizon-client/src/game/explosion.rs:712-728` — `add_or_append_stack`: `existing.item == stack.item && existing.damage == stack.damage && existing.count < 16`. Consequences on a normal explosion (TNT, creeper, bed, crystal): 1. Two max-stack-1 items (swords, books, potions, tools, armour) that survive the blast merge into **one count-2 stack** — an invalid stack the rest of the code treats as one item (it can then be split/duped by the normal inventory code). 2. Two stacks of the same item with **different components** (custom name, enchantments, potion data, banner pattern…) merge, and the second stack's components are silently dropped — the merged stack takes the first one's data. 3. Items with a *larger* max stack (e.g. ender pearls) are artificially capped at 16 per merged pile. ### Repro Blow up two dropped enchanted books / two named swords / a stack of potions with TNT and pick the result up: one stack with count 2 and only the first item's components. ### Expected Vanilla `ItemEntity` merging uses `ItemStack.isSameItemSameComponents` and the item's own `getMaxStackSize()`. ### Suggested fix Use the item's max stack size and `same_item_same_components` in `add_or_append_stack` (the audit's container sweep lists this as the same class as the count-0 stack invariant; happy to provide the minimal test).
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#1132
No description provided.