[PR #690] [MERGED] Mobs float in water instead of bouncing #2732

Closed
opened 2026-11-02 15:58:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/mob-float


📝 Commits (1)

  • 62f96e9 Mobs float in water instead of bouncing

📊 Changes

8 files changed (+181 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/mobs.rs (+3 -0)
📝 crates/horizon-client/src/mobs/ai.rs (+18 -4)
📝 crates/horizon-client/src/mobs/equine.rs (+20 -6)
📝 crates/horizon-client/src/mobs/goals.rs (+4 -0)
📝 crates/horizon-client/src/mobs/living.rs (+110 -5)
📝 crates/horizon-client/src/mobs/species.rs (+10 -1)
📝 crates/horizon-client/src/mobs/tame.rs (+10 -1)
📝 tools/test_mob_ai_parity.py (+6 -0)

📄 Description

What and why

Fixes #542.

FloatGoal's constructor calls navigation.setCanFloat(true), and Mob.jumpInLiquid uses that flag: floaters rise 0.04F a tick, other mobs 0.3. Horizon set the flag by hand for a few species only (villager, rabbit, bee, sniffer...). Every other FloatGoal user (pigs, cows, sheep, wolves, cats, horses, witches, vindicators, creepers, spiders...) took the 0.3 jump and bounced out of the water. In game on main, a pig in deep water went from y 63.6 to 68 and back (surface at 65). With this PR it stays at 64.4 to 64.7.

  • ai::register sets can_float when a Float goal is registered, plus the species whose constructors set it themselves (allay, armadillo, camel, goat, parrot, wither). Zombies, skeletons and golems have no float goal and still sink.
  • jumpInLiquid adds 0.04F as a float, as vanilla does (f64::from(0.04f32)).
  • Mobs that drop back into water splash: Entity.updateFluidInteraction -> doWaterSplashEffect (not on the first tick), from the base tick and from LivingEntity.checkFallDamage, through the shared water_splash kernel. They get their getSwimSplashSound (hostile for monsters and hoglins, the dolphin's and the axolotl's own), the bubble/splash particles and the SPLASH game event. A floating mob bobs out and back in, so vanilla splashes here every few seconds. One gap: a mob ridden by the player splashes with its own velocity, not its rider's (Horizon's mob tick doesn't see the player as a controlling passenger).

The new scenarios caught three more divergences in the same mobs:

  • Horses: AbstractHorse.addBehaviourGoals runs after the other goals (Float, MountPanic, Tempt last). The skeleton horse has none (it sinks), and the zombie horse has no mount panic.
  • RandomStandGoal waits -getAmbientStandInterval(), which is 400 for every AbstractHorse, not 80. The ambient interval table now has 400 for the zombie and skeleton horses and the camels too.
  • CatSitOnBlockGoal checks tame and not sitting before MoveToBlockGoal.canUse, which draws its next delay only when the last one ran out. Horizon drew it on every call.

Vanilla reference

FloatGoal, Mob.jumpInLiquid, LivingEntity.jumpInLiquid, Entity.updateFluidInteraction / doWaterSplashEffect / getSwimSplashSound (and the Monster/Hoglin/Dolphin/Axolotl overrides), LivingEntity.checkFallDamage, AbstractHorse.registerGoals / addBehaviourGoals / getAmbientSoundInterval, SkeletonHorse / ZombieHorse.addBehaviourGoals, RandomStandGoal, CatSitOnBlockGoal, MoveToBlockGoal.canUse.

Harness: 8 new mob_ai scenarios, <species>_deep_water: pig, cow, wolf, cat, horse, witch, vindicator, plus zombie as the sinking control, each dropped into a 4-deep pool for 160 ticks. With the float flag and 0.04F alone, they matched until the mobs first broke the surface (around tick 20), where vanilla splashes. With the whole PR, 8/8 scenarios match all 161 ticks (positions, velocities, random draws and sounds).

Self-check

One integration commit of this PR with #689 and #691, on origin/main 5d027877 (Mac mini):

cargo fmt --all --check                                     ok
cargo clippy --workspace --all-targets -- -D warnings       ok
cargo test -p horizon-client --lib                          806 passed, 0 failed (11 ignored)
python3 tools/test_mob_ai_parity.py --only _deep_water      8/8 scenarios match, 1288/1288 mob-ticks
python3 tools/parity.py --changed origin/main               86/86 affected harnesses pass, 0 failed

🤖 Generated with Claude Code


🔄 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/690 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-float` --- ### 📝 Commits (1) - [`62f96e9`](https://github.com/horizon-rust/horizon/commit/62f96e9d65f77ed261ad1d14f4cff5fe5ce37a33) Mobs float in water instead of bouncing ### 📊 Changes **8 files changed** (+181 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/mobs.rs` (+3 -0) 📝 `crates/horizon-client/src/mobs/ai.rs` (+18 -4) 📝 `crates/horizon-client/src/mobs/equine.rs` (+20 -6) 📝 `crates/horizon-client/src/mobs/goals.rs` (+4 -0) 📝 `crates/horizon-client/src/mobs/living.rs` (+110 -5) 📝 `crates/horizon-client/src/mobs/species.rs` (+10 -1) 📝 `crates/horizon-client/src/mobs/tame.rs` (+10 -1) 📝 `tools/test_mob_ai_parity.py` (+6 -0) </details> ### 📄 Description ## What and why Fixes #542. `FloatGoal`'s constructor calls `navigation.setCanFloat(true)`, and `Mob.jumpInLiquid` uses that flag: floaters rise `0.04F` a tick, other mobs `0.3`. Horizon set the flag by hand for a few species only (villager, rabbit, bee, sniffer...). Every other FloatGoal user (pigs, cows, sheep, wolves, cats, horses, witches, vindicators, creepers, spiders...) took the 0.3 jump and bounced out of the water. In game on main, a pig in deep water went from y 63.6 to 68 and back (surface at 65). With this PR it stays at 64.4 to 64.7. - `ai::register` sets `can_float` when a `Float` goal is registered, plus the species whose constructors set it themselves (allay, armadillo, camel, goat, parrot, wither). Zombies, skeletons and golems have no float goal and still sink. - `jumpInLiquid` adds `0.04F` as a float, as vanilla does (`f64::from(0.04f32)`). - Mobs that drop back into water splash: `Entity.updateFluidInteraction` -> `doWaterSplashEffect` (not on the first tick), from the base tick and from `LivingEntity.checkFallDamage`, through the shared `water_splash` kernel. They get their `getSwimSplashSound` (hostile for monsters and hoglins, the dolphin's and the axolotl's own), the bubble/splash particles and the SPLASH game event. A floating mob bobs out and back in, so vanilla splashes here every few seconds. One gap: a mob ridden by the player splashes with its own velocity, not its rider's (Horizon's mob tick doesn't see the player as a controlling passenger). The new scenarios caught three more divergences in the same mobs: - Horses: `AbstractHorse.addBehaviourGoals` runs after the other goals (Float, MountPanic, Tempt last). The skeleton horse has none (it sinks), and the zombie horse has no mount panic. - `RandomStandGoal` waits `-getAmbientStandInterval()`, which is 400 for every `AbstractHorse`, not 80. The ambient interval table now has 400 for the zombie and skeleton horses and the camels too. - `CatSitOnBlockGoal` checks tame and not sitting before `MoveToBlockGoal.canUse`, which draws its next delay only when the last one ran out. Horizon drew it on every call. ## Vanilla reference `FloatGoal`, `Mob.jumpInLiquid`, `LivingEntity.jumpInLiquid`, `Entity.updateFluidInteraction` / `doWaterSplashEffect` / `getSwimSplashSound` (and the Monster/Hoglin/Dolphin/Axolotl overrides), `LivingEntity.checkFallDamage`, `AbstractHorse.registerGoals` / `addBehaviourGoals` / `getAmbientSoundInterval`, `SkeletonHorse` / `ZombieHorse.addBehaviourGoals`, `RandomStandGoal`, `CatSitOnBlockGoal`, `MoveToBlockGoal.canUse`. Harness: 8 new `mob_ai` scenarios, `<species>_deep_water`: pig, cow, wolf, cat, horse, witch, vindicator, plus zombie as the sinking control, each dropped into a 4-deep pool for 160 ticks. With the float flag and `0.04F` alone, they matched until the mobs first broke the surface (around tick 20), where vanilla splashes. With the whole PR, **8/8 scenarios match all 161 ticks** (positions, velocities, random draws and sounds). ## Self-check One integration commit of this PR with #689 and #691, on origin/main 5d027877 (Mac mini): ``` cargo fmt --all --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-client --lib 806 passed, 0 failed (11 ignored) python3 tools/test_mob_ai_parity.py --only _deep_water 8/8 scenarios match, 1288/1288 mob-ticks python3 tools/parity.py --changed origin/main 86/86 affected harnesses pass, 0 failed ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:58:39 +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#2732
No description provided.