[PR #187] [MERGED] Arrows get vanilla's water physics (#127) #2388

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

📋 Pull Request Information

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

Base: main ← Head: fix/arrow-water-127


📝 Commits (4)

  • 60d9bff Water cancels the player's fall damage (#180)
  • f442374 Format the player fluid binding
  • 645109d Keep the scene motion scope text a valid string
  • 1d93642 Arrows get vanilla's water physics (#127)

📊 Changes

15 files changed (+2119 additions, -90 deletions)

View changed files

➕ crates/horizon-client/examples/arrow_probe.rs (+224 -0)
📝 crates/horizon-client/examples/scene_motion_probe.rs (+37 -3)
➕ crates/horizon-client/src/arrows.rs (+875 -0)
📝 crates/horizon-client/src/game.rs (+31 -0)
📝 crates/horizon-client/src/game/creatures.rs (+97 -8)
📝 crates/horizon-client/src/landing.rs (+3 -3)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/motion.rs (+36 -6)
➕ crates/horizon-client/src/motion/fluids.rs (+336 -0)
📝 crates/horizon-client/src/projectiles.rs (+30 -57)
📝 crates/horizon-world/src/entity_fluid.rs (+1 -1)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java (+130 -0)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java (+29 -11)
➕ tools/test_arrow_parity.py (+171 -0)
📝 tools/test_native_scene_motion.py (+118 -1)

📄 Description

Fixes #127

Stacked on #186 (reuses its FluidResources/fluid tag binding); base is fix/water-fall-damage-180. Retarget to main before merging #186 with branch deletion.

Root cause

Arrows ran a simplified projectile tick: a point lookup for "in water" chose 0.6 instead of 0.99 drag after the move, and that was all. No bubbles, no splash, no currents, no bubble columns; sticking nudged back by the normalized motion; stuck arrows never fell out when their block went and despawned on a 1200-tick age.

Fix

crates/horizon-client/src/arrows.rs ports AbstractArrow.tick for arrows (state in Projectile::arrow, ticked by arrows::tick; other projectiles keep Projectile::tick):

  • the in-block check (a stuck arrow inside a collision box stops), shake, clearFire in water;
  • in-ground: fall out (startFalling, the arrow's own random) when the block it hit changed and nothing collides around it, else life toward the 1200-tick despawn; block effects at rest;
  • in flight: water inertia 0.6 from the last base tick's wasTouchingWater with four bubbles behind the arrow, crit trails, lerpRotation (folded RAD_TO_DEG), checkLeftOwner, the COLLIDER/Fluid.NONE clip with the nearest entity first, the blocks along the path (applyEffectsFromBlocks: bubble columns push up/down or drag with their particles, water extinguishes, StepBasedCollector order), 0.99 drag only out of water, gravity through Vec3.add (signed zeros), then the base tick: updateFluidInteraction (currents while not stuck, entity.generic.splash with bubble/splash particles), fire ticks, lava halving, below-world removal;
  • onHitBlock: back 0.05 along each moving axis (Math.signum), stop, hit sound pitch from the arrow's random, shake 7, crit off.
    The game plays the events (arrow_event: particles, sounds, the level-random bubble column particles, the SPLASH game event); entity hits are still the game's (projectile_hit), the arrow is spent on a hit.

Parity proof

New harness tools/test_arrow_parity.py: real vanilla Arrow entities (VanillaArrowOracle, over an independent copy of the resident scene) vs arrows::tick (examples/arrow_probe.rs), one state line (position, motion, rotation, ground, life, shake, stuck block, fire, water flags, fluid heights, removal, crit, fall) and one ordered event line per operation. 197 fixtures: flights with/without crits and physics, shots into/through/from inside 3-deep source, flowing and falling water, random currents, kelp/seagrass/waterlogged blocks, bubble columns (drag up/down, open/water/stone above), sticking in 12 full and partial shapes then the block removed or replaced, starting inside blocks, and the 1200-tick despawn.

  • Mac mini: 83,573 / 83,573 lines on both the client and server jars (4,059 bubble particles, 7,616 crit particles, 33 splashes, 210 bubble-column particles, 142 hit sounds, 28 despawns).
  • test_native_scene_motion.py still 2,499,038 / 2,499,038; cargo clippy --workspace --all-targets -D warnings clean; cargo test -p horizon-client --lib 441 passed.

In-game check

Linux build on a vscreen, survival, bow drawn 1.2 s into a 3-deep pool: the arrow splashes on entry, trails bubbles, slows and sticks in the pool floor short of its dry landing spot.

Left for the next PRs / not covered

  • Fire (lava/fire ignition, Flame, burning hits, TNT/campfires/candles): #125/#124, stacked next.
  • Pickup (#119): next after that.
  • Rain uses raining + sky light 15 (no biome precipitation check); entity hits keep the game's 0.3-inflated boxes and no piercing; powder snow/scaffolding entity collision contexts and world-border bounces are not modelled in the clip.

🤖 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/187 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/arrow-water-127` --- ### 📝 Commits (4) - [`60d9bff`](https://github.com/horizon-rust/horizon/commit/60d9bffc8682c8d4ebe12471b1de17c430db86ec) Water cancels the player's fall damage (#180) - [`f442374`](https://github.com/horizon-rust/horizon/commit/f442374e6da1e6164f3fee62fea3a6533f1bbd51) Format the player fluid binding - [`645109d`](https://github.com/horizon-rust/horizon/commit/645109d427fea81f90e8dfe437f57e7bfda19a42) Keep the scene motion scope text a valid string - [`1d93642`](https://github.com/horizon-rust/horizon/commit/1d93642094bbe2e46a977586ecaa0ce3da5f516a) Arrows get vanilla's water physics (#127) ### 📊 Changes **15 files changed** (+2119 additions, -90 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/arrow_probe.rs` (+224 -0) 📝 `crates/horizon-client/examples/scene_motion_probe.rs` (+37 -3) ➕ `crates/horizon-client/src/arrows.rs` (+875 -0) 📝 `crates/horizon-client/src/game.rs` (+31 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+97 -8) 📝 `crates/horizon-client/src/landing.rs` (+3 -3) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/motion.rs` (+36 -6) ➕ `crates/horizon-client/src/motion/fluids.rs` (+336 -0) 📝 `crates/horizon-client/src/projectiles.rs` (+30 -57) 📝 `crates/horizon-world/src/entity_fluid.rs` (+1 -1) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaArrowOracle.java` (+130 -0) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java` (+29 -11) ➕ `tools/test_arrow_parity.py` (+171 -0) 📝 `tools/test_native_scene_motion.py` (+118 -1) </details> ### 📄 Description Fixes #127 **Stacked on #186** (reuses its `FluidResources`/fluid tag binding); base is `fix/water-fall-damage-180`. Retarget to `main` before merging #186 with branch deletion. ## Root cause Arrows ran a simplified projectile tick: a point lookup for "in water" chose 0.6 instead of 0.99 drag after the move, and that was all. No bubbles, no splash, no currents, no bubble columns; sticking nudged back by the normalized motion; stuck arrows never fell out when their block went and despawned on a 1200-tick *age*. ## Fix `crates/horizon-client/src/arrows.rs` ports `AbstractArrow.tick` for arrows (state in `Projectile::arrow`, ticked by `arrows::tick`; other projectiles keep `Projectile::tick`): - the in-block check (a stuck arrow inside a collision box stops), shake, `clearFire` in water; - in-ground: fall out (`startFalling`, the arrow's own random) when the block it hit changed and nothing collides around it, else `life` toward the 1200-tick despawn; block effects at rest; - in flight: water inertia 0.6 from the last base tick's `wasTouchingWater` with four bubbles behind the arrow, crit trails, `lerpRotation` (folded `RAD_TO_DEG`), `checkLeftOwner`, the `COLLIDER`/`Fluid.NONE` clip with the nearest entity first, the blocks along the path (`applyEffectsFromBlocks`: bubble columns push up/down or drag with their particles, water extinguishes, `StepBasedCollector` order), 0.99 drag only out of water, gravity through `Vec3.add` (signed zeros), then the base tick: `updateFluidInteraction` (currents while not stuck, `entity.generic.splash` with bubble/splash particles), fire ticks, lava halving, below-world removal; - `onHitBlock`: back 0.05 along each moving axis (`Math.signum`), stop, hit sound pitch from the arrow's random, shake 7, crit off. The game plays the events (`arrow_event`: particles, sounds, the level-random bubble column particles, the SPLASH game event); entity hits are still the game's (`projectile_hit`), the arrow is spent on a hit. ## Parity proof New harness `tools/test_arrow_parity.py`: real vanilla `Arrow` entities (`VanillaArrowOracle`, over an independent copy of the resident scene) vs `arrows::tick` (`examples/arrow_probe.rs`), one state line (position, motion, rotation, ground, life, shake, stuck block, fire, water flags, fluid heights, removal, crit, fall) and one ordered event line per operation. 197 fixtures: flights with/without crits and physics, shots into/through/from inside 3-deep source, flowing and falling water, random currents, kelp/seagrass/waterlogged blocks, bubble columns (drag up/down, open/water/stone above), sticking in 12 full and partial shapes then the block removed or replaced, starting inside blocks, and the 1200-tick despawn. - Mac mini: **83,573 / 83,573** lines on both the client and server jars (4,059 bubble particles, 7,616 crit particles, 33 splashes, 210 bubble-column particles, 142 hit sounds, 28 despawns). - `test_native_scene_motion.py` still 2,499,038 / 2,499,038; `cargo clippy --workspace --all-targets -D warnings` clean; `cargo test -p horizon-client --lib` 441 passed. ## In-game check Linux build on a vscreen, survival, bow drawn 1.2 s into a 3-deep pool: the arrow splashes on entry, trails bubbles, slows and sticks in the pool floor short of its dry landing spot. ## Left for the next PRs / not covered - Fire (lava/fire ignition, Flame, burning hits, TNT/campfires/candles): #125/#124, stacked next. - Pickup (#119): next after that. - Rain uses raining + sky light 15 (no biome precipitation check); entity hits keep the game's 0.3-inflated boxes and no piercing; powder snow/scaffolding entity collision contexts and world-border bounces are not modelled in the clip. 🤖 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:55:34 +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#2388
No description provided.