[PR #4053] [MERGED] Your body keeps up with the camera at Levitation 255 #5383

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

📋 Pull Request Information

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

Base: main ← Head: fix-3616


📝 Commits (1)

  • 14d4530 Your body keeps up with the camera at Levitation 255

📊 Changes

1 file changed (+48 additions, -15 deletions)

View changed files

📝 crates/horizon-client/src/game/perspective.rs (+48 -15)

📄 Description

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

What and why

In third person the player's own body disappears, or jumps ahead of the camera, while you rise with Levitation 254/255 (#3616).

The cause is in tick_player_model (game/perspective.rs). It set m.previous = at whenever the model moved more than 10 blocks in a tick. Levitation 255 moves the player about 11.6 to 12.75 blocks a tick, so above that speed the body stopped interpolating and drew at the end-of-tick position on every frame. The camera kept lerping from previous_position. So in each frame the body sat up to a whole tick (about 12 blocks) above where the camera expected it, which is out of the frame.

The fix: the model now lerps from the player's own old position (self.previous_position, with the 0.125 crouch drop of the previous tick), the same one the camera lerps from. The walk distance and body-turn deltas use that old position too (LivingEntity.calculateEntityAnimation and LivingEntity.tick use x - xo). That position is already reset on every teleport, respawn, portal and dismount, so those still jump without a sweep. This also fixes short teleports under 10 blocks: before, the body swept across them while the camera jumped. The position step is a small pure function, player_model_positions, so it can be tested.

Fixes #3616

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

  • EntityRenderer.extractRenderState(Entity, EntityRenderState, float): state.x/y/z = Mth.lerp(partial, entity.xOld/yOld/zOld, entity.getX/Y/Z()). It has no distance cutoff. The local player's body is that entity, and the camera (Camera.alignWithEntity) lerps from entity.xo/yo/zo, which Entity.setOldPos sets together with xOld/yOld/zOld, so body and camera share one old position.
  • LivingEntity.calculateEntityAnimation: the walk distance is Mth.length(getX() - xo, …).
  • LivingEntity.travel with Levitation: deltaMovement.y += (0.05 * (amplifier + 1) - y) * 0.2, so level 255 heads toward 12.75 blocks a tick.

Checked with javap on the 26.3 client jar. No parity harness covers the player model's interpolation: tools/test_camera_parity.py covers the camera library, which this PR doesn't change. The new unit test game::perspective::preview_tests::the_player_model_rises_with_the_camera_at_levitation_255 checks the positions.

Self-check

tools/pr_ready.py doesn't run on Windows, so I ran these commands by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test --profile fast -p horizon-client --bin horizon-client preview_tests: 6 passed, 1 ignored (the existing test that needs HORIZON_TEST_RESOURCES)
  • Before: I put the old snap back into player_model_positions (old position = new one past 10 blocks a tick). The new test then fails:
    assertion `left == right` failed: the body jumps instead of rising (#3616)
      left: (Vec3 { x: 0.5, y: 92.75, z: 0.5 }, Vec3 { x: 0.5, y: 92.75, z: 0.5 })
     right: (Vec3 { x: 0.5, y: 80.0, z: 0.5 }, Vec3 { x: 0.5, y: 92.75, z: 0.5 })
    test result: FAILED. 5 passed; 1 failed; 1 ignored
    
  • In game, single player with the server thread (the default), creative mode, third person back, looking level, /effect give @s minecraft:levitation 60 254 true, then screenshots while rising at 11.57 blocks a tick (from horizon-ctl state):
    • origin/main: the body is missing from all 6 frames; only the sky shows.
    • this branch: the body is centred in all 6 frames.
    • this branch, after a 40-block /tp in open sky: the body is drawn in place right away, with no sweep.

Screenshots

Third person back while rising with Levitation 255. Before: the player's body is gone, and the frame shows only sky and clouds. After: the body stays centred in front of the camera, as when standing still.

🤖 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/4053 **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-3616` --- ### 📝 Commits (1) - [`14d4530`](https://github.com/horizon-rust/horizon/commit/14d453048e374be06c3219c9e1bc205169f481df) Your body keeps up with the camera at Levitation 255 ### 📊 Changes **1 file changed** (+48 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/perspective.rs` (+48 -15) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando personally. ## What and why In third person the player's own body disappears, or jumps ahead of the camera, while you rise with Levitation 254/255 (#3616). The cause is in `tick_player_model` (`game/perspective.rs`). It set `m.previous = at` whenever the model moved more than 10 blocks in a tick. Levitation 255 moves the player about 11.6 to 12.75 blocks a tick, so above that speed the body stopped interpolating and drew at the end-of-tick position on every frame. The camera kept lerping from `previous_position`. So in each frame the body sat up to a whole tick (about 12 blocks) above where the camera expected it, which is out of the frame. The fix: the model now lerps from the player's own old position (`self.previous_position`, with the 0.125 crouch drop of the previous tick), the same one the camera lerps from. The walk distance and body-turn deltas use that old position too (`LivingEntity.calculateEntityAnimation` and `LivingEntity.tick` use `x - xo`). That position is already reset on every teleport, respawn, portal and dismount, so those still jump without a sweep. This also fixes short teleports under 10 blocks: before, the body swept across them while the camera jumped. The position step is a small pure function, `player_model_positions`, so it can be tested. Fixes #3616 ## 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 - `EntityRenderer.extractRenderState(Entity, EntityRenderState, float)`: `state.x/y/z = Mth.lerp(partial, entity.xOld/yOld/zOld, entity.getX/Y/Z())`. It has no distance cutoff. The local player's body is that entity, and the camera (`Camera.alignWithEntity`) lerps from `entity.xo/yo/zo`, which `Entity.setOldPos` sets together with `xOld/yOld/zOld`, so body and camera share one old position. - `LivingEntity.calculateEntityAnimation`: the walk distance is `Mth.length(getX() - xo, …)`. - `LivingEntity.travel` with Levitation: `deltaMovement.y += (0.05 * (amplifier + 1) - y) * 0.2`, so level 255 heads toward 12.75 blocks a tick. Checked with javap on the 26.3 client jar. No parity harness covers the player model's interpolation: `tools/test_camera_parity.py` covers the camera library, which this PR doesn't change. The new unit test `game::perspective::preview_tests::the_player_model_rises_with_the_camera_at_levitation_255` checks the positions. ## Self-check `tools/pr_ready.py` doesn't run on Windows, so I ran these commands by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test --profile fast -p horizon-client --bin horizon-client preview_tests`: 6 passed, 1 ignored (the existing test that needs `HORIZON_TEST_RESOURCES`) - Before: I put the old snap back into `player_model_positions` (old position = new one past 10 blocks a tick). The new test then fails: ``` assertion `left == right` failed: the body jumps instead of rising (#3616) left: (Vec3 { x: 0.5, y: 92.75, z: 0.5 }, Vec3 { x: 0.5, y: 92.75, z: 0.5 }) right: (Vec3 { x: 0.5, y: 80.0, z: 0.5 }, Vec3 { x: 0.5, y: 92.75, z: 0.5 }) test result: FAILED. 5 passed; 1 failed; 1 ignored ``` - In game, single player with the server thread (the default), creative mode, third person back, looking level, `/effect give @s minecraft:levitation 60 254 true`, then screenshots while rising at 11.57 blocks a tick (from `horizon-ctl state`): - origin/main: the body is missing from all 6 frames; only the sky shows. - this branch: the body is centred in all 6 frames. - this branch, after a 40-block `/tp` in open sky: the body is drawn in place right away, with no sweep. ## Screenshots Third person back while rising with Levitation 255. Before: the player's body is gone, and the frame shows only sky and clouds. After: the body stays centred in front of the camera, as when standing still. 🤖 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:12:13 +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#5383
No description provided.