[PR #5639] [MERGED] Mobs keep the whole ItemStack in each equipment slot #6407

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5639
Author: @rdbtCVS
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/mob-equipment-itemstack


📝 Commits (1)

  • d4941b1 Mobs keep the whole stack in each equipment slot

📊 Changes

7 files changed (+193 additions, -40 deletions)

View changed files

📝 crates/horizon-client/examples/probe/entity_death_loot_fixture.rs (+2 -0)
📝 crates/horizon-client/src/entity_nbt.rs (+60 -0)
📝 crates/horizon-client/src/game/creatures.rs (+3 -0)
📝 crates/horizon-client/src/game/mob_looting.rs (+21 -27)
📝 crates/horizon-client/src/mobs/drops.rs (+41 -4)
📝 crates/horizon-client/src/mobs/finalize.rs (+48 -6)
📝 crates/horizon-client/src/mobs/gear.rs (+18 -3)

📄 Description

🤖 Opened by rdbtCVS's AI agent (Claude Code, Sonnet 5.5), not by rdbtCVS personally.

Mob equipment was an item id plus an enchantment list and trim, so anything a mob picked up lost its damage, name and components: a hand took one item of a stack, a worn piece always compared as fresh in canReplaceCurrentItem, and a replaced or dead-mob drop came back repaired and unnamed (a free repair).

  • Gear.stacks holds the whole stack of an armour or off-hand slot when it is more than one plain item (the main hand already had Extra::main_hand_stack). finalize::set_item_stack / stored_stack / item_stack read and write it; replacing the item forgets it, as before for enchantments and trim.
  • Mob.equipItemIfPossible: the whole stack goes into a hand (one item into an armour slot, EquipmentSlot.limit), and the replaced stack is dropped as it was.
  • canReplaceCurrentItem compares the worn piece's real damage and name.
  • Death drops the kept stack itself (Drop::Stack), with the rolled damage when the drop is not preserved, as before.
  • The entity save writes the kept stack and the load reads it.

Added a save round-trip test (damage and name survive; replacing the item resets them). python3 tools/parity.py entity_death_loot passes. Not run: the other harnesses, lan_e2e.

Not covered: dispenser and piglin equip paths still set ids only; they can use set_item_stack next.

🤖 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/5639 **Author:** [@rdbtCVS](https://github.com/rdbtCVS) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-equipment-itemstack` --- ### 📝 Commits (1) - [`d4941b1`](https://github.com/horizon-rust/horizon/commit/d4941b115500519bb3c093a1e7fa5591e17d35b3) Mobs keep the whole stack in each equipment slot ### 📊 Changes **7 files changed** (+193 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/entity_death_loot_fixture.rs` (+2 -0) 📝 `crates/horizon-client/src/entity_nbt.rs` (+60 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+3 -0) 📝 `crates/horizon-client/src/game/mob_looting.rs` (+21 -27) 📝 `crates/horizon-client/src/mobs/drops.rs` (+41 -4) 📝 `crates/horizon-client/src/mobs/finalize.rs` (+48 -6) 📝 `crates/horizon-client/src/mobs/gear.rs` (+18 -3) </details> ### 📄 Description > 🤖 Opened by rdbtCVS's AI agent (Claude Code, Sonnet 5.5), not by rdbtCVS personally. Mob equipment was an item id plus an enchantment list and trim, so anything a mob picked up lost its damage, name and components: a hand took one item of a stack, a worn piece always compared as fresh in `canReplaceCurrentItem`, and a replaced or dead-mob drop came back repaired and unnamed (a free repair). - `Gear.stacks` holds the whole stack of an armour or off-hand slot when it is more than one plain item (the main hand already had `Extra::main_hand_stack`). `finalize::set_item_stack` / `stored_stack` / `item_stack` read and write it; replacing the item forgets it, as before for enchantments and trim. - `Mob.equipItemIfPossible`: the whole stack goes into a hand (one item into an armour slot, `EquipmentSlot.limit`), and the replaced stack is dropped as it was. - `canReplaceCurrentItem` compares the worn piece's real damage and name. - Death drops the kept stack itself (`Drop::Stack`), with the rolled damage when the drop is not preserved, as before. - The entity save writes the kept stack and the load reads it. Added a save round-trip test (damage and name survive; replacing the item resets them). `python3 tools/parity.py entity_death_loot` passes. Not run: the other harnesses, `lan_e2e`. Not covered: dispenser and piglin equip paths still set ids only; they can use `set_item_stack` next. 🤖 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 06:20:06 +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#6407
No description provided.