[PR #6632] [MERGED] fix(mobs): a hit that bypasses armour, or isn't a horse's, wears no body piece #6999

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6632
Author: @sirrayi
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/mob-hurt-armor-parity


📝 Commits (1)

  • 779ab7d fix(mobs): a hit that bypasses armour, or isn't a horse's, wears no body piece

📊 Changes

2 files changed (+128 additions, -72 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+42 -63)
📝 crates/horizon-client/src/mobs.rs (+86 -9)

📄 Description

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

What and why

#5317 ("every worn piece wears when its mob is hurt") was merged before the deviations its review named were addressed — the review is Joansitoh's agent's, in that PR's thread, and it asked for exactly these. This closes them, and the one further note at the end of it, so ArmorHurt stops differing from vanilla 26.3.

  1. The species gate. hurtArmor is overridden by Horse alone: the base one is empty (LivingEntity.java:1887), and Wolf (Wolf.java:444) and Player (Player.java:727) have their own. The gate was drops::head_is_body(species) minus Wolf, which also matches donkey, mule, skeleton and zombie horse, camel, llama, nautilus, happy ghast and sulfur cube — so /item replace entity @e[type=minecraft:donkey,limit=1] armor.body with minecraft:wolf_armor followed by any hit wore, and eventually broke, a piece vanilla never touches. The gate is now Species::Horse.
  2. #bypasses_armor. Vanilla calls hurtArmor inside getDamageAfterArmorAbsorb, under !source.is(BYPASSES_ARMOR) (LivingEntity.java:1907-1909). Nothing tested it here, so fall, drowning, starvation, void and magic hits wore the piece. A damage type in the tag now asks for nothing.
  3. The amount. doHurtEquipment is handed the damage getDamageAfterArmorAbsorb received — before CombatRules.getDamageAfterAbsorb, the enchantment reduction and the invulnerability window's subtraction. The PR sent dealt, so max(1, damage / 4) came out low: 8 raw damage against plate is 8 / 4 = 2 durability in vanilla, and dealt 3.9 gave 1. The emit now carries that pre-reduction amount.
  4. doHurtEquipment's equippable component. It opens with Equippable equippable = item.get(DataComponents.EQUIPPABLE) and gives up when that is null. wearable checked equip_damage_on_hurt, which defaults to true when the component is absent (horizon-items/src/items.rs), so a damageable item carrying no equippable — a sword put in a horse's body slot by /item replace — wore out. wearable now also requires equip_slot, which is equippable.slot and so present exactly when the component is.

While there, the thing the review's first point implies and the code did not do: Horse.hurtArmor asks doHurtEquipment for EquipmentSlot.BODY alone, so hurt_mob_armor now wears the body piece only. The four-armour-slot loop went with it — a horse with a helmet in armor.head (only /item replace puts one there) wore it here, which vanilla does not.

No issue number: #5317 is merged, so this is a follow-up rather than a fix for a report.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

LivingEntity.hurtArmor (LivingEntity.java:1887, empty), LivingEntity.getDamageAfterArmorAbsorb (:1907-1909), Horse.hurtArmor (Horse.java:233), Wolf.hurtArmor (Wolf.java:444), Player.hurtArmor (Player.java:727), and LivingEntity.doHurtEquipment (Equippable equippable = item.get(DataComponents.EQUIPPABLE), max(1, damage / 4), ItemStack.canBeHurtBy).

No harness reaches this path; mobs::armor_hurt_tests is where it is pinned — three of its four cases fail on the merged code and pass here. The equippable gate needs a live Game, so it is the one part without a test; say the word and I will add a lan_e2e check for it.

Other projects' code

none

Self-check

**pr_ready** (`tools/pr_ready.py --quick` on MacBookPro, against origin/main at db34ce484, 1 min 53 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 2 files, +128 −72 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ❌ 573 run, FAILED (errors=13, skipped=1) (1 min 12 s) |
| rustfmt | ✅ (7 s) |
| clippy | ✅ (10 s) |
| tests: horizon-client, horizon-client-lib | ✅ 1931 passed (21 s) |
| doc tests | ✅ 0 passed (3 s) |
| content root tests | ➖ content root untouched |
| tokens.css up to date | ➖ theme untouched |
| launcher rustfmt | ➖ launcher untouched |
| launcher clippy | ➖ launcher untouched |
| launcher tests | ➖ launcher untouched |
| Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses |

The Python row is this machine rather than the branch: Python 3.9 has no hashlib.file_digest, so all 13 errors are raised inside tools/lab.py before a test body runs.

🤖 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/6632 **Author:** [@sirrayi](https://github.com/sirrayi) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-hurt-armor-parity` --- ### 📝 Commits (1) - [`779ab7d`](https://github.com/horizon-rust/horizon/commit/779ab7dd4cce0247754a657c47af32eb913df3db) fix(mobs): a hit that bypasses armour, or isn't a horse's, wears no body piece ### 📊 Changes **2 files changed** (+128 additions, -72 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+42 -63) 📝 `crates/horizon-client/src/mobs.rs` (+86 -9) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally. ## What and why #5317 ("every worn piece wears when its mob is hurt") was merged before the deviations its review named were addressed — the review is Joansitoh's agent's, in that PR's thread, and it asked for exactly these. This closes them, and the one further note at the end of it, so `ArmorHurt` stops differing from vanilla 26.3. 1. **The species gate.** `hurtArmor` is overridden by `Horse` alone: the base one is empty (`LivingEntity.java:1887`), and `Wolf` (`Wolf.java:444`) and `Player` (`Player.java:727`) have their own. The gate was `drops::head_is_body(species)` minus Wolf, which also matches donkey, mule, skeleton and zombie horse, camel, llama, nautilus, happy ghast and sulfur cube — so `/item replace entity @e[type=minecraft:donkey,limit=1] armor.body with minecraft:wolf_armor` followed by any hit wore, and eventually broke, a piece vanilla never touches. The gate is now `Species::Horse`. 2. **`#bypasses_armor`.** Vanilla calls `hurtArmor` inside `getDamageAfterArmorAbsorb`, under `!source.is(BYPASSES_ARMOR)` (`LivingEntity.java:1907-1909`). Nothing tested it here, so fall, drowning, starvation, void and magic hits wore the piece. A damage type in the tag now asks for nothing. 3. **The amount.** `doHurtEquipment` is handed the damage `getDamageAfterArmorAbsorb` received — before `CombatRules.getDamageAfterAbsorb`, the enchantment reduction and the invulnerability window's subtraction. The PR sent `dealt`, so `max(1, damage / 4)` came out low: 8 raw damage against plate is `8 / 4 = 2` durability in vanilla, and `dealt` 3.9 gave 1. The emit now carries that pre-reduction amount. 4. **`doHurtEquipment`'s `equippable` component.** It opens with `Equippable equippable = item.get(DataComponents.EQUIPPABLE)` and gives up when that is null. `wearable` checked `equip_damage_on_hurt`, which *defaults to true* when the component is absent (`horizon-items/src/items.rs`), so a damageable item carrying no `equippable` — a sword put in a horse's body slot by `/item replace` — wore out. `wearable` now also requires `equip_slot`, which is `equippable.slot` and so present exactly when the component is. While there, the thing the review's first point implies and the code did not do: `Horse.hurtArmor` asks `doHurtEquipment` for `EquipmentSlot.BODY` alone, so `hurt_mob_armor` now wears the body piece only. The four-armour-slot loop went with it — a horse with a helmet in `armor.head` (only `/item replace` puts one there) wore it here, which vanilla does not. No issue number: #5317 is merged, so this is a follow-up rather than a fix for a report. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `LivingEntity.hurtArmor` (`LivingEntity.java:1887`, empty), `LivingEntity.getDamageAfterArmorAbsorb` (`:1907-1909`), `Horse.hurtArmor` (`Horse.java:233`), `Wolf.hurtArmor` (`Wolf.java:444`), `Player.hurtArmor` (`Player.java:727`), and `LivingEntity.doHurtEquipment` (`Equippable equippable = item.get(DataComponents.EQUIPPABLE)`, `max(1, damage / 4)`, `ItemStack.canBeHurtBy`). No harness reaches this path; `mobs::armor_hurt_tests` is where it is pinned — three of its four cases fail on the merged code and pass here. The `equippable` gate needs a live `Game`, so it is the one part without a test; say the word and I will add a `lan_e2e` check for it. ## Other projects' code none ## Self-check ``` **pr_ready** (`tools/pr_ready.py --quick` on MacBookPro, against origin/main at db34ce484, 1 min 53 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +128 −72 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 573 run, FAILED (errors=13, skipped=1) (1 min 12 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (10 s) | | tests: horizon-client, horizon-client-lib | ✅ 1931 passed (21 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | ``` The Python row is this machine rather than the branch: Python 3.9 has no `hashlib.file_digest`, so all 13 errors are raised inside `tools/lab.py` before a test body runs. 🤖 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:31:25 +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#6999
No description provided.