[PR #294] [MERGED] Arrows stop jumping along their path after they land (#278) #2463

Closed
opened 2026-11-02 15:56:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/294
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: fix/arrow-interpolation


📝 Commits (1)

  • 5530d68 Arrows interpolate from their last tick, not from where they were shot

📊 Changes

4 files changed (+16 additions, -9 deletions)

View changed files

📝 crates/horizon-client/examples/arrow_probe.rs (+3 -2)
📝 crates/horizon-client/src/arrows.rs (+3 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java (+4 -2)
📝 tools/test_arrow_parity.py (+6 -5)

📄 Description

Fixes #278

What

Shot arrows no longer jump back and forth along the path they flew. A stuck arrow stays still in the block it hit, and a flying one moves smoothly.

Why

The renderer draws a projectile at lerp(previous, position, partialTick). Vanilla sets the old position at the start of every entity tick (Entity.setOldPosAndRot, called from commonTick). Projectile::tick did this, but arrows tick through arrows::tick, which never updated previous. It stayed at the point the arrow was shot from, so every frame drew the arrow somewhere between the bow and where it actually was. Once stuck, it flickered along its whole flight path for the 1200 ticks until it despawned, which made it look as though it never went away. The despawn itself (tickDespawn, 1200 ticks in the ground) and pickup were already vanilla's.

How

  • arrows::tick sets p.previous = p.position before ticking, like setOldPosAndRot.
  • The arrow harness now compares the old position too. The probe prints previous and the oracle prints xo/yo/zo. The oracle calls setOldPosAndRot() once after placing the arrow, as the client's recreateFromPacket → snapTo does when an arrow spawns. The server constructor's setPos leaves xo at 0.

How tested

  • tools/parity.py arrow on the Mac mini: PASS (flights, water, sticking, falling out, despawn after 1200 ticks, fire, pickup; now with the old position). Without the one-line fix it fails at output line 7, the first tick.
  • In game on the Mac mini (offscreen captures; the session was locked), with an arrow shot from a bow into a stone wall and the player teleported beside its path, six screenshots 0.2 s apart:
    • main: the "stuck" arrow is drawn in mid-air, at a different point along its path in each frame (about 100 px apart between frames 1 and 4).
    • this branch: the arrow is in the wall at the same pixel in every frame.
  • Self-check:
cargo fmt --all -- --check                                   OK
cargo clippy --workspace --all-targets -- -D warnings        OK
cargo test -p horizon-client --lib                           627 passed
parity: arrow                                                PASS (fails at line 7 without the fix)

Not covered: the arrow's rotation is still drawn without interpolation (vanilla lerps yRotO/xRotO). That's minor, since rotation barely changes once the arrow is stuck, and it's left for a separate PR. Nothing needs Ludovic.

🤖 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/294 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/arrow-interpolation` --- ### 📝 Commits (1) - [`5530d68`](https://github.com/horizon-rust/horizon/commit/5530d682abb07b3af3bdcb78ef3b65ed63fe9e6d) Arrows interpolate from their last tick, not from where they were shot ### 📊 Changes **4 files changed** (+16 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/arrow_probe.rs` (+3 -2) 📝 `crates/horizon-client/src/arrows.rs` (+3 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java` (+4 -2) 📝 `tools/test_arrow_parity.py` (+6 -5) </details> ### 📄 Description Fixes #278 ## What Shot arrows no longer jump back and forth along the path they flew. A stuck arrow stays still in the block it hit, and a flying one moves smoothly. ## Why The renderer draws a projectile at `lerp(previous, position, partialTick)`. Vanilla sets the old position at the start of every entity tick (`Entity.setOldPosAndRot`, called from `commonTick`). `Projectile::tick` did this, but arrows tick through `arrows::tick`, which never updated `previous`. It stayed at the point the arrow was shot from, so every frame drew the arrow somewhere between the bow and where it actually was. Once stuck, it flickered along its whole flight path for the 1200 ticks until it despawned, which made it look as though it never went away. The despawn itself (`tickDespawn`, 1200 ticks in the ground) and pickup were already vanilla's. ## How - `arrows::tick` sets `p.previous = p.position` before ticking, like `setOldPosAndRot`. - The arrow harness now compares the old position too. The probe prints `previous` and the oracle prints `xo/yo/zo`. The oracle calls `setOldPosAndRot()` once after placing the arrow, as the client's `recreateFromPacket` → `snapTo` does when an arrow spawns. The server constructor's `setPos` leaves `xo` at 0. ## How tested - `tools/parity.py arrow` on the Mac mini: **PASS** (flights, water, sticking, falling out, despawn after 1200 ticks, fire, pickup; now with the old position). Without the one-line fix it fails at output line 7, the first tick. - In game on the Mac mini (offscreen captures; the session was locked), with an arrow shot from a bow into a stone wall and the player teleported beside its path, six screenshots 0.2 s apart: - main: the "stuck" arrow is drawn in mid-air, at a different point along its path in each frame (about 100 px apart between frames 1 and 4). - this branch: the arrow is in the wall at the same pixel in every frame. - Self-check: ``` cargo fmt --all -- --check OK cargo clippy --workspace --all-targets -- -D warnings OK cargo test -p horizon-client --lib 627 passed parity: arrow PASS (fails at line 7 without the fix) ``` Not covered: the arrow's rotation is still drawn without interpolation (vanilla lerps `yRotO`/`xRotO`). That's minor, since rotation barely changes once the arrow is stuck, and it's left for a separate PR. Nothing needs Ludovic. 🤖 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-02 15:56:22 +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#2463
No description provided.