[PR #5242] [MERGED] fix(mobs): a mob landing on a slime block or bed bounces #6161

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

📋 Pull Request Information

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

Base: main ← Head: fix/mobs-bounce-off-bouncy-blocks


📝 Commits (3)

  • 6c50703 fix(mobs): a mob landing on a slime block or bed bounces
  • af096e8 test(mobs): the bounce test's MobWorld takes main's universal_anger rule
  • dc80c54 Merge main into #5242 (MobWorld gained mod_effects)

📊 Changes

2 files changed (+238 additions, -38 deletions)

View changed files

📝 crates/horizon-client/src/mobs/living.rs (+237 -37)
📝 tools/port_map/game-005.tsv (+1 -1)

📄 Description

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

What and why

A mob that lands hard on a block that bounces does not bounce. Mob::do_move rebuilt Entity.restituteMovementAfterCollisions by hand, and the copy only ever used the entity's own bounciness attribute — zero for every mob but a sulfur cube. The block's restitution never reached a mob, so a slime block, a bed or any other block with a bounceRestitution stopped a falling mob dead where vanilla throws it back up. That is the Entity.getBlockBounciness row of #3514 (the port map had it as a gap: player: and the code said "Block bounciness is not modelled for mobs").

This binds mobs to the existing port of that method instead of the hand copy: movement_restitution::restitute_movement, which the player and dropped items already go through and which tools/test_restitution_parity.py compares against vanilla. A MobRestitution view of the mob (crates/horizon-client/src/mobs/living.rs) supplies the mob's fields. Three things follow from using the shared port:

  • the block under the entity now contributes its bounce_restitution (a slime block's 0.8), maxed with the entity's own bounciness as vanilla does;
  • which blocks suppress a bounce is the movement data's suppresses_bounce tag rather than a hardcoded minecraft:honey_block name, so a mob on a block that holds the tag is covered the way every other entity is;
  • the "hard enough to bounce" comparison uses the living entity's effective gravity (0.01 while a Slow Falling mob descends), the accessor the player path uses, instead of the bare gravity attribute.

A mob still never sneaks, so nothing suppresses its own bounce.

tools/port_map/game-005.tsv: the Entity.getBlockBounciness row loses its gap note.

Fixes the Entity.getBlockBounciness row of #3514. Nothing else moves: the guard, the collided components, the air drag and the velocity write are the ones that were already there.

Kind

  • parity: Horizon now does what vanilla 26.3 does

Vanilla reference

Entity.restituteMovementAfterCollisions, whose native port is crates/horizon-world/src/movement_restitution.rs; Entity.getBlockBounciness for the block's contribution; Entity.getOnPos(0.2F) for the block the bounce sees; Entity.getBlockPosBelowThatAffectsMyMovement (Entity.getOnPos(0.500001F)) for the position bounce_on receives; getAttributeValue(BOUNCINESS); LivingEntity.getAirDrag; and the living entity's effective gravity.

Harness: tools/test_restitution_parity.py already compares the phases themselves (entity and block restitution, the living flag, suppressing bounce, gravity, drag), so this change is the binding rather than new arithmetic. The binding gets a unit test, mobs::living::tests::a_mob_bounces_off_a_bouncy_block_and_not_off_stone: a pig dropped from one block up onto a slime block comes back with a positive vertical velocity, onto stone it does not.

I could not run the harnesses or that test body on this machine: it has no .local/ data from a Minecraft install (so the test takes the same early return as its neighbours and CI runs it in full), and tools/pr_ready.py and tools/parity.py need Python 3.11+ (hashlib.file_digest) while only 3.9 is installed. The self-check below is their Rust half, run by hand; tools/port_ledger.py check needs a ledger built from the vanilla jar for the same reason.

Other projects' code

none

Self-check

cargo fmt --all --check
  clean
cargo clippy -p horizon-client --lib --bins --tests -- -D warnings
  Finished `dev` profile [unoptimized + debuginfo] target(s) in 30.78s   (no warnings)
cargo test -p horizon-client --lib --bins --tests
  lib      942 passed, 0 failed, 23 ignored
  bin      360 passed, 0 failed,  3 ignored
  horizon-ctl 18 passed
  tests/   forced_chunks 1, generation_saves 4, lan_bot 12, launch_api 3,
           streaming_meshes 2, tall_column 1, wide_states 1 — 0 failed
  mobs::living::tests::a_mob_bounces_off_a_bouncy_block_and_not_off_stone  ok
             (early return here: no .local/ vanilla data, as its neighbours)
python3 tools/check_public_tree.py
  Public tree check passed.

Harnesses for CI: python3 tools/parity.py --changed origin/main → mob_ai, entity_move and restitution are the ones this file can reach.

Maintainers: please push fixups straight onto the branch if something small is left.

🤖 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/5242 **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/mobs-bounce-off-bouncy-blocks` --- ### 📝 Commits (3) - [`6c50703`](https://github.com/horizon-rust/horizon/commit/6c507031033f29900320ab5c451fd5c33eaf6723) fix(mobs): a mob landing on a slime block or bed bounces - [`af096e8`](https://github.com/horizon-rust/horizon/commit/af096e8ce1021e7476e6e9fd19747a82cf62ed02) test(mobs): the bounce test's MobWorld takes main's universal_anger rule - [`dc80c54`](https://github.com/horizon-rust/horizon/commit/dc80c54eb56160135fa389ae9f2510c372f335c5) Merge main into #5242 (MobWorld gained mod_effects) ### 📊 Changes **2 files changed** (+238 additions, -38 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs/living.rs` (+237 -37) 📝 `tools/port_map/game-005.tsv` (+1 -1) </details> ### 📄 Description > 🤖 Opened by sirrayi's AI agent (DeepSeek Harness, deepseek-v4.1-flash), not by sirrayi personally. ## What and why A mob that lands hard on a block that bounces does not bounce. `Mob::do_move` rebuilt `Entity.restituteMovementAfterCollisions` by hand, and the copy only ever used the entity's own `bounciness` attribute — zero for every mob but a sulfur cube. The block's restitution never reached a mob, so a slime block, a bed or any other block with a `bounceRestitution` stopped a falling mob dead where vanilla throws it back up. That is the `Entity.getBlockBounciness` row of #3514 (the port map had it as a `gap: player:` and the code said "Block bounciness is not modelled for mobs"). This binds mobs to the existing port of that method instead of the hand copy: `movement_restitution::restitute_movement`, which the player and dropped items already go through and which `tools/test_restitution_parity.py` compares against vanilla. A `MobRestitution` view of the mob (`crates/horizon-client/src/mobs/living.rs`) supplies the mob's fields. Three things follow from using the shared port: - the block under the entity now contributes its `bounce_restitution` (a slime block's 0.8), maxed with the entity's own bounciness as vanilla does; - which blocks suppress a bounce is the movement data's `suppresses_bounce` tag rather than a hardcoded `minecraft:honey_block` name, so a mob on a block that holds the tag is covered the way every other entity is; - the "hard enough to bounce" comparison uses the living entity's effective gravity (0.01 while a Slow Falling mob descends), the accessor the player path uses, instead of the bare gravity attribute. A mob still never sneaks, so nothing suppresses its own bounce. `tools/port_map/game-005.tsv`: the `Entity.getBlockBounciness` row loses its gap note. Fixes the `Entity.getBlockBounciness` row of #3514. Nothing else moves: the guard, the collided components, the air drag and the velocity write are the ones that were already there. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does ## Vanilla reference `Entity.restituteMovementAfterCollisions`, whose native port is `crates/horizon-world/src/movement_restitution.rs`; `Entity.getBlockBounciness` for the block's contribution; `Entity.getOnPos(0.2F)` for the block the bounce sees; `Entity.getBlockPosBelowThatAffectsMyMovement` (`Entity.getOnPos(0.500001F)`) for the position `bounce_on` receives; `getAttributeValue(BOUNCINESS)`; `LivingEntity.getAirDrag`; and the living entity's effective gravity. Harness: `tools/test_restitution_parity.py` already compares the phases themselves (entity and block restitution, the living flag, suppressing bounce, gravity, drag), so this change is the binding rather than new arithmetic. The binding gets a unit test, `mobs::living::tests::a_mob_bounces_off_a_bouncy_block_and_not_off_stone`: a pig dropped from one block up onto a slime block comes back with a positive vertical velocity, onto stone it does not. I could not run the harnesses or that test body on this machine: it has no `.local/` data from a Minecraft install (so the test takes the same early return as its neighbours and CI runs it in full), and `tools/pr_ready.py` and `tools/parity.py` need Python 3.11+ (`hashlib.file_digest`) while only 3.9 is installed. The self-check below is their Rust half, run by hand; `tools/port_ledger.py check` needs a ledger built from the vanilla jar for the same reason. ## Other projects' code none ## Self-check ``` cargo fmt --all --check clean cargo clippy -p horizon-client --lib --bins --tests -- -D warnings Finished `dev` profile [unoptimized + debuginfo] target(s) in 30.78s (no warnings) cargo test -p horizon-client --lib --bins --tests lib 942 passed, 0 failed, 23 ignored bin 360 passed, 0 failed, 3 ignored horizon-ctl 18 passed tests/ forced_chunks 1, generation_saves 4, lan_bot 12, launch_api 3, streaming_meshes 2, tall_column 1, wide_states 1 — 0 failed mobs::living::tests::a_mob_bounces_off_a_bouncy_block_and_not_off_stone ok (early return here: no .local/ vanilla data, as its neighbours) python3 tools/check_public_tree.py Public tree check passed. ``` Harnesses for CI: `python3 tools/parity.py --changed origin/main` → `mob_ai`, `entity_move` and `restitution` are the ones this file can reach. Maintainers: please push fixups straight onto the branch if something small is left. 🤖 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:09 +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#6161
No description provided.