[PR #6090] [MERGED] Mobs feel instant health and damage, Resistance, Absorption and Slow Falling #6647

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

📋 Pull Request Information

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

Base: main ← Head: fix/mob-effects


📝 Commits (1)

  • e5d3a0e Mobs feel instant health and damage, Resistance, Absorption and Slow Falling

📊 Changes

4 files changed (+165 additions, -13 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+4 -0)
📝 crates/horizon-client/src/mobs.rs (+63 -1)
📝 crates/horizon-client/src/mobs/ai.rs (+79 -0)
📝 crates/horizon-client/src/mobs/living.rs (+19 -12)

📄 Description

🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself.

What and why

Mobs stored their potion effects but most were never acted on. Four effects had no code on the mob side, all found by comparing against the real 26.3 server:

  • /effect give ... instant_health / instant_damage sat in the mob's effect list and never healed or hurt it. The mob effect tick now applies them every tick they have left, as vanilla does (a harming one lands once because of the hit frames; undead are healed by harm and hurt by healing).
  • Resistance did nothing to mobs. A hit now loses 20% per level (bypasses_effects and bypasses_resistance sources skip it, and a fully resisted hit does nothing).
  • Absorption did nothing to mobs. Mobs now carry an absorption amount (saved and shown as AbsorptionAmount), set by the effect (4 per level), soaked before health, and removed when the effect ends.
  • Slow Falling did not change a mob's gravity. The slow-fall cap existed only in a side path; the walking/flying/swimming movement used plain gravity. Both now use one effective_gravity, and a slow-falling mob resets its fall distance, so it no longer takes fall damage.

One shared cause: the mob effect tick and the mob damage path never consulted the effect list. A thrown splash potion's mob path already worked; /summon splash_potion creates no thrown potion at all, which is a separate gap and is not touched here.

Fixes #6087

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Real 26.3 server, same console commands, no player, ticks frozen and stepped. Golems at 100 HP unless noted; "before" is current main, "after" is this change.

Case Vanilla Before After
instant_damage 6 amp 0 / amp 1 (golem 60 HP) 54 / 48 60 / 60 54 / 48
instant_health amp 1 (golem 60 HP) 68, then 100 60 68, then 100
5 damage, resistance amp 4 100 95 100
5 damage, absorption amp 1 Health 100, Absorption 3.0 (8.0 before the hit) 95 / 0.0 100 / 3.0
5 damage, absorption amp 0 99 95 99
slow falling pig, tick 1 Motion y -0.0194 -0.1552 -0.0194
slow falling pig, y after 22 ticks 128.01 114.09 128.01
slow falling pig, landed after 120 ticks alive at y 100 gone (fall damage) alive at y 100

Test

mob_effects_heal_harm_resist_absorb_and_slow_the_fall in mobs/ai.rs covers all four effects, including the undead inversion. With each piece reverted on its own (instant tick, resistance, absorption, gravity cap) it fails on its own assertion (60 vs 68, 95 vs 100, (95, 8) vs (100, 3), 0.08 vs 0.01).

Numbers

Side-by-side scenes (values compared to 1e-5):

  • effects2 (airborne, landing, absorption, resistance): 262/315 before, 315/315 after
  • effects (golem effects over 280 ticks, includes instant_*): 902/980 before, 924/980 after; the remaining 56 are the known amplifier: 0b that Horizon writes into active_effects and vanilla omits (text of data get only)
  • armour: 126/153 before, 130/153 after; the rest are unrelated (Protection IV against generic damage, and player-attack, thorns and freeze rows)

What wasn't compared

  • Potions thrown by a real player or a witch at a mob (not run, no player on the vanilla side); /summon splash_potion makes no projectile on Horizon and was left alone.
  • Absorption on mobs loaded from a saved world beyond a read/write of AbsorptionAmount; the golden hearts shown on a client.
  • Resistance against the enchantment-protection rows (generic with Protection IV still differs) and against modded damage types.
  • Slow Falling in water or lava, on a mount, or with Levitation together.
  • Mod-defined instant effects on mobs.

Proved by script against the real 26.3 server; no human played this change.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on Valhalla, against origin/main at 308ef6527, 5 min 13 s)

Check Result
Scope ✅ 5 files, +165 −13
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 533 passed (20 s)
rustfmt ✅ (6 s)
Rust ⚠️ 1.98.0 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (1 min 35 s)
tests: horizon-client ✅ 1752 passed (3 min 8 s)
doc tests ✅ 0 passed (1 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 ➖ 325 affected, to run in CI (--quick): armor_stand_frost, arrow, auto_jump, block_removal, boat_paddle_reset, boat_submerged, bulk_section, bundle_weight, camera, canyon_carver, carving_geometry, carving_mask and 313 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code

https://claude.ai/code/session_018zuDTsnyHkP28bzn3u7S3m


🔄 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/6090 **Author:** [@HrafnaValkyrja](https://github.com/HrafnaValkyrja) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-effects` --- ### 📝 Commits (1) - [`e5d3a0e`](https://github.com/horizon-rust/horizon/commit/e5d3a0ec6c6a7f051baff33913f4993343572e1e) Mobs feel instant health and damage, Resistance, Absorption and Slow Falling ### 📊 Changes **4 files changed** (+165 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+4 -0) 📝 `crates/horizon-client/src/mobs.rs` (+63 -1) 📝 `crates/horizon-client/src/mobs/ai.rs` (+79 -0) 📝 `crates/horizon-client/src/mobs/living.rs` (+19 -12) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. ## What and why Mobs stored their potion effects but most were never acted on. Four effects had no code on the mob side, all found by comparing against the real 26.3 server: - `/effect give ... instant_health` / `instant_damage` sat in the mob's effect list and never healed or hurt it. The mob effect tick now applies them every tick they have left, as vanilla does (a harming one lands once because of the hit frames; undead are healed by harm and hurt by healing). - Resistance did nothing to mobs. A hit now loses 20% per level (`bypasses_effects` and `bypasses_resistance` sources skip it, and a fully resisted hit does nothing). - Absorption did nothing to mobs. Mobs now carry an absorption amount (saved and shown as `AbsorptionAmount`), set by the effect (4 per level), soaked before health, and removed when the effect ends. - Slow Falling did not change a mob's gravity. The slow-fall cap existed only in a side path; the walking/flying/swimming movement used plain gravity. Both now use one `effective_gravity`, and a slow-falling mob resets its fall distance, so it no longer takes fall damage. One shared cause: the mob effect tick and the mob damage path never consulted the effect list. A thrown splash potion's mob path already worked; `/summon splash_potion` creates no thrown potion at all, which is a separate gap and is not touched here. Fixes #6087 ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Real 26.3 server, same console commands, no player, ticks frozen and stepped. Golems at 100 HP unless noted; "before" is current main, "after" is this change. | Case | Vanilla | Before | After | |---|---|---|---| | instant_damage 6 amp 0 / amp 1 (golem 60 HP) | 54 / 48 | 60 / 60 | 54 / 48 | | instant_health amp 1 (golem 60 HP) | 68, then 100 | 60 | 68, then 100 | | 5 damage, resistance amp 4 | 100 | 95 | 100 | | 5 damage, absorption amp 1 | Health 100, Absorption 3.0 (8.0 before the hit) | 95 / 0.0 | 100 / 3.0 | | 5 damage, absorption amp 0 | 99 | 95 | 99 | | slow falling pig, tick 1 Motion y | -0.0194 | -0.1552 | -0.0194 | | slow falling pig, y after 22 ticks | 128.01 | 114.09 | 128.01 | | slow falling pig, landed after 120 ticks | alive at y 100 | gone (fall damage) | alive at y 100 | ## Test `mob_effects_heal_harm_resist_absorb_and_slow_the_fall` in `mobs/ai.rs` covers all four effects, including the undead inversion. With each piece reverted on its own (instant tick, resistance, absorption, gravity cap) it fails on its own assertion (60 vs 68, 95 vs 100, (95, 8) vs (100, 3), 0.08 vs 0.01). ## Numbers Side-by-side scenes (values compared to 1e-5): - effects2 (airborne, landing, absorption, resistance): 262/315 before, 315/315 after - effects (golem effects over 280 ticks, includes instant_*): 902/980 before, 924/980 after; the remaining 56 are the known `amplifier: 0b` that Horizon writes into `active_effects` and vanilla omits (text of `data get` only) - armour: 126/153 before, 130/153 after; the rest are unrelated (Protection IV against `generic` damage, and player-attack, thorns and freeze rows) ## What wasn't compared - Potions thrown by a real player or a witch at a mob (not run, no player on the vanilla side); `/summon splash_potion` makes no projectile on Horizon and was left alone. - Absorption on mobs loaded from a saved world beyond a read/write of `AbsorptionAmount`; the golden hearts shown on a client. - Resistance against the enchantment-protection rows (`generic` with Protection IV still differs) and against modded damage types. - Slow Falling in water or lava, on a mount, or with Levitation together. - Mod-defined instant effects on mobs. Proved by script against the real 26.3 server; no human played this change. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Valhalla, against origin/main at 308ef6527, 5 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +165 −13 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 533 passed (20 s) | | rustfmt | ✅ (6 s) | | Rust | ⚠️ 1.98.0 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (1 min 35 s) | | tests: horizon-client | ✅ 1752 passed (3 min 8 s) | | doc tests | ✅ 0 passed (1 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 | ➖ 325 affected, to run in CI (--quick): armor_stand_frost, arrow, auto_jump, block_removal, boat_paddle_reset, boat_submerged, bulk_section, bundle_weight, camera, canyon_carver, carving_geometry, carving_mask and 313 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018zuDTsnyHkP28bzn3u7S3m --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:24:20 +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#6647
No description provided.