[PR #6352] [MERGED] Draw an arrow between the rotations of the two ticks it turns over #6820

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6352
Author: @MSedgeMC
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/gp-arrow-rot


📝 Commits (2)

  • 244c866 Draw an arrow between the rotations of the two ticks it turns over
  • c77c94c Merge main into the arrow rotation interpolation

📊 Changes

5 files changed (+72 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/arrows.rs (+1 -1)
📝 crates/horizon-client/src/game/creatures.rs (+8 -2)
📝 crates/horizon-client/src/game/remote_projectiles.rs (+37 -2)
📝 crates/horizon-client/src/projectiles.rs (+21 -1)
📝 tools/test_arrow_parity.py (+5 -0)

📄 Description

Vanilla draws every entity's rotation interpolated between the tick that just ended and the current one: Entity.commmonTick's setOldPosAndRot (called by ServerLevel and ClientLevel before each entity tick) copies yRot/xRot into yRotO/xRotO, and ArrowRenderer uses

poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, state.yRotO, state.yRot) - 90.0F));
poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, state.xRotO, state.xRot)));

A freshly shot projectile does not interpolate from where it was created either: Projectile.shoot ends with this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); (offsets 78 and 86).

Horizon's Projectile kept a previous position only and crates/horizon-client/src/game/creatures.rs built the arrow's model matrix from the raw pitch/yaw, so the drawn model stepped a whole tick at a time while its position was interpolated. AbstractArrow.tick moves its aim a fifth of the way to the flight direction each tick (lerpRotation, offsets 468-484), which for an arrow shot straight up is about 36 degrees a tick, so the arrow was drawn up to a tick ahead of its interpolated position and snapped between frames.

Projectile now carries previous_yaw/previous_pitch, filled by set_old_pos_and_rot in place of the four previous = position assignments (arrows::tick, the remote arrow tick, the shulker bullet tick and tick_inner), shoot's rotation copy is repeated in update_rotation, and the arrow is drawn with previous + alpha * (current - previous) for both angles. Shulker bullets and thrown items keep a previous rotation too, which is what vanilla's setOldPosAndRot does for every entity.

Proven: cargo test -q -p horizon-client --lib a_remote_arrow_keeps -> 1 passed on the build VM: an arrow shot straight up at the lowest bow power (0.3) is checked tick by tick, that the rotation the renderer interpolates from is always the one the previous tick ended with and that the arrow has turned over by the end. python3 tools/test_arrow_parity.py -> client: 171,939 arrow states match, server: 171,939 arrow states match, so the simulated rotation is untouched by this change.

Not proven: the game itself: a side-by-side of an arrow shot straight up at the lowest power, which should turn over smoothly and in the same frames as vanilla. The model matrix is not covered by a test: the crate has no render test for projectiles.

Note on #6157: the ticked rotation of exactly that shot already matches vanilla bit for bit on current main, and the corpus of tools/test_arrow_parity.py now covers it (a straight-up 0.3 case was added), so the timing of the turn over is not where the remaining difference is. What did not match is the drawn rotation this change fixes. If the reported difference is still visible after this, it is not in the arrow's simulated or drawn rotation.

Known limit: only the arrow model path interpolates here; the other projectiles are drawn as item billboards and never used their own rotation.


🔄 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/6352 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/gp-arrow-rot` --- ### 📝 Commits (2) - [`244c866`](https://github.com/horizon-rust/horizon/commit/244c866b500c1c5b739a15ce062dac7ca81c1e98) Draw an arrow between the rotations of the two ticks it turns over - [`c77c94c`](https://github.com/horizon-rust/horizon/commit/c77c94cb221b97ca497fd5857923785c6ea0e09b) Merge main into the arrow rotation interpolation ### 📊 Changes **5 files changed** (+72 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/arrows.rs` (+1 -1) 📝 `crates/horizon-client/src/game/creatures.rs` (+8 -2) 📝 `crates/horizon-client/src/game/remote_projectiles.rs` (+37 -2) 📝 `crates/horizon-client/src/projectiles.rs` (+21 -1) 📝 `tools/test_arrow_parity.py` (+5 -0) </details> ### 📄 Description Vanilla draws every entity's rotation interpolated between the tick that just ended and the current one: `Entity.commmonTick`'s `setOldPosAndRot` (called by `ServerLevel` and `ClientLevel` before each entity tick) copies `yRot`/`xRot` into `yRotO`/`xRotO`, and `ArrowRenderer` uses ``` poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, state.yRotO, state.yRot) - 90.0F)); poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, state.xRotO, state.xRot))); ``` A freshly shot projectile does not interpolate from where it was created either: `Projectile.shoot` ends with `this.yRotO = this.getYRot(); this.xRotO = this.getXRot();` (offsets 78 and 86). Horizon's `Projectile` kept a previous *position* only and `crates/horizon-client/src/game/creatures.rs` built the arrow's model matrix from the raw `pitch`/`yaw`, so the drawn model stepped a whole tick at a time while its position was interpolated. `AbstractArrow.tick` moves its aim a fifth of the way to the flight direction each tick (`lerpRotation`, offsets 468-484), which for an arrow shot straight up is about 36 degrees a tick, so the arrow was drawn up to a tick ahead of its interpolated position and snapped between frames. `Projectile` now carries `previous_yaw`/`previous_pitch`, filled by `set_old_pos_and_rot` in place of the four `previous = position` assignments (`arrows::tick`, the remote arrow tick, the shulker bullet tick and `tick_inner`), `shoot`'s rotation copy is repeated in `update_rotation`, and the arrow is drawn with `previous + alpha * (current - previous)` for both angles. Shulker bullets and thrown items keep a previous rotation too, which is what vanilla's `setOldPosAndRot` does for every entity. **Proven:** `cargo test -q -p horizon-client --lib a_remote_arrow_keeps` -> 1 passed on the build VM: an arrow shot straight up at the lowest bow power (0.3) is checked tick by tick, that the rotation the renderer interpolates from is always the one the previous tick ended with and that the arrow has turned over by the end. `python3 tools/test_arrow_parity.py` -> `client: 171,939 arrow states match`, `server: 171,939 arrow states match`, so the simulated rotation is untouched by this change. **Not proven:** the game itself: a side-by-side of an arrow shot straight up at the lowest power, which should turn over smoothly and in the same frames as vanilla. The model matrix is not covered by a test: the crate has no render test for projectiles. Note on #6157: the ticked rotation of exactly that shot already matches vanilla bit for bit on current main, and the corpus of `tools/test_arrow_parity.py` now covers it (a straight-up 0.3 case was added), so the timing of the turn over is not where the remaining difference is. What did not match is the drawn rotation this change fixes. If the reported difference is still visible after this, it is not in the arrow's simulated or drawn rotation. Known limit: only the arrow model path interpolates here; the other projectiles are drawn as item billboards and never used their own rotation. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:27:31 +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#6820
No description provided.