From 5530d682abb07b3af3bdcb78ef3b65ed63fe9e6d Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Thu, 15 Oct 2026 08:11:32 +0200 Subject: [PATCH] Arrows interpolate from their last tick, not from where they were shot arrows::tick never set the projectile's previous position (Entity.setOldPosAndRot at the start of every tick); Projectile::tick does, but arrows don't go through it. The renderer lerped from the spawn point to the current position every frame, so a flying or stuck arrow jumped along its whole path. The arrow harness now prints the old position too. Fixes #278 Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/examples/arrow_probe.rs | 5 +++-- crates/horizon-client/src/arrows.rs | 3 +++ .../dev/horizonlab/parity/VanillaArrowOracle.java | 6 ++++-- tools/test_arrow_parity.py | 11 ++++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/crates/horizon-client/examples/arrow_probe.rs b/crates/horizon-client/examples/arrow_probe.rs index c8aed6a46..545d7ae4d 100644 --- a/crates/horizon-client/examples/arrow_probe.rs +++ b/crates/horizon-client/examples/arrow_probe.rs @@ -262,7 +262,7 @@ fn main() -> Result<()> { let a = arrow.arrow.as_ref().unwrap(); writeln!( out, - "arrow {} {} {:08x} {:08x} {} {} {} {} {} {} {} {} {} {:016x} {:016x} {} {} {:016x}", + "arrow {} {} {:08x} {:08x} {} {} {} {} {} {} {} {} {} {:016x} {:016x} {} {} {:016x} {}", bits(arrow.position), bits(arrow.velocity), arrow.pitch.to_bits(), @@ -280,7 +280,8 @@ fn main() -> Result<()> { a.fluids.fluid_height(&Tags, LAVA).to_bits(), a.removed, arrow.critical(), - a.fall_distance.to_bits() + a.fall_distance.to_bits(), + bits(arrow.previous) )?; writeln!(out, "events {}", events.join(" | "))?; let a = arrow.arrow.as_ref().unwrap(); diff --git a/crates/horizon-client/src/arrows.rs b/crates/horizon-client/src/arrows.rs index 1520ee7ca..d89d82161 100644 --- a/crates/horizon-client/src/arrows.rs +++ b/crates/horizon-client/src/arrows.rs @@ -387,6 +387,9 @@ pub fn tick(p: &mut Projectile, scene: &ArrowScene, targets: &[(Who, Aabb)]) -> let Some(mut st) = p.arrow.take() else { return (false, Hit::None); }; + // Entity.setOldPosAndRot: the renderer interpolates from here, in flight + // and stuck alike. + p.previous = p.position; let hit = Ticker { p, st: &mut st, diff --git a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java index d6716f7ad..b5e8fb284 100644 --- a/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java +++ b/mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java @@ -151,6 +151,8 @@ public final class VanillaArrowOracle { var a=new Arrow(level,0,0,0,ammo,null); random.set(a,net.minecraft.util.RandomSource.create(seed(row.get("seed")))); a.setPos(VanillaSceneCollisionOracle.vector(row.get("position")));a.setDeltaMovement(VanillaSceneCollisionOracle.vector(row.get("velocity"))); + // The client's recreateFromPacket snaps a spawned arrow, old position included. + a.setOldPosAndRot(); a.setCritArrow(row.get("crit").getAsBoolean());a.setNoPhysics(row.get("no_physics").getAsBoolean()); String touched="-"; for(var value:row.getAsJsonArray("ops")){ @@ -187,9 +189,9 @@ public final class VanillaArrowOracle { default->throw new AssertionError(op); } var state=(BlockState)lastState.get(a); - out.printf("arrow %s %s %08x %08x %s %d %d %d %s %d %s %s %s %016x %016x %s %s %016x%n",bits(a.position()),bits(a.getDeltaMovement()),Float.floatToIntBits(a.getXRot()),Float.floatToIntBits(a.getYRot()), + out.printf("arrow %s %s %08x %08x %s %d %d %d %s %d %s %s %s %016x %016x %s %s %016x %s%n",bits(a.position()),bits(a.getDeltaMovement()),Float.floatToIntBits(a.getXRot()),Float.floatToIntBits(a.getYRot()), inGround.invoke(a),inGroundTime.getInt(a),life.getInt(a),a.shakeTime,state==null?"none":Block.getId(state),a.getRemainingFireTicks(),touching.getBoolean(a),eyes.getBoolean(a),first.getBoolean(a), - Double.doubleToLongBits(a.getFluidHeight(net.minecraft.tags.FluidTags.WATER)),Double.doubleToLongBits(a.getFluidHeight(net.minecraft.tags.FluidTags.LAVA)),a.isRemoved(),a.isCritArrow(),Double.doubleToLongBits(a.fallDistance)); + Double.doubleToLongBits(a.getFluidHeight(net.minecraft.tags.FluidTags.WATER)),Double.doubleToLongBits(a.getFluidHeight(net.minecraft.tags.FluidTags.LAVA)),a.isRemoved(),a.isCritArrow(),Double.doubleToLongBits(a.fallDistance),bits(new Vec3(a.xo,a.yo,a.zo))); out.println("events "+String.join(" | ",level.events));level.events.clear(); out.printf("pickup %d %s %s%n",a.pickup.ordinal(),a.getPickupItemStackOrigin().has(net.minecraft.core.component.DataComponents.INTANGIBLE_PROJECTILE),touched);touched="-"; } diff --git a/tools/test_arrow_parity.py b/tools/test_arrow_parity.py index 32eaaa1be..0b6b5b2d2 100644 --- a/tools/test_arrow_parity.py +++ b/tools/test_arrow_parity.py @@ -5,11 +5,12 @@ Real vanilla `Arrow` entities tick in an independently built copy of the scene (`VanillaArrowOracle`, client and server jars); Horizon's `arrows::tick` runs over the scene itself (`examples/arrow_probe.rs`). Every operation prints the arrow's position, motion, rotation, ground state, life, -shake, stuck block, fire ticks, water flags, fluid heights, removal, crit flag -and fall distance by exact bits, then its sounds, particles and game events in -order, then its pickup rule, whether its item is intangible and what a player -touching it took. Cases: flights in the air with and without crits or physics, into and -through water (inertia, bubbles, splashes, currents of flowing water, eyes), +shake, stuck block, fire ticks, water flags, fluid heights, removal, crit flag, +fall distance and old position (what rendering interpolates from) by exact +bits, then its sounds, particles and game events in order, then its pickup +rule, whether its item is intangible and what a player touching it took. +Cases: flights in the air with and without crits or physics, into and through +water (inertia, bubbles, splashes, currents of flowing water, eyes), kelp, seagrass and waterlogged blocks, bubble columns with and without drag and with air or water above, sticking in full and partial blocks, falling out when the block goes, starting inside a block, and despawning after 1200 ticks;