[PR #6665] [MERGED] Minecarts: float drags and size, and the water state of the tick before #7021

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6665
Author: @apeirs
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/minecart-float-drag


📝 Commits (5)

📊 Changes

2 files changed (+57 additions, -23 deletions)

View changed files

📝 crates/horizon-client/src/game/minecarts.rs (+33 -23)
📝 tools/command_exec_corpus.py (+24 -0)

📄 Description

🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally.

What and why

Fixes #5051. A minecart's position and velocity drifted from vanilla 26.3 in three ways:

  • Float drags. AbstractMinecart.comeOffTrack scales by getAirDrag() (0.95F), and applyNaturalSlowdown by scale(0.95F) in water: floats widened to 0.949999988079071. Horizon multiplied by 0.95.
  • Float size. EntityTypes.MINECART is sized(0.98F, 0.7F). minecarts::WIDTH/HEIGHT were 0.98/0.7, so a cart stopped by a block sat 9.5e-9 (half of 0.98F − 0.98) off vanilla's spot.
  • The water check a tick early. isInWater() is wasTouchingWater, which AbstractMinecart.tick updates in updateFluidInteraction() after behavior.tick(). So the move goes by where the cart was the tick before, and a new cart's first move is a dry one. Horizon looked at the block under the cart live on every call. A cart on waterlogged rails therefore slowed by one 0.95F too many: after 20 ticks, Motion was 0.0475 against vanilla's 0.0500.

crates/horizon-client/src/game/minecarts.rs:

  • Minecart.in_water, set once a tick after the move (updateFluidInteraction), is now what gravity, the max speed, the slope slide and the slowdown read, for the old behaviour and the new (minecart_improvements) one alike. The check behind it is the cart's box against water (bounds_in_water, as the TNT cart's blast already uses), not the block at its feet.
  • come_off_track and natural_slowdown drag by f64::from(0.95_f32).
  • WIDTH/HEIGHT are 0.98_f32/0.7_f32 widened.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Read from the 26.3 bytecode (javap, plus a local decompile that isn't committed):

  • AbstractMinecart.tick: behavior.tick(), then updateFluidInteraction(); Entity.updateFluidInteraction sets wasTouchingWater, which isInWater() returns.
  • AbstractMinecart.getAirDrag → 0.95f; AbstractMinecart.applyNaturalSlowdown → scale(0.949999988079071d) in water; comeOffTrack → scale(getAirDrag()).
  • EntityTypes static init: MINECART sized(0.98f, 0.7f).
  • OldMinecartBehavior.getMaxSpeed (0.2 in water, 0.4) and getSlowdownFactor (0.997/0.96) are doubles, and so is pushOtherMinecart's 0.95; those were already right.

Harness: tools/test_command_exec_parity.py, new group minecart drag in command_exec_corpus.py. It compares the exact Pos and Motion doubles:

  • A cart is pushed along powered rails into a stone block, bounces back, leaves the rails and falls (air drag and the float width).
  • A cart rolls along waterlogged rails (the water slowdown and its timing).

Results against the vanilla 26.3 oracle:

  • This branch at d0ce8fa54: minecart drag: 6/6, whole harness 965/965 commands match.
  • Main at 9d979caa4: minecart drag: 2/6. On the dry cart, x was off by 4.5e-8 and Motion by ~1e-9. On the wet cart, Motion was 0.04753… against 0.05003… and x 4.1107 against 4.2955.

While probing I also saw that after a cart turns back on rails, Horizon's z Motion reads -0.0 where vanilla's reads 0.0 (on ticks the cart stays in one block). It changes nothing in the movement, and I couldn't find where vanilla loses the sign, so it isn't in this PR. The harness samples the cart after it has left the rails, where both agree.

Self-check

pr_ready (tools/pr_ready.py --quick --verbose on arch, against origin/main at d0ce8fa54, 10 min 57 s)

Check Result
Scope ✅ 2 files, +54 −21
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (1 min 2 s)
rustfmt ✅ (14 s)
clippy ✅ (2 min 27 s)
tests: horizon-client ✅ 1577 passed (7 min 11 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Since then I rebased onto main at 80dfb5f35; the only conflict was the corpus's group list. On the rebased commit, cargo fmt --check and cargo clippy -p horizon-client --all-targets --locked -- -D warnings are clean (on the IdeaPad, through rbuild). On the same commit, cargo test -p horizon-client --lib minecart passes 10 tests (mesh on the IdeaPad).


🔄 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/6665 **Author:** [@apeirs](https://github.com/apeirs) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/minecart-float-drag` --- ### 📝 Commits (5) - [`1e6f4e7`](https://github.com/horizon-rust/horizon/commit/1e6f4e737e3455c895b761b4c952c4eca8b58017) Minecarts: float drags and size, and the water state of the tick before - [`0af63f6`](https://github.com/horizon-rust/horizon/commit/0af63f66e6b943f77fe97ed6a8739d71ba298b86) Merge main into #6665 - [`20f847e`](https://github.com/horizon-rust/horizon/commit/20f847e5ffde31e5315b28b763270711ba2b2c97) Merge main into #6665 - [`e4a8f9e`](https://github.com/horizon-rust/horizon/commit/e4a8f9ebd355e0fe4c887b69c52ef7d716283bc0) Merge main into #6665 - [`44ee33c`](https://github.com/horizon-rust/horizon/commit/44ee33c861725b0292dcf2fd3a31fb16600a3be0) Fall damage reads the cart's last-tick water state ### 📊 Changes **2 files changed** (+57 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/minecarts.rs` (+33 -23) 📝 `tools/command_exec_corpus.py` (+24 -0) </details> ### 📄 Description > 🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally. ## What and why Fixes #5051. A minecart's position and velocity drifted from vanilla 26.3 in three ways: - **Float drags.** `AbstractMinecart.comeOffTrack` scales by `getAirDrag()` (`0.95F`), and `applyNaturalSlowdown` by `scale(0.95F)` in water: floats widened to `0.949999988079071`. Horizon multiplied by `0.95`. - **Float size.** `EntityTypes.MINECART` is `sized(0.98F, 0.7F)`. `minecarts::WIDTH`/`HEIGHT` were `0.98`/`0.7`, so a cart stopped by a block sat 9.5e-9 (half of `0.98F − 0.98`) off vanilla's spot. - **The water check a tick early.** `isInWater()` is `wasTouchingWater`, which `AbstractMinecart.tick` updates in `updateFluidInteraction()` *after* `behavior.tick()`. So the move goes by where the cart was the tick before, and a new cart's first move is a dry one. Horizon looked at the block under the cart live on every call. A cart on waterlogged rails therefore slowed by one `0.95F` too many: after 20 ticks, Motion was 0.0475 against vanilla's 0.0500. `crates/horizon-client/src/game/minecarts.rs`: - `Minecart.in_water`, set once a tick after the move (`updateFluidInteraction`), is now what gravity, the max speed, the slope slide and the slowdown read, for the old behaviour and the new (`minecart_improvements`) one alike. The check behind it is the cart's box against water (`bounds_in_water`, as the TNT cart's blast already uses), not the block at its feet. - `come_off_track` and `natural_slowdown` drag by `f64::from(0.95_f32)`. - `WIDTH`/`HEIGHT` are `0.98_f32`/`0.7_f32` widened. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Read from the 26.3 bytecode (javap, plus a local decompile that isn't committed): - `AbstractMinecart.tick`: `behavior.tick()`, then `updateFluidInteraction()`; `Entity.updateFluidInteraction` sets `wasTouchingWater`, which `isInWater()` returns. - `AbstractMinecart.getAirDrag` → `0.95f`; `AbstractMinecart.applyNaturalSlowdown` → `scale(0.949999988079071d)` in water; `comeOffTrack` → `scale(getAirDrag())`. - `EntityTypes` static init: `MINECART` `sized(0.98f, 0.7f)`. - `OldMinecartBehavior.getMaxSpeed` (0.2 in water, 0.4) and `getSlowdownFactor` (0.997/0.96) are doubles, and so is `pushOtherMinecart`'s 0.95; those were already right. Harness: `tools/test_command_exec_parity.py`, new group `minecart drag` in `command_exec_corpus.py`. It compares the exact `Pos` and `Motion` doubles: - A cart is pushed along powered rails into a stone block, bounces back, leaves the rails and falls (air drag and the float width). - A cart rolls along waterlogged rails (the water slowdown and its timing). Results against the vanilla 26.3 oracle: - This branch at `d0ce8fa54`: `minecart drag: 6/6`, whole harness `965/965 commands match`. - Main at `9d979caa4`: `minecart drag: 2/6`. On the dry cart, x was off by 4.5e-8 and Motion by ~1e-9. On the wet cart, Motion was 0.04753… against 0.05003… and x 4.1107 against 4.2955. While probing I also saw that after a cart turns back on rails, Horizon's z Motion reads `-0.0` where vanilla's reads `0.0` (on ticks the cart stays in one block). It changes nothing in the movement, and I couldn't find where vanilla loses the sign, so it isn't in this PR. The harness samples the cart after it has left the rails, where both agree. ## Self-check **pr_ready** (`tools/pr_ready.py --quick --verbose` on arch, against origin/main at d0ce8fa54, 10 min 57 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +54 −21 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (1 min 2 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (2 min 27 s) | | tests: horizon-client | ✅ 1577 passed (7 min 11 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Since then I rebased onto main at `80dfb5f35`; the only conflict was the corpus's group list. On the rebased commit, `cargo fmt --check` and `cargo clippy -p horizon-client --all-targets --locked -- -D warnings` are clean (on the IdeaPad, through `rbuild`). On the same commit, `cargo test -p horizon-client --lib minecart` passes 10 tests (`mesh` on the IdeaPad). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:32:14 +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#7021
No description provided.