[PR #5317] [MERGED] fix(mobs): every worn piece wears when its mob is hurt #6205

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

📋 Pull Request Information

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

Base: main ← Head: fix/mob-body-armor-wear


📝 Commits (5)

  • 0854972 fix(mobs): a horse's body armour wears when the horse is hurt
  • 009f5d0 fix(mobs): every worn piece wears when its mob is hurt
  • 92bc5e7 refactor(mobs): the equipment-break event comes from the vanilla method
  • 3d5138c fix(mobs): a guest's tool breaking reaches the other clients
  • 6237b86 Revert "fix(mobs): a guest's tool breaking reaches the other clients"

📊 Changes

5 files changed (+202 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+102 -0)
📝 crates/horizon-client/src/mobs.rs (+71 -0)
📝 crates/horizon-client/src/mobs/item_break.rs (+27 -0)
📝 tools/port_map/game-006.tsv (+1 -1)
📝 tools/port_map/game-011.tsv (+1 -1)

📄 Description

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

What and why

Worn equipment on a mob never lost durability. Mob::damage_with had no notion of it, so a horse's body armour stayed at full however often the horse was hit, and no mob's helmet, chestplate, leggings or boots ever wore or broke either — vanilla's LivingEntity.doHurtEquipment (the hurtArmor a hit runs) covers every piece a living entity wears, and the player's own armour already follows it in game.rs::hurt_armor. This closes the Horse.hurtArmor row of #3512 and the mob half of LivingEntity.entityEventForEquipmentBreak in #3514.

  • Mob::damage_with reports a landed hit's dealt amount for a mob wearing body armour (MobEvent::ArmorHurt, carrying the damage kind).
  • game/creatures.rs::Game::hurt_mob_armor applies it, the way the player's path does: max(1, damage / 4) through Game::durability_loss (Unbreaking), nothing for a piece that does not wear when its wearer is hurt (equip_damage_on_hurt), nothing for a fire hit on a fire-resistant piece (canBeHurtBy via the is_fire tag), and at the item's maximum the slot empties and the equipment-break event goes out — 49 to 52 for the armour slots, 65 for the body, which is LivingEntity.entityEventForEquipmentBreak's own mapping.
  • A wolf's body armour keeps its separate Wolf.actuallyHurt rule (hurt_wolf_armor).
  • The same method's client half: a guest's held tool breaking on the host now broadcasts event 47 through Game::lan_entity_event, so the other clients play the break and its crumbs instead of only the window that was simulating (the row's "another player's tool" case).
  • The slot's event id comes from the method itself: item_break::equipment_break_event is LivingEntity.entityEventForEquipmentBreak by name, the inverse of the equipment_break_slot the client side already had, and a test pins the two as inverses over every slot. hurt_mob_armor spells no event number of its own.

Vanilla reference

LivingEntity.hurtArmor → LivingEntity.doHurtEquipment, ItemStack.canBeHurtBy, and LivingEntity.onEquippedItemBroken → entityEventForEquipmentBreak (the slot-to-event table mobs/item_break.rs already decodes for clients).

Tests: mobs::armor_hurt_tests::a_hurt_horse_reports_the_body_armour_wear (a horse wearing diamond horse armour takes a hit and owes a wear; the same horse with no armour owes nothing) and mobs::item_break::tests::the_break_event_and_its_slot_are_inverses. Neither needs prepared game data.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Other projects' code

none

Self-check

cargo fmt --all --check                                     clean
cargo clippy -p horizon-client --lib --bins --tests -- -D warnings
  Finished (no warnings)
cargo test -p horizon-client --lib armor_hurt_tests
  a_hurt_horse_reports_the_body_armour_wear ... ok
python3 tools/check_public_tree.py
  Public tree check passed.

tools/pr_ready.py still cannot run here (Python 3.11+ needed, 3.9 installed) — the block above is its Rust half.

tools/port_map: Horse.hurtArmor is port; LivingEntity.entityEventForEquipmentBreak is inline with what it still misses in its note — now only the saddle (68), the off hand (48), and a host's own tool breaking in a world that is open to LAN.

What I could not verify here: this machine cannot run the game, so the two-player path (a guest's tool breaking, and whether the owning guest's own client sees it twice) is untested. python3 tools/lan_e2e.py --check <name> on a machine with the game data is the check for it; it is guarded by lan_acting, so a single-player window never reaches it.

A correction to my earlier draft of this description: I had written that the window running the world draws no crumbs for its own mobs. That is wrong — every client that receives the event runs remote_equipment_break, which plays the piece's break sound and draws its five crumbs for the slot (mobs/item_break.rs maps the event back to the slot). What I have not verified here is only whether the integrated single-player window receives its own server's entity event; I could not run the game on this machine.

🤖 Generated with DeepSeek Harness (deepseek-v4.1-flash)


🔄 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/5317 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-body-armor-wear` --- ### 📝 Commits (5) - [`0854972`](https://github.com/horizon-rust/horizon/commit/0854972109089d5ad1529efb3aad8f6f287db7ad) fix(mobs): a horse's body armour wears when the horse is hurt - [`009f5d0`](https://github.com/horizon-rust/horizon/commit/009f5d0de41cdb42907496f987a92f3ae9719f09) fix(mobs): every worn piece wears when its mob is hurt - [`92bc5e7`](https://github.com/horizon-rust/horizon/commit/92bc5e77283b96d5aefbb78820bff89fa23dfa59) refactor(mobs): the equipment-break event comes from the vanilla method - [`3d5138c`](https://github.com/horizon-rust/horizon/commit/3d5138cfd6609c42921880553669a9d54d26293b) fix(mobs): a guest's tool breaking reaches the other clients - [`6237b86`](https://github.com/horizon-rust/horizon/commit/6237b86c0b619f7a48dec5772d96e71b060197f2) Revert "fix(mobs): a guest's tool breaking reaches the other clients" ### 📊 Changes **5 files changed** (+202 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+102 -0) 📝 `crates/horizon-client/src/mobs.rs` (+71 -0) 📝 `crates/horizon-client/src/mobs/item_break.rs` (+27 -0) 📝 `tools/port_map/game-006.tsv` (+1 -1) 📝 `tools/port_map/game-011.tsv` (+1 -1) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally. ## What and why Worn equipment on a mob never lost durability. `Mob::damage_with` had no notion of it, so a horse's body armour stayed at full however often the horse was hit, and no mob's helmet, chestplate, leggings or boots ever wore or broke either — vanilla's `LivingEntity.doHurtEquipment` (the `hurtArmor` a hit runs) covers every piece a living entity wears, and the player's own armour already follows it in `game.rs::hurt_armor`. This closes the `Horse.hurtArmor` row of #3512 and the mob half of `LivingEntity.entityEventForEquipmentBreak` in #3514. - `Mob::damage_with` reports a landed hit's dealt amount for a mob wearing body armour (`MobEvent::ArmorHurt`, carrying the damage kind). - `game/creatures.rs::Game::hurt_mob_armor` applies it, the way the player's path does: `max(1, damage / 4)` through `Game::durability_loss` (Unbreaking), nothing for a piece that does not wear when its wearer is hurt (`equip_damage_on_hurt`), nothing for a fire hit on a fire-resistant piece (`canBeHurtBy` via the `is_fire` tag), and at the item's maximum the slot empties and the equipment-break event goes out — 49 to 52 for the armour slots, 65 for the body, which is `LivingEntity.entityEventForEquipmentBreak`'s own mapping. - A wolf's body armour keeps its separate `Wolf.actuallyHurt` rule (`hurt_wolf_armor`). - The same method's client half: a **guest's held tool breaking on the host** now broadcasts event 47 through `Game::lan_entity_event`, so the other clients play the break and its crumbs instead of only the window that was simulating (the row's "another player's tool" case). - The slot's event id comes from the method itself: `item_break::equipment_break_event` is `LivingEntity.entityEventForEquipmentBreak` by name, the inverse of the `equipment_break_slot` the client side already had, and a test pins the two as inverses over every slot. `hurt_mob_armor` spells no event number of its own. ## Vanilla reference `LivingEntity.hurtArmor` → `LivingEntity.doHurtEquipment`, `ItemStack.canBeHurtBy`, and `LivingEntity.onEquippedItemBroken` → `entityEventForEquipmentBreak` (the slot-to-event table `mobs/item_break.rs` already decodes for clients). Tests: `mobs::armor_hurt_tests::a_hurt_horse_reports_the_body_armour_wear` (a horse wearing diamond horse armour takes a hit and owes a wear; the same horse with no armour owes nothing) and `mobs::item_break::tests::the_break_event_and_its_slot_are_inverses`. Neither needs prepared game data. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Other projects' code none ## Self-check ``` cargo fmt --all --check clean cargo clippy -p horizon-client --lib --bins --tests -- -D warnings Finished (no warnings) cargo test -p horizon-client --lib armor_hurt_tests a_hurt_horse_reports_the_body_armour_wear ... ok python3 tools/check_public_tree.py Public tree check passed. ``` `tools/pr_ready.py` still cannot run here (Python 3.11+ needed, 3.9 installed) — the block above is its Rust half. `tools/port_map`: `Horse.hurtArmor` is `port`; `LivingEntity.entityEventForEquipmentBreak` is `inline` with what it still misses in its note — now only the saddle (68), the off hand (48), and a host's own tool breaking in a world that is open to LAN. What I could not verify here: this machine cannot run the game, so the two-player path (a guest's tool breaking, and whether the owning guest's own client sees it twice) is untested. `python3 tools/lan_e2e.py --check <name>` on a machine with the game data is the check for it; it is guarded by `lan_acting`, so a single-player window never reaches it. A correction to my earlier draft of this description: I had written that the window running the world draws no crumbs for its own mobs. That is wrong — every client that receives the event runs `remote_equipment_break`, which plays the piece's break sound and draws its five crumbs for the slot (`mobs/item_break.rs` maps the event back to the slot). What I have not verified here is only whether the integrated single-player window receives its own server's entity event; I could not run the game on this machine. 🤖 Generated with [DeepSeek Harness](https://www.deepseek.com) (deepseek-v4.1-flash) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:15:51 +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#6205
No description provided.