[PR #287] [MERGED] Bats hang upside down and fly, with their wing animations #2457

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

📋 Pull Request Information

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

Base: main ← Head: fix/bat-flight


📝 Commits (1)

  • 2bcb30b Bats hang upside down and fly, with their wing animations (#215)

📊 Changes

7 files changed (+185 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+7 -0)
📝 crates/horizon-client/src/mobs.rs (+10 -3)
📝 crates/horizon-client/src/mobs/ai.rs (+13 -0)
➕ crates/horizon-client/src/mobs/bat.rs (+143 -0)
📝 crates/horizon-client/src/mobs/living.rs (+2 -2)
📝 crates/horizon-client/src/mobs/species.rs (+1 -1)
📝 tools/test_mob_ai_parity.py (+9 -0)

📄 Description

Fixes #215. Stacked on #285 (strider); merge that first, this then retargets to main.

What

Bats had no AI of their own (Horizon's generic land-animal fallback walked them about) and their animation states were never started, so they neither flew nor flapped. This ports vanilla 26.3 Bat:

  • a new bat hangs (setResting(true) in the constructor); customServerAiStep: hanging from a redstone-conductor block above, turning its head now and then, taking off (level event 1025, entity.bat.takeoff) when a player comes within 4 blocks or the block goes; in flight, a new random target every ~30 ticks or when reached or blocked, steering towards it, and hanging up again under a solid block 1 time in 100
  • Bat.tick: held to the ceiling while resting, vertical speed ×0.6 in flight, then setupAnimationStates (flying / resting keyframes, which BatModel already had)
  • waking when hurt, BatFlags saved and loaded, no fall damage, movement events without sounds, voice pitch ×0.95
  • bats are not omnidirectional air movers in 26.3 (only bees, parrots and sulfur cubes are): their vertical drag is 0.98 like other mobs

Note for ports: Math.signum(0.0) is 0 but Rust's f64::signum(0.0) is 1; a bat level with its target used to climb into the ceiling.

Proof

Mob AI parity harness, six new bat scenarios (hanging alone, woken by a player beneath, flying with nothing above, three in a closed cave):

scenarios mob-ticks before first divergence
main (via #285) 0/6 6/1906
this PR 6/6 1906/1906

Self-check

  • cargo fmt --all --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test -p horizon-client --lib: 596 passed
  • tools/test_mob_ai_parity.py (full): 111/111 scenarios, 37339/37339 mob-ticks
  • In game: screenshots follow in a comment.

Needs Ludovic

Nothing.

🤖 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/287 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/bat-flight` --- ### 📝 Commits (1) - [`2bcb30b`](https://github.com/horizon-rust/horizon/commit/2bcb30b375437d3d42720f5ec9d73d1adfde2a70) Bats hang upside down and fly, with their wing animations (#215) ### 📊 Changes **7 files changed** (+185 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+7 -0) 📝 `crates/horizon-client/src/mobs.rs` (+10 -3) 📝 `crates/horizon-client/src/mobs/ai.rs` (+13 -0) ➕ `crates/horizon-client/src/mobs/bat.rs` (+143 -0) 📝 `crates/horizon-client/src/mobs/living.rs` (+2 -2) 📝 `crates/horizon-client/src/mobs/species.rs` (+1 -1) 📝 `tools/test_mob_ai_parity.py` (+9 -0) </details> ### 📄 Description Fixes #215. Stacked on #285 (strider); merge that first, this then retargets to main. ## What Bats had no AI of their own (Horizon's generic land-animal fallback walked them about) and their animation states were never started, so they neither flew nor flapped. This ports vanilla 26.3 `Bat`: - a new bat hangs (`setResting(true)` in the constructor); `customServerAiStep`: hanging from a redstone-conductor block above, turning its head now and then, taking off (level event 1025, `entity.bat.takeoff`) when a player comes within 4 blocks or the block goes; in flight, a new random target every ~30 ticks or when reached or blocked, steering towards it, and hanging up again under a solid block 1 time in 100 - `Bat.tick`: held to the ceiling while resting, vertical speed ×0.6 in flight, then `setupAnimationStates` (flying / resting keyframes, which `BatModel` already had) - waking when hurt, `BatFlags` saved and loaded, no fall damage, movement events without sounds, voice pitch ×0.95 - bats are not omnidirectional air movers in 26.3 (only bees, parrots and sulfur cubes are): their vertical drag is 0.98 like other mobs Note for ports: `Math.signum(0.0)` is 0 but Rust's `f64::signum(0.0)` is 1; a bat level with its target used to climb into the ceiling. ## Proof Mob AI parity harness, six new bat scenarios (hanging alone, woken by a player beneath, flying with nothing above, three in a closed cave): | | scenarios | mob-ticks before first divergence | |---|---|---| | main (via #285) | 0/6 | 6/1906 | | this PR | **6/6** | **1906/1906** | ## Self-check - `cargo fmt --all --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test -p horizon-client --lib`: 596 passed - `tools/test_mob_ai_parity.py` (full): **111/111 scenarios, 37339/37339 mob-ticks** - In game: screenshots follow in a comment. ## Needs Ludovic Nothing. 🤖 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:56:19 +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#2457
No description provided.