[PR #3659] [MERGED] Let parrots fly: flying navigation and move control, flapping and gliding #5132

Closed
opened 2026-11-03 05:10:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3659
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3091


📝 Commits (2)

  • 9fa7ddd Let parrots fly: flying navigation and move control, flapping and gliding
  • e09cbf2 Merge origin/main into fix-3091

📊 Changes

8 files changed (+246 additions, -25 deletions)

View changed files

📝 crates/horizon-client/examples/probe/mob_ai_probe.rs (+1 -0)
📝 crates/horizon-client/src/game/remote.rs (+6 -0)
📝 crates/horizon-client/src/mobs/ai.rs (+2 -1)
📝 crates/horizon-client/src/mobs/goals.rs (+24 -16)
📝 crates/horizon-client/src/mobs/living.rs (+6 -1)
📝 crates/horizon-client/src/mobs/parrot.rs (+191 -3)
📝 crates/horizon-client/src/mobs/tame.rs (+7 -4)
📝 tools/test_mob_ai_parity.py (+9 -0)

📄 Description

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

What and why

Fixes #3091

The port ledger has no port for Parrot.createNavigation or Parrot.calculateFlapping, as kacpherek pointed out. So a parrot used the ground move control and ground navigation: it walked and hopped, fell at full gravity when pushed off a block, and never flew, tame or not. Its wings never flapped either, because nothing ticked flap and flapSpeed for parrots.

This PR ports the parrot's flight:

  • Parrot():
    • FlyingMoveControl(this, 10, false). Without hoversInPlace, it turns gravity back on when it has no wanted point, so a parrot with nowhere to go comes down.
    • The FIRE_IN_NEIGHBOR, FIRE and COCOA path maluses at -1.
  • createNavigation: a FlyingPathNavigation with setCanOpenDoors(false) and setCanFloat(true).
  • ParrotWanderGoal.getPosition, in place of the plain water-avoiding stroll the parrot had:
    • In water: LandRandomPos.getPos(15, 15).
    • Then, unless the 1-in-1000 roll fails: getTreePos, the first empty block with an empty block above, over leaves or a #logs block, within ±3/±6/±3, walked in BlockPos.betweenClosed order.
    • If both give nothing: WaterAvoidingRandomFlyingGoal.getPosition. That code already existed inside Stroll::flying; this PR moves it into Mob::flying_stroll_pos so both goals share it.
  • calculateFlapping, at the end of aiStep:
    • flapSpeed goes up by 1.2 in the air and down by 0.3 on the ground or as a passenger. flapping restarts at 1 in the air and decays by 0.9, and flap turns by flapping * 2.
    • A parrot falling through the air keeps 0.6 of its downward speed (the glide).
    • A multiplayer client runs the wing part for the parrots it displays, as it already does for chickens.
  • isFlapping / onFlap, called from Entity.processFlappingMovement when a move ends in air: an entity.parrot.fly sound (volume 0.15), then nextFlap = flyDist + flapSpeed / 2.
  • canFlyToOwner: TamableAnimal.canTeleportTo lets a parrot teleport onto leaves next to its owner.

Not in this PR: the parrot's FollowMobGoal(1.0, 3, 7) (priority 3), which has no port yet. It is a separate goal, it doesn't change how a parrot flies, and none of the scenarios below has another mob for it to follow. Also not here: the GameEvent.FLAP vibration that processFlappingMovement sends after onFlap. Horizon's mobs don't send that event for any flying mob yet, and wardens ignore it.

Vanilla reference

  • net.minecraft.world.entity.animal.parrot.Parrot.<init>, createNavigation, registerGoals, aiStep, calculateFlapping, isFlapping, onFlap, isFlying, canFlyToOwner
  • Parrot$ParrotWanderGoal.getPosition and getTreePos
  • WaterAvoidingRandomFlyingGoal.getPosition (HoverRandomPos.getPos(8, 7, …, π/2, 3, 1), else AirAndWaterRandomPos.getPos(8, 4, -2, …))
  • FlyingMoveControl.tick
  • Entity.applyMovementEmissionAndPlaySound → processFlappingMovement
  • TamableAnimal.canTeleportTo

Harness: tools/test_mob_ai_parity.py (VanillaMobAiOracle against mob_ai_probe).

Tests

Parity harness. tools/test_mob_ai_parity.py gets four parrot scenarios:

  • parrot_alone_0 and parrot_alone_1: on open grass, 400 ticks.
  • parrot_tree: by an oak log under a leaf canopy, 400 ticks.
  • parrot_falling: let go 10 blocks up, 100 ticks.

They run on Peaceful because Parrot.getAmbient draws its 1-in-1000 imitation roll from the level's random, which the probe doesn't share. That ambient-sound difference is older than this change and separate from flight.

Before, on main's code with only the new scenarios added. Every parrot diverges on its first tick, because vanilla's fall is slowed to 0.6 and Horizon's isn't:

parrot_alone_0 mob 0: first divergence at tick 1 of 401 (random draws this tick: vanilla 3, horizon 3)
    v: vanilla 0,-0.0436800012588501,0 | horizon 0,-0.0728000020980835,0
...
parrot_tree: sounds differ at tick 74: vanilla ['minecraft:entity.parrot.fly 3e19999a 3f800000'] | horizon []
parrot_falling: sounds differ at tick 20: vanilla ['minecraft:entity.parrot.fly 3e19999a 3f800000'] | horizon []
0/4 scenarios match entirely; 4/1304 mob-ticks match before each mob's first divergence

After, with neighbouring flying, tame and farm scenarios also run to check for regressions (the shared flying stroll, the tame goals, the chicken's flapping):

chicken_player: all 201 ticks match
chicken_alone: all 201 ticks match
wither_player: all 201 ticks match
llama_wolf: all 201 ticks match
feed_chicken: all 81 ticks match
feed_chicken_baby: all 81 ticks match
bee_alone_0: all 401 ticks match
bee_alone_1: all 401 ticks match
parrot_alone_0: all 401 ticks match
parrot_alone_1: all 401 ticks match
parrot_tree: all 401 ticks match
parrot_falling: all 101 ticks match
wolf_deep_water: all 161 ticks match
peaceful_type_wither: all 2 ticks match
peaceful_type_wolf: all 2 ticks match
15/15 scenarios match entirely; 3438/3438 mob-ticks match before each mob's first divergence

Unit tests in mobs::parrot::tests, all passing:

  • the move control, navigation, maluses and wander goal a parrot is registered with;
  • calculateFlapping's wing values and the 0.6 glide (none while rising, on a shoulder, or on the ground);
  • the entity.parrot.fly wing beat each half flapSpeed flown.

In game

I ran a scripted singleplayer creative world with horizon-ctl: a 25×25 grass platform with open air above.

  • A parrot summoned 10 blocks up, its height sampled every 5 ticks:
    • Before (main): 0.48, 0, 0, …. It drops to the floor within the first sample.
    • After: 9.80, 9.25, 8.67, 7.79, 7.04, 6.46, 5.88, 5.11, 4.54, 3.77, 3.17, 3.03. It glides down with its wings spread.
  • Five parrots summoned on the grass, the highest each got over 30 s:
    • Before: 0, 0, 0, 0, 0. They only walk.
    • After: 1.06, 1.98, 2.28, 3.19, 1.17 blocks. The mid-run screenshot shows them in the air in the flying pose.

Self-check

cargo fmt --all -- --check
cargo clippy --profile fast -p horizon-client --features mods --all-targets -- -D warnings
cargo test --profile fast -p horizon-client --features mods --lib -- mobs::parrot mobs::farm mobs::tame mobs::allay mobs::bee
python3 tools/test_mob_ai_parity.py --only parrot wither bee_alone chicken wolf
cargo build --profile fast -p horizon-client --features mods --bins

(tools/pr_ready.py doesn't run on Windows, so these are the steps it would run, by hand.)

🤖 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/3659 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3091` --- ### 📝 Commits (2) - [`9fa7ddd`](https://github.com/horizon-rust/horizon/commit/9fa7dddbe49e2a4c87b11d7ed15ae32df539faa4) Let parrots fly: flying navigation and move control, flapping and gliding - [`e09cbf2`](https://github.com/horizon-rust/horizon/commit/e09cbf2b9e9e087ec62374de705ea3c8a454263d) Merge origin/main into fix-3091 ### 📊 Changes **8 files changed** (+246 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/mob_ai_probe.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+6 -0) 📝 `crates/horizon-client/src/mobs/ai.rs` (+2 -1) 📝 `crates/horizon-client/src/mobs/goals.rs` (+24 -16) 📝 `crates/horizon-client/src/mobs/living.rs` (+6 -1) 📝 `crates/horizon-client/src/mobs/parrot.rs` (+191 -3) 📝 `crates/horizon-client/src/mobs/tame.rs` (+7 -4) 📝 `tools/test_mob_ai_parity.py` (+9 -0) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3091 The port ledger has no port for `Parrot.createNavigation` or `Parrot.calculateFlapping`, as kacpherek pointed out. So a parrot used the ground move control and ground navigation: it walked and hopped, fell at full gravity when pushed off a block, and never flew, tame or not. Its wings never flapped either, because nothing ticked `flap` and `flapSpeed` for parrots. This PR ports the parrot's flight: - **`Parrot()`**: - `FlyingMoveControl(this, 10, false)`. Without `hoversInPlace`, it turns gravity back on when it has no wanted point, so a parrot with nowhere to go comes down. - The `FIRE_IN_NEIGHBOR`, `FIRE` and `COCOA` path maluses at -1. - **`createNavigation`**: a `FlyingPathNavigation` with `setCanOpenDoors(false)` and `setCanFloat(true)`. - **`ParrotWanderGoal.getPosition`**, in place of the plain water-avoiding stroll the parrot had: - In water: `LandRandomPos.getPos(15, 15)`. - Then, unless the 1-in-1000 roll fails: `getTreePos`, the first empty block with an empty block above, over leaves or a `#logs` block, within ±3/±6/±3, walked in `BlockPos.betweenClosed` order. - If both give nothing: `WaterAvoidingRandomFlyingGoal.getPosition`. That code already existed inside `Stroll::flying`; this PR moves it into `Mob::flying_stroll_pos` so both goals share it. - **`calculateFlapping`**, at the end of `aiStep`: - `flapSpeed` goes up by 1.2 in the air and down by 0.3 on the ground or as a passenger. `flapping` restarts at 1 in the air and decays by 0.9, and `flap` turns by `flapping * 2`. - A parrot falling through the air keeps 0.6 of its downward speed (the glide). - A multiplayer client runs the wing part for the parrots it displays, as it already does for chickens. - **`isFlapping` / `onFlap`**, called from `Entity.processFlappingMovement` when a move ends in air: an `entity.parrot.fly` sound (volume 0.15), then `nextFlap = flyDist + flapSpeed / 2`. - **`canFlyToOwner`**: `TamableAnimal.canTeleportTo` lets a parrot teleport onto leaves next to its owner. Not in this PR: the parrot's `FollowMobGoal(1.0, 3, 7)` (priority 3), which has no port yet. It is a separate goal, it doesn't change how a parrot flies, and none of the scenarios below has another mob for it to follow. Also not here: the `GameEvent.FLAP` vibration that `processFlappingMovement` sends after `onFlap`. Horizon's mobs don't send that event for any flying mob yet, and wardens ignore it. ## Vanilla reference - `net.minecraft.world.entity.animal.parrot.Parrot.<init>`, `createNavigation`, `registerGoals`, `aiStep`, `calculateFlapping`, `isFlapping`, `onFlap`, `isFlying`, `canFlyToOwner` - `Parrot$ParrotWanderGoal.getPosition` and `getTreePos` - `WaterAvoidingRandomFlyingGoal.getPosition` (`HoverRandomPos.getPos(8, 7, …, π/2, 3, 1)`, else `AirAndWaterRandomPos.getPos(8, 4, -2, …)`) - `FlyingMoveControl.tick` - `Entity.applyMovementEmissionAndPlaySound` → `processFlappingMovement` - `TamableAnimal.canTeleportTo` Harness: `tools/test_mob_ai_parity.py` (VanillaMobAiOracle against `mob_ai_probe`). ## Tests **Parity harness.** `tools/test_mob_ai_parity.py` gets four parrot scenarios: - `parrot_alone_0` and `parrot_alone_1`: on open grass, 400 ticks. - `parrot_tree`: by an oak log under a leaf canopy, 400 ticks. - `parrot_falling`: let go 10 blocks up, 100 ticks. They run on Peaceful because `Parrot.getAmbient` draws its 1-in-1000 imitation roll from the level's random, which the probe doesn't share. That ambient-sound difference is older than this change and separate from flight. Before, on main's code with only the new scenarios added. Every parrot diverges on its first tick, because vanilla's fall is slowed to 0.6 and Horizon's isn't: ``` parrot_alone_0 mob 0: first divergence at tick 1 of 401 (random draws this tick: vanilla 3, horizon 3) v: vanilla 0,-0.0436800012588501,0 | horizon 0,-0.0728000020980835,0 ... parrot_tree: sounds differ at tick 74: vanilla ['minecraft:entity.parrot.fly 3e19999a 3f800000'] | horizon [] parrot_falling: sounds differ at tick 20: vanilla ['minecraft:entity.parrot.fly 3e19999a 3f800000'] | horizon [] 0/4 scenarios match entirely; 4/1304 mob-ticks match before each mob's first divergence ``` After, with neighbouring flying, tame and farm scenarios also run to check for regressions (the shared flying stroll, the tame goals, the chicken's flapping): ``` chicken_player: all 201 ticks match chicken_alone: all 201 ticks match wither_player: all 201 ticks match llama_wolf: all 201 ticks match feed_chicken: all 81 ticks match feed_chicken_baby: all 81 ticks match bee_alone_0: all 401 ticks match bee_alone_1: all 401 ticks match parrot_alone_0: all 401 ticks match parrot_alone_1: all 401 ticks match parrot_tree: all 401 ticks match parrot_falling: all 101 ticks match wolf_deep_water: all 161 ticks match peaceful_type_wither: all 2 ticks match peaceful_type_wolf: all 2 ticks match 15/15 scenarios match entirely; 3438/3438 mob-ticks match before each mob's first divergence ``` **Unit tests** in `mobs::parrot::tests`, all passing: - the move control, navigation, maluses and wander goal a parrot is registered with; - `calculateFlapping`'s wing values and the 0.6 glide (none while rising, on a shoulder, or on the ground); - the `entity.parrot.fly` wing beat each half `flapSpeed` flown. ## In game I ran a scripted singleplayer creative world with `horizon-ctl`: a 25×25 grass platform with open air above. - **A parrot summoned 10 blocks up**, its height sampled every 5 ticks: - Before (main): `0.48, 0, 0, …`. It drops to the floor within the first sample. - After: `9.80, 9.25, 8.67, 7.79, 7.04, 6.46, 5.88, 5.11, 4.54, 3.77, 3.17, 3.03`. It glides down with its wings spread. - **Five parrots summoned on the grass**, the highest each got over 30 s: - Before: `0, 0, 0, 0, 0`. They only walk. - After: `1.06, 1.98, 2.28, 3.19, 1.17` blocks. The mid-run screenshot shows them in the air in the flying pose. ## Self-check ``` cargo fmt --all -- --check cargo clippy --profile fast -p horizon-client --features mods --all-targets -- -D warnings cargo test --profile fast -p horizon-client --features mods --lib -- mobs::parrot mobs::farm mobs::tame mobs::allay mobs::bee python3 tools/test_mob_ai_parity.py --only parrot wither bee_alone chicken wolf cargo build --profile fast -p horizon-client --features mods --bins ``` (`tools/pr_ready.py` doesn't run on Windows, so these are the steps it would run, by hand.) 🤖 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-03 05:10:27 +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#5132
No description provided.