[PR #3449] [MERGED] Keep the player model's legs still while flying straight up #4989

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

📋 Pull Request Information

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

Base: main ← Head: fix-3302


📝 Commits (1)

  • bf7179c Keep the player model's legs still while flying straight up

📊 Changes

1 file changed (+23 additions, -3 deletions)

View changed files

📝 crates/horizon-client/src/game/perspective.rs (+23 -3)

📄 Description

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

What and why

Fixes #3302

In third person, flying straight up in Creative (or gliding up and down with an elytra) swung the player's legs and arms as if walking. Hovering didn't.

Game::tick_player_model (game/perspective.rs) fed the vertical distance into the walk animation whenever the player was flying or gliding:

let dist = (dx * dx + dz * dz + if flying { dy * dy } else { 0.0 }).sqrt() as f32;

Vanilla only counts vertical movement for omnidirectional air movers (bees and parrots), never for a player. The walk distance is now the horizontal distance only, in a small player_walk_distance helper. Everything else about the model's step (the teleport snap, the body turn, WalkAnimationState's 0.4 lerp) is unchanged. Other players' models (game/remote.rs, game/lan.rs) already used the horizontal distance.

Vanilla reference

  • LivingEntity.aiStep ends with calculateEntityAnimation(omnidirectionalAirMover()).
  • LivingEntity.calculateEntityAnimation(boolean): Mth.length(getX() - xo, flag ? getY() - yo : 0, getZ() - zo), then updateWalkAnimation.
  • Entity.omnidirectionalAirMover() returns false. Player, Avatar, AbstractClientPlayer, LocalPlayer and RemotePlayer don't override it, so a player's walk animation never counts vertical movement, flying or not.

Read with javap -c on the 26.3 client jar. No harness covers the local player's model animation. The new unit test game::perspective::preview_tests::flying_straight_up_does_not_walk_the_player_model checks that moving straight up or down walks the model 0, and that a move with a horizontal part walks only that part.

Test before (the helper with main's flying formula, which adds dy * dy):

running 1 test
test game::perspective::preview_tests::flying_straight_up_does_not_walk_the_player_model ... FAILED
assertion `left == right` failed
  left: 0.375
 right: 0.0
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 141 filtered out

After:

running 4 tests
test game::perspective::preview_tests::player_render_transform_uses_vanilla_avatar_scale ... ignored
test game::perspective::preview_tests::burning_inventory_preview_keeps_visible_fullbright_flames ... ok
test game::perspective::preview_tests::flying_straight_up_does_not_walk_the_player_model ... ok
test game::perspective::preview_tests::preview_keeps_crossing_faces_depth_and_clips_without_dropping_faces ... ok
test result: ok. 3 passed; 0 failed; 1 ignored; 0 measured; 138 filtered out

Self-check

Run on Windows 11 (tools/pr_ready.py stops on Windows at signal.SIGHUP, so the steps were run by hand):

cargo fmt --all -- --check                                                      ok
cargo clippy -p horizon-client --features mods --all-targets -- -D warnings     ok
cargo test -p horizon-client --bin horizon-client                               139 passed, 3 ignored
python tools/check_public_tree.py                                               passed

Screenshots

Creative world, third person (back view), flying, holding jump without touching WASD for about 1 second (from y 82.4 to 91.2), scripted with horizon-ctl.

Before (main, 142388e1c): the legs and arms swing while rising.

before: legs swing while rising

After: the model stays still while rising, as when hovering. Flying forward still swings it.

after: legs still while rising
after: legs still swing flying forward

🤖 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/3449 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3302` --- ### 📝 Commits (1) - [`bf7179c`](https://github.com/horizon-rust/horizon/commit/bf7179c48b600fc79f2929cd2383cdc88ca8ae70) Keep the player model's legs still while flying straight up ### 📊 Changes **1 file changed** (+23 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/perspective.rs` (+23 -3) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #3302 In third person, flying straight up in Creative (or gliding up and down with an elytra) swung the player's legs and arms as if walking. Hovering didn't. `Game::tick_player_model` (`game/perspective.rs`) fed the vertical distance into the walk animation whenever the player was flying or gliding: ```rust let dist = (dx * dx + dz * dz + if flying { dy * dy } else { 0.0 }).sqrt() as f32; ``` Vanilla only counts vertical movement for omnidirectional air movers (bees and parrots), never for a player. The walk distance is now the horizontal distance only, in a small `player_walk_distance` helper. Everything else about the model's step (the teleport snap, the body turn, `WalkAnimationState`'s 0.4 lerp) is unchanged. Other players' models (`game/remote.rs`, `game/lan.rs`) already used the horizontal distance. ## Vanilla reference - `LivingEntity.aiStep` ends with `calculateEntityAnimation(omnidirectionalAirMover())`. - `LivingEntity.calculateEntityAnimation(boolean)`: `Mth.length(getX() - xo, flag ? getY() - yo : 0, getZ() - zo)`, then `updateWalkAnimation`. - `Entity.omnidirectionalAirMover()` returns `false`. `Player`, `Avatar`, `AbstractClientPlayer`, `LocalPlayer` and `RemotePlayer` don't override it, so a player's walk animation never counts vertical movement, flying or not. Read with `javap -c` on the 26.3 client jar. No harness covers the local player's model animation. The new unit test `game::perspective::preview_tests::flying_straight_up_does_not_walk_the_player_model` checks that moving straight up or down walks the model 0, and that a move with a horizontal part walks only that part. Test before (the helper with main's flying formula, which adds `dy * dy`): ``` running 1 test test game::perspective::preview_tests::flying_straight_up_does_not_walk_the_player_model ... FAILED assertion `left == right` failed left: 0.375 right: 0.0 test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 141 filtered out ``` After: ``` running 4 tests test game::perspective::preview_tests::player_render_transform_uses_vanilla_avatar_scale ... ignored test game::perspective::preview_tests::burning_inventory_preview_keeps_visible_fullbright_flames ... ok test game::perspective::preview_tests::flying_straight_up_does_not_walk_the_player_model ... ok test game::perspective::preview_tests::preview_keeps_crossing_faces_depth_and_clips_without_dropping_faces ... ok test result: ok. 3 passed; 0 failed; 1 ignored; 0 measured; 138 filtered out ``` ## Self-check Run on Windows 11 (`tools/pr_ready.py` stops on Windows at `signal.SIGHUP`, so the steps were run by hand): ``` cargo fmt --all -- --check ok cargo clippy -p horizon-client --features mods --all-targets -- -D warnings ok cargo test -p horizon-client --bin horizon-client 139 passed, 3 ignored python tools/check_public_tree.py passed ``` ## Screenshots Creative world, third person (back view), flying, holding jump without touching WASD for about 1 second (from y 82.4 to 91.2), scripted with `horizon-ctl`. Before (main, 142388e1c): the legs and arms swing while rising. ![before: legs swing while rising](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/fly-3302-before.png) After: the model stays still while rising, as when hovering. Flying forward still swings it. ![after: legs still while rising](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/fly-3302-after.png) ![after: legs still swing flying forward](https://raw.githubusercontent.com/d3grando/horizon/pr-assets/fly-3302-after-forward.png) 🤖 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:09:24 +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#4989
No description provided.