[PR #6057] [MERGED] Mobs follow each block's landing rule #6631

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

📋 Pull Request Information

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

Base: main ← Head: fix/mob-fall-on-blocks


📝 Commits (1)

  • 2b6ceab Mobs follow each block's landing rule

📊 Changes

8 files changed (+299 additions, -38 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+1 -0)
📝 crates/horizon-client/src/game/creatures.rs (+2 -0)
📝 crates/horizon-client/src/mobs.rs (+3 -0)
📝 crates/horizon-client/src/mobs/ai.rs (+14 -0)
➕ crates/horizon-client/src/mobs/landing.rs (+213 -0)
📝 crates/horizon-client/src/mobs/living.rs (+64 -38)
📝 crates/horizon-client/src/mobs/world.rs (+1 -0)
📝 crates/horizon-client/src/mobs/zombie_villager.rs (+1 -0)

📄 Description

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

No open PR or merged commit covered mob landings (searched gh PRs for "fall damage"; #5536 only added mod-block hooks).

What was wrong

Players run every block's Block.fallOn through the landing registry (crates/horizon-client/src/landing.rs). Mobs did not:
mobs/living.rs::check_fall_damage took the whole fall, with only a hand-written farmland case. So hay, honey, slime,
powder snow, beds and stalagmites did nothing for a pig or cow. A second gap: powder snow's entityInside (makeStuckInBlock: forget the fall)
was never run for mobs, so a mob sinking into snow was hurt on the floor below.

Fix

  • New mobs/landing.rs: MobLanding, a BlockLandingWorld adapter for a mob (sounds, block writes and entity event 54 go out as MobEvents).
  • Mob::fall_on_block calls the registry (MobWorld.landing, new field) with the right entity kind (zombie family, turtle, bat, living). Old trample_farmland removed: the registry's Farmland rule does it.
  • cause_fall_damage_at takes the damage kind (stalagmite) and returns whether it hurt.
  • mobs/ai.rs: powder snow at the mob's feet resets the fall and sets stuck (0.9, 1.5, 0.9), as PowderSnowBlock.entityInside.
  • The registry (landing-definitions.json) has 8 families: Block (default, incl. wool, beds via reduction), Hay, Honey, Slime, PowderSnow, PointedDripstone, Farmland, TurtleEgg. Sweet berries and cobweb have no fallOn; they act through makeStuckInBlock, which mobs already had.

Fixes #6056

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

python3 tools/rea_vanilla.py method net.minecraft.world.level.block.<Class> fallOn:
HayBlock causeFallDamage(d, 0.2); SlimeBlock (d, 0.0) unless suppressing bounce; HoneyBlock slide sound + event 54 + (d, 0.2);
PowderSnowBlock sound only (d >= 4); PointedDripstoneBlock tip-up (d + 2.5, 2.0, stalagmite); FarmlandBlock random < d - 0.5 to dirt;
TurtleEggBlock destroyEgg(3) unless Zombie. BedBlock has no fallOn of its own in bytecode (REA: not found); its halving comes through the base Block path, measured below.

Tests

  • Scene: same commands on a real 26.3 server and on Horizon (13 blocks x pig and cow, dropped 8 blocks, 468 values).
    (First version of the scene was vacuous: neighbouring pits overwrote the landing blocks and negative x put the mob on the wrong block. Fixed in the scene; the old fall scene has the same flaws.)
  • Unit test: mobs::living::tests::a_mob_bounces_off_a_bouncy_block_and_not_off_stone now also checks health after an 8-block fall onto slime 10, stone 5, hay 9, honey 9, bed 9, dripstone 0. Passes.
  • python3 tools/pr_ready.py --quick: rustfmt, clippy, 1713 client tests pass (rc 0). Rust is 1.98, CI uses 1.99.

Vanilla vs Horizon (health after an 8-block fall, start 10; pig and cow identical)

block vanilla Horizon before Horizon after
stone, wool, cobweb, farmland 5 / 5 / 10 / 5 same same
hay 9 5 9
honey 9 5 9
slime 10 5 10
powder snow 10 4 10
bed 9 5 9
pointed dripstone dead 5 dead
sweet berry bush 10 10 10
Scene totals: before 443/468 values match, after 453/468.

What still differs or was not compared

  • Turtle egg: random 1 in 3 break per landing; vanilla breaks it for one of pig/cow, Horizon for the other (vanilla differs from itself between runs). The mechanism works in Horizon now (cow broke the egg); not comparable value for value.
  • Water landing: Pos y 100.902 vs 100.805 (pig), 100.942 vs 100.813 (cow) after 30 ticks. Health matches. Not from fallOn (water has none); a buoyancy difference, not investigated.
  • Not compared: players (a console-only server has none; the player path was already on the registry), sounds, particles, event 54 delivery, neighbour block updates after an egg breaks (block_event/level_event are ignored in the mob adapter), farmland trample outcome (random), mod-block hook distance for a bed-like reduction, horses, llamas, riders, mobs other than pig and cow, other fall heights.
  • Unit test not run against the old code (no stash allowed); "differs before" is from the scene (443 vs 453 matches, numbers above).

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 c05ef84a5, 2 min 46 s)

Check Result
Scope ✅ 9 files, +299 −38
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 525 passed (19 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 ✅ (13 s)
tests: horizon-client ✅ 1713 passed (2 min 4 s)
doc tests ✅ 0 passed (2 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 ➖ 321 affected, to run in CI (--quick): arrow, auto_jump, block_removal, boat_paddle_reset, bulk_section, bundle_weight, camera, canyon_carver, carving_geometry, carving_mask, cauldron, cave_carver and 309 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/6057 **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-fall-on-blocks` --- ### 📝 Commits (1) - [`2b6ceab`](https://github.com/horizon-rust/horizon/commit/2b6ceab8a8b346023077534dfd12c9b0afef306d) Mobs follow each block's landing rule ### 📊 Changes **8 files changed** (+299 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+1 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+2 -0) 📝 `crates/horizon-client/src/mobs.rs` (+3 -0) 📝 `crates/horizon-client/src/mobs/ai.rs` (+14 -0) ➕ `crates/horizon-client/src/mobs/landing.rs` (+213 -0) 📝 `crates/horizon-client/src/mobs/living.rs` (+64 -38) 📝 `crates/horizon-client/src/mobs/world.rs` (+1 -0) 📝 `crates/horizon-client/src/mobs/zombie_villager.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Valkyrie's AI agent (Claude Code, Opus 5.5), not by Valkyrie herself. No open PR or merged commit covered mob landings (searched gh PRs for "fall damage"; #5536 only added mod-block hooks). ## What was wrong Players run every block's `Block.fallOn` through the landing registry (crates/horizon-client/src/landing.rs). Mobs did not: `mobs/living.rs::check_fall_damage` took the whole fall, with only a hand-written farmland case. So hay, honey, slime, powder snow, beds and stalagmites did nothing for a pig or cow. A second gap: powder snow's `entityInside` (makeStuckInBlock: forget the fall) was never run for mobs, so a mob sinking into snow was hurt on the floor below. ## Fix - New `mobs/landing.rs`: `MobLanding`, a `BlockLandingWorld` adapter for a mob (sounds, block writes and entity event 54 go out as MobEvents). - `Mob::fall_on_block` calls the registry (`MobWorld.landing`, new field) with the right entity kind (zombie family, turtle, bat, living). Old `trample_farmland` removed: the registry's Farmland rule does it. - `cause_fall_damage_at` takes the damage kind (stalagmite) and returns whether it hurt. - `mobs/ai.rs`: powder snow at the mob's feet resets the fall and sets stuck (0.9, 1.5, 0.9), as PowderSnowBlock.entityInside. - The registry (landing-definitions.json) has 8 families: Block (default, incl. wool, beds via reduction), Hay, Honey, Slime, PowderSnow, PointedDripstone, Farmland, TurtleEgg. Sweet berries and cobweb have no fallOn; they act through makeStuckInBlock, which mobs already had. Fixes #6056 ## 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 `python3 tools/rea_vanilla.py method net.minecraft.world.level.block.<Class> fallOn`: HayBlock causeFallDamage(d, 0.2); SlimeBlock (d, 0.0) unless suppressing bounce; HoneyBlock slide sound + event 54 + (d, 0.2); PowderSnowBlock sound only (d >= 4); PointedDripstoneBlock tip-up (d + 2.5, 2.0, stalagmite); FarmlandBlock random < d - 0.5 to dirt; TurtleEggBlock destroyEgg(3) unless Zombie. BedBlock has no fallOn of its own in bytecode (REA: not found); its halving comes through the base Block path, measured below. ## Tests - Scene: same commands on a real 26.3 server and on Horizon (13 blocks x pig and cow, dropped 8 blocks, 468 values). (First version of the scene was vacuous: neighbouring pits overwrote the landing blocks and negative x put the mob on the wrong block. Fixed in the scene; the old `fall` scene has the same flaws.) - Unit test: `mobs::living::tests::a_mob_bounces_off_a_bouncy_block_and_not_off_stone` now also checks health after an 8-block fall onto slime 10, stone 5, hay 9, honey 9, bed 9, dripstone 0. Passes. - `python3 tools/pr_ready.py --quick`: rustfmt, clippy, 1713 client tests pass (rc 0). Rust is 1.98, CI uses 1.99. ## Vanilla vs Horizon (health after an 8-block fall, start 10; pig and cow identical) | block | vanilla | Horizon before | Horizon after | |---|---|---|---| | stone, wool, cobweb, farmland | 5 / 5 / 10 / 5 | same | same | | hay | 9 | 5 | 9 | | honey | 9 | 5 | 9 | | slime | 10 | 5 | 10 | | powder snow | 10 | 4 | 10 | | bed | 9 | 5 | 9 | | pointed dripstone | dead | 5 | dead | | sweet berry bush | 10 | 10 | 10 | Scene totals: before 443/468 values match, after 453/468. ## What still differs or was not compared - Turtle egg: random 1 in 3 break per landing; vanilla breaks it for one of pig/cow, Horizon for the other (vanilla differs from itself between runs). The mechanism works in Horizon now (cow broke the egg); not comparable value for value. - Water landing: Pos y 100.902 vs 100.805 (pig), 100.942 vs 100.813 (cow) after 30 ticks. Health matches. Not from fallOn (water has none); a buoyancy difference, not investigated. - Not compared: players (a console-only server has none; the player path was already on the registry), sounds, particles, event 54 delivery, neighbour block updates after an egg breaks (block_event/level_event are ignored in the mob adapter), farmland trample outcome (random), mod-block hook distance for a bed-like reduction, horses, llamas, riders, mobs other than pig and cow, other fall heights. - Unit test not run against the old code (no stash allowed); "differs before" is from the scene (443 vs 453 matches, numbers above). 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 c05ef84a5, 2 min 46 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +299 −38 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 525 passed (19 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 | ✅ (13 s) | | tests: horizon-client | ✅ 1713 passed (2 min 4 s) | | doc tests | ✅ 0 passed (2 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 | ➖ 321 affected, to run in CI (--quick): arrow, auto_jump, block_removal, boat_paddle_reset, bulk_section, bundle_weight, camera, canyon_carver, carving_geometry, carving_mask, cauldron, cave_carver and 309 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:02 +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#6631
No description provided.