[PR #5022] [MERGED] Elytra: glide with Mth's sine table and float drag, as vanilla does #6013

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5022
Author: @apeirs
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/elytra-vanilla-trig


📝 Commits (1)

  • 5943233 Elytra: glide with Mth's sine table and float drag, as vanilla does

📊 Changes

1 file changed (+73 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/motion.rs (+73 -11)

📄 Description

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

What and why

Fixes #4618. A long elytra glide lands up to about 0.11 blocks from where vanilla lands (the issue says "up to .125"). MotionWorld::travel_fall_flying computed the glide with exact f32 trig and double drag constants, while vanilla uses Mth's sine table and float constants. Each tick is off by very little, but the glide feeds its own velocity back in, so the error builds up over a flight.

crates/horizon-client/src/motion.rs, travel_fall_flying:

vanilla 26.3 before
look direction getLookAngle → calculateViewVector: Mth.sin/Mth.cos, 0.017453292f f32::sin/cos, f32::to_radians
pull-up -sin(lean) Mth.sin f32::sin
lift cos²(lean) Math.cos of the widened lean f32::cos, then widened
drag multiply(0.99F, 0.98F, 0.99F) (0.9900000095…, 0.9800000190…) 0.99, 0.98

The fix uses the helpers that already exist for this: horizon_world::view_direction::view_vector, trig::DEG_TO_RAD, trig::sin and jmath::cos. Nothing else in the tree has its own copy of the glide math, and the anticheat's movement replays run the same PlayerMotion, so they follow.

How much each difference matters: over 2,000 simulated glides from y=100 to the ground, the worst landing gap was 0.114 blocks. Fixing only the look direction leaves at most 0.079 of it, fixing only the pull-up sin leaves at most 0.082, and the drag constants account for 0.0005.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Read from the 26.3 client bytecode (javap):

  • LivingEntity.updateFallFlyingMovement(Vec3): getXRot() * 0.017453292f, Mth.square(Math.cos((double) lean)), Mth.sin((double) lean) in the pull-up, multiply(0.99F, 0.98F, 0.99F).
  • Entity.calculateViewVector(float, float) (through getLookAngle): Mth.cos/Mth.sin of xRot * 0.017453292f and -yRot * 0.017453292f.

Test: motion::tests::a_glide_tick_matches_vanilla_to_the_bit, one glide tick for a climb and for a dive, from (0.4, -0.3, 1.1). It compares the bits with the result of that bytecode, transcribed to Java and run on the 26.3 JVM against the game jar's own Mth. It passes on this branch and fails on main (-25.3 37.7: x 0.2817008543593485, vanilla 0.2816964943056143). It needs .local/horizon-client like the other glide tests in that module, and skips without it.

No parity harness yet: the scene-motion oracle can't glide (its isFallFlying is only a statistics flag). If you want one, I can extend VanillaSceneMotionOracle with a worn elytra and a glide, which I couldn't run here without the vanilla data.

Self-check

pr_ready (tools/pr_ready.py --quick on arch, against origin/main at 9d979caa4, 5 min 25 s)

Check Result
Scope ✅ 1 files, +73 −11
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 0 s)
rustfmt ✅ (13 s)
clippy ✅ (2 min 8 s)
tests: horizon-client ✅ 1334 passed (2 min 3 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

With .local/horizon-client present: cargo test -p horizon-client --lib -- motion:: passes, 36 tests.


🔄 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/5022 **Author:** [@apeirs](https://github.com/apeirs) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/elytra-vanilla-trig` --- ### 📝 Commits (1) - [`5943233`](https://github.com/horizon-rust/horizon/commit/5943233ee5f0e2b0b82be1bb345cf80b789146eb) Elytra: glide with Mth's sine table and float drag, as vanilla does ### 📊 Changes **1 file changed** (+73 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/motion.rs` (+73 -11) </details> ### 📄 Description > 🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally. ## What and why Fixes #4618. A long elytra glide lands up to about 0.11 blocks from where vanilla lands (the issue says "up to .125"). `MotionWorld::travel_fall_flying` computed the glide with exact `f32` trig and double drag constants, while vanilla uses `Mth`'s sine table and float constants. Each tick is off by very little, but the glide feeds its own velocity back in, so the error builds up over a flight. `crates/horizon-client/src/motion.rs`, `travel_fall_flying`: | | vanilla 26.3 | before | | --- | --- | --- | | look direction | `getLookAngle` → `calculateViewVector`: `Mth.sin`/`Mth.cos`, `0.017453292f` | `f32::sin`/`cos`, `f32::to_radians` | | pull-up `-sin(lean)` | `Mth.sin` | `f32::sin` | | lift `cos²(lean)` | `Math.cos` of the widened lean | `f32::cos`, then widened | | drag | `multiply(0.99F, 0.98F, 0.99F)` (0.9900000095…, 0.9800000190…) | `0.99`, `0.98` | The fix uses the helpers that already exist for this: `horizon_world::view_direction::view_vector`, `trig::DEG_TO_RAD`, `trig::sin` and `jmath::cos`. Nothing else in the tree has its own copy of the glide math, and the anticheat's movement replays run the same `PlayerMotion`, so they follow. How much each difference matters: over 2,000 simulated glides from y=100 to the ground, the worst landing gap was 0.114 blocks. Fixing only the look direction leaves at most 0.079 of it, fixing only the pull-up `sin` leaves at most 0.082, and the drag constants account for 0.0005. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Read from the 26.3 client bytecode (javap): - `LivingEntity.updateFallFlyingMovement(Vec3)`: `getXRot() * 0.017453292f`, `Mth.square(Math.cos((double) lean))`, `Mth.sin((double) lean)` in the pull-up, `multiply(0.99F, 0.98F, 0.99F)`. - `Entity.calculateViewVector(float, float)` (through `getLookAngle`): `Mth.cos`/`Mth.sin` of `xRot * 0.017453292f` and `-yRot * 0.017453292f`. Test: `motion::tests::a_glide_tick_matches_vanilla_to_the_bit`, one glide tick for a climb and for a dive, from (0.4, -0.3, 1.1). It compares the bits with the result of that bytecode, transcribed to Java and run on the 26.3 JVM against the game jar's own `Mth`. It passes on this branch and fails on main (`-25.3 37.7: x 0.2817008543593485`, vanilla `0.2816964943056143`). It needs `.local/horizon-client` like the other glide tests in that module, and skips without it. No parity harness yet: the scene-motion oracle can't glide (its `isFallFlying` is only a statistics flag). If you want one, I can extend `VanillaSceneMotionOracle` with a worn elytra and a glide, which I couldn't run here without the vanilla data. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on arch, against origin/main at 9d979caa4, 5 min 25 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +73 −11 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 0 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (2 min 8 s) | | tests: horizon-client | ✅ 1334 passed (2 min 3 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | With `.local/horizon-client` present: `cargo test -p horizon-client --lib -- motion::` passes, 36 tests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:37 +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#6013
No description provided.