[PR #238] [MERGED] Player water on #59: bubble columns, swim sounds, drown bubbles, vanilla fixes #2426

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

📋 Pull Request Information

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

Base: main ← Head: fix/player-water-physics


📝 Commits (1)

  • a2b2b3f Player water on #59: bubble columns, swim sounds, drown bubbles, vanilla fixes

📊 Changes

11 files changed (+547 additions, -96 deletions)

View changed files

📝 crates/horizon-client/examples/scene_motion_probe.rs (+55 -9)
📝 crates/horizon-client/src/game.rs (+51 -4)
📝 crates/horizon-client/src/game/remote.rs (+18 -6)
📝 crates/horizon-client/src/health.rs (+3 -0)
📝 crates/horizon-client/src/motion.rs (+83 -49)
📝 crates/horizon-client/src/motion/environment.rs (+99 -2)
📝 crates/horizon-client/src/motion/fluids.rs (+4 -2)
📝 crates/horizon-client/src/pose.rs (+5 -4)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java (+68 -17)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSprintInputOracle.java (+7 -2)
📝 tools/test_native_scene_motion.py (+154 -1)

📄 Description

Builds on Cosmic's #59, which brought player fluid travel, swimming, the air supply and drowning. This PR is now rebased onto main with #59 merged. It keeps #59's code and structure (motion.rs, motion/fluids.rs, motion/environment.rs) and changes only what differs from vanilla 26.3 or what #59 doesn't have. Every point was checked against the vanilla sources and bytecode.

What this adds or fixes on top of #59

  • Bubble columns push the player. BubbleColumnBlock.entityInside (isPrecise) → Player.onAbove/onInsideBubbleColumn, which does nothing while flying.
    • Above the column: min(1.8, y+0.1) going up, max(-0.9, y-0.03) going down, plus splash and bubble particles from the level random.
    • Inside the column: min(0.7, y+0.06) going up, max(-0.3, y-0.03) going down, and the fall distance is reset.
  • goDownInWater now runs where LocalPlayer.aiStep runs it: before LivingEntity.aiStep's small-velocity cleanup, not after it.
  • Jump phase follows vanilla's structure:
    • Nothing happens while flying (isAffectedByFluids).
    • getFluidJumpThreshold comes from the eye height (eyes under 0.4 → 0), also in travelInLava. #59 used a constant 0.4.
  • Swim steering samples y + 1.0 - 0.1 (was y + 0.9).
  • Travel order: LivingEntity.travel checks fluids before gliding, and Player.travel keeps 0.6 of the vertical speed around it while flying.
  • Elytra: water and lava no longer end a glide (updateFallFlying only checks canGlide). Starting a glide is still blocked in liquids.
  • isUnderWater is LocalPlayer.isUnderWater (wasUnderwater). #59 used Entity's version, which also requires touching water.
  • Sprint conditions now include shallow water, may-fly/flying and gliding. #59 passed only in-water, under-water and swimming, so the player could start sprinting in shallow water.
  • Tick order and pose:
    • No double-tap flight toggle while swimming.
    • The base tick (fluids, swimming) runs before LocalPlayer.aiStep's crouch selection.
    • getDesiredPose puts swimming before gliding, and a spectator takes the desired pose.
  • Oxygen bonus: decreaseAirSupply creates the oxygen_bonus attribute instance, like vanilla's getAttribute (the harness compares allocated instances).
  • Swim sounds: Player.playStepSound in water plays waterSwimSound and then the muffled step (0.05 volume, 0.8 pitch). Swimming plays entity.player.swim.
  • Drown bubbles: entity event 67 shows 8 bubbles around a drowning player.
  • Harness case for player fluid travel. #59's water corpus never had the player travel in fluid. Both oracles now run the real methods:
    • updateIsUnderwater and updateSwimming
    • the air supply
    • effects as flags
    • containsAnyLiquid
    • drown damage, swim sounds and bubble column particles
    • goDownInWater for the controlled actor

Lava ignition and damage are out of scope and unchanged (#59's). The lava travel fixtures use player_tick, which leaves them out.

Proof (Mac mini)

  • Scene motion harness (tools/test_native_scene_motion.py). The new swim_corpus covers deep water at every pitch with and without sprint, shallow and waterlogged water with depth strider and dolphins_grace, ledges, ladders, lava, currents, flying, bubble columns up and down of 3 heights under air, water or stone, and the air supply with effects and oxygen.
    • main corpus: 2,841,094 states match vanilla, client jar and server jar
    • --sprint-input (sprint-swim runs and the tunnel crawl): 424,684 states match
  • cargo fmt --check and cargo clippy --workspace --all-targets -- -D warnings are clean, and cargo test -p horizon-client passes (630 tests).
  • Fixed in the harness: the scope string in #238's last push had apostrophes that broke the Python. Flying bubble-column fixtures no longer jump, because jumping while flying is LocalPlayer's vertical flight, which the server-side oracle doesn't model.

In game (Mac mini, release build)

The screen was locked, so the game ran with --offscreen and was driven with horizon-ctl in survival.

  • Idle in deep water sinks at -0.0248 → -0.025 b/t.
  • Holding space rises at 0.135 b/t and bobs at the surface.
  • Sprint-swim at pitch 20 reaches 0.175 b/t with the low swim-pose camera.
  • Drowning: the air bar empties after about 15 s, then 2 damage every second.
  • Bubble column (soul sand): 0.7 b/t inside, 0.775 at the top, and the player is thrown out to y+2 and then held at the surface with bubbles.
Idle, sinking Space: at the surface, air refilling
idle surface
Sprint-swimming (swim-pose camera) Drowning: air empty, hearts going
swim drown
Held at the top of a bubble column (F5)
column

Follow-ups (not in this PR)

  • The third-person avatar still renders upright while swimming: perspective.rs has no swim-pose rendering.
  • The harness's drag columns stand on stone, because MagmaBlock.stepOn needs a hot_floor damage source the oracle doesn't register.

Needs Ludovic

Nothing. The screenshots are on the pr-evidence/238 branch and can be deleted after merge.

🤖 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/238 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/player-water-physics` --- ### 📝 Commits (1) - [`a2b2b3f`](https://github.com/horizon-rust/horizon/commit/a2b2b3f7761bffb6230ae52e6b737744454948d2) Player water on #59: bubble columns, swim sounds, drown bubbles, vanilla fixes ### 📊 Changes **11 files changed** (+547 additions, -96 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/scene_motion_probe.rs` (+55 -9) 📝 `crates/horizon-client/src/game.rs` (+51 -4) 📝 `crates/horizon-client/src/game/remote.rs` (+18 -6) 📝 `crates/horizon-client/src/health.rs` (+3 -0) 📝 `crates/horizon-client/src/motion.rs` (+83 -49) 📝 `crates/horizon-client/src/motion/environment.rs` (+99 -2) 📝 `crates/horizon-client/src/motion/fluids.rs` (+4 -2) 📝 `crates/horizon-client/src/pose.rs` (+5 -4) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSceneMotionOracle.java` (+68 -17) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaSprintInputOracle.java` (+7 -2) 📝 `tools/test_native_scene_motion.py` (+154 -1) </details> ### 📄 Description Builds on Cosmic's #59, which brought player fluid travel, swimming, the air supply and drowning. This PR is now rebased onto main with #59 merged. It keeps #59's code and structure (`motion.rs`, `motion/fluids.rs`, `motion/environment.rs`) and changes only what differs from vanilla 26.3 or what #59 doesn't have. Every point was checked against the vanilla sources and bytecode. ## What this adds or fixes on top of #59 - **Bubble columns push the player.** `BubbleColumnBlock.entityInside` (isPrecise) → `Player.onAbove/onInsideBubbleColumn`, which does nothing while flying. - Above the column: min(1.8, y+0.1) going up, max(-0.9, y-0.03) going down, plus splash and bubble particles from the level random. - Inside the column: min(0.7, y+0.06) going up, max(-0.3, y-0.03) going down, and the fall distance is reset. - **goDownInWater** now runs where `LocalPlayer.aiStep` runs it: before `LivingEntity.aiStep`'s small-velocity cleanup, not after it. - **Jump phase** follows vanilla's structure: - Nothing happens while flying (`isAffectedByFluids`). - `getFluidJumpThreshold` comes from the eye height (eyes under 0.4 → 0), also in `travelInLava`. #59 used a constant 0.4. - **Swim steering** samples `y + 1.0 - 0.1` (was `y + 0.9`). - **Travel order:** `LivingEntity.travel` checks fluids before gliding, and `Player.travel` keeps 0.6 of the vertical speed around it while flying. - **Elytra:** water and lava no longer end a glide (`updateFallFlying` only checks `canGlide`). Starting a glide is still blocked in liquids. - **isUnderWater** is `LocalPlayer.isUnderWater` (`wasUnderwater`). #59 used Entity's version, which also requires touching water. - **Sprint conditions** now include shallow water, may-fly/flying and gliding. #59 passed only in-water, under-water and swimming, so the player could start sprinting in shallow water. - **Tick order and pose:** - No double-tap flight toggle while swimming. - The base tick (fluids, swimming) runs before `LocalPlayer.aiStep`'s crouch selection. - `getDesiredPose` puts swimming before gliding, and a spectator takes the desired pose. - **Oxygen bonus:** `decreaseAirSupply` creates the oxygen_bonus attribute instance, like vanilla's `getAttribute` (the harness compares allocated instances). - **Swim sounds:** `Player.playStepSound` in water plays `waterSwimSound` and then the muffled step (0.05 volume, 0.8 pitch). Swimming plays `entity.player.swim`. - **Drown bubbles:** entity event 67 shows 8 bubbles around a drowning player. - **Harness case for player fluid travel.** #59's water corpus never had the player travel in fluid. Both oracles now run the real methods: - `updateIsUnderwater` and `updateSwimming` - the air supply - effects as flags - `containsAnyLiquid` - drown damage, swim sounds and bubble column particles - `goDownInWater` for the controlled actor Lava ignition and damage are out of scope and unchanged (#59's). The lava travel fixtures use `player_tick`, which leaves them out. ## Proof (Mac mini) - **Scene motion harness** (`tools/test_native_scene_motion.py`). The new `swim_corpus` covers deep water at every pitch with and without sprint, shallow and waterlogged water with depth strider and dolphins_grace, ledges, ladders, lava, currents, flying, bubble columns up and down of 3 heights under air, water or stone, and the air supply with effects and oxygen. - main corpus: **2,841,094 states match vanilla, client jar and server jar** - `--sprint-input` (sprint-swim runs and the tunnel crawl): **424,684 states match** - `cargo fmt --check` and `cargo clippy --workspace --all-targets -- -D warnings` are clean, and `cargo test -p horizon-client` passes (630 tests). - Fixed in the harness: the scope string in #238's last push had apostrophes that broke the Python. Flying bubble-column fixtures no longer jump, because jumping while flying is `LocalPlayer`'s vertical flight, which the server-side oracle doesn't model. ## In game (Mac mini, release build) The screen was locked, so the game ran with `--offscreen` and was driven with horizon-ctl in survival. - Idle in deep water sinks at **-0.0248 → -0.025 b/t**. - Holding space rises at **0.135 b/t** and bobs at the surface. - Sprint-swim at pitch 20 reaches **0.175 b/t** with the low swim-pose camera. - Drowning: the air bar empties after about 15 s, then **2 damage every second**. - Bubble column (soul sand): **0.7 b/t** inside, 0.775 at the top, and the player is thrown out to y+2 and then held at the surface with bubbles. | Idle, sinking | Space: at the surface, air refilling | |---|---| | ![idle](https://raw.githubusercontent.com/ludovic111/horizon/pr-evidence/238/1-idle-sink.png) | ![surface](https://raw.githubusercontent.com/ludovic111/horizon/pr-evidence/238/2-space-surface.png) | | **Sprint-swimming (swim-pose camera)** | **Drowning: air empty, hearts going** | | ![swim](https://raw.githubusercontent.com/ludovic111/horizon/pr-evidence/238/3-sprint-swim.png) | ![drown](https://raw.githubusercontent.com/ludovic111/horizon/pr-evidence/238/4b-drowning.png) | | **Held at the top of a bubble column (F5)** | | | ![column](https://raw.githubusercontent.com/ludovic111/horizon/pr-evidence/238/5c-bubble-column-f5.png) | | ## Follow-ups (not in this PR) - The third-person avatar still renders upright while swimming: `perspective.rs` has no swim-pose rendering. - The harness's drag columns stand on stone, because `MagmaBlock.stepOn` needs a hot_floor damage source the oracle doesn't register. ## Needs Ludovic Nothing. The screenshots are on the `pr-evidence/238` branch and can be deleted after merge. 🤖 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:01 +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#2426
No description provided.