[PR #6510] Hurt a glide by the distance the block actually stopped #6922

Open
opened 2026-11-03 06:29:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6510
Author: @MSedgeMC
Created: 11/1/2026
Status: 🔄 Open

Base: main ← Head: fix/elytra-collision-damage


📝 Commits (1)

  • 4744214 Hurt a glide by the distance the block actually stopped

📊 Changes

1 file changed (+25 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/motion.rs (+25 -6)

📄 Description

Vanilla's glide takes collision damage from how much of its speed a block took away:

// javap -p -c on LivingEntity (travel's fall-flying branch)
22-26: getDeltaMovement().horizontalDistance() -> d3      // before the move
27-33: setDeltaMovement(updateFallFlyingMovement(...))
36-44: move(MoverType.SELF, getDeltaMovement())
57-64: getDeltaMovement().horizontalDistance() -> d5      // after the move
66-70: handleFallFlyingCollisions(d3, d5)
// handleFallFlyingCollisions
if (horizontalCollision) {
    float f = (float)((d3 - d5) * 10.0 - 3.0);
    if (f > 0) { playSound(getFallDamageSound((int)f)); hurt(flyIntoWall, f); }
}

d5 is small because Entity.move ends by leaving the delta at the movement it resolved.
Horizon's move_entity does not write the resolved movement back - it only multiplies the
velocity by the block speed factor - so the "after" value Horizon read from
player.velocity was the same as the "before" one and (d3 - d5) * 10 - 3 came out at -3,
i.e. no damage, which is the report: flying into blocks at speed often does nothing.

The after value is now the horizontal distance the player actually travelled during the
move, which is what vanilla's resolved delta measures.

Proven: on the build VM,
cargo test -q -p horizon-client-lib --lib a_glide_hurts_by_what_a_collision_took_off_its_speed
→ 1 passed: a move that lost nothing reads -3.0, losing exactly 0.3 reads 0.0 (no damage at
the boundary), 0.5 -> 0.1 reads 1.0, and 1.2 -> 0.0 reads 9.0. cargo clippy -q -p horizon-client-lib --lib → clean.

Not proven: not flown in game; the check is the report's own - glide into a wall at speed
and take fly_into_wall damage plus the fall sound, more of it the faster the stop.

Note: this changes what the damage reads, not the rest of the glide. move_entity still
leaves the player's velocity unclipped after a collision (vanilla zeroes the blocked axis
there); that is a wider change affecting every entity's move and is left alone here, since
the position, collision flags and the damage all no longer depend on it.


🔄 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/6510 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/elytra-collision-damage` --- ### 📝 Commits (1) - [`4744214`](https://github.com/horizon-rust/horizon/commit/474421407cdc3b5d72d091375aba429fe3805f01) Hurt a glide by the distance the block actually stopped ### 📊 Changes **1 file changed** (+25 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/motion.rs` (+25 -6) </details> ### 📄 Description Vanilla's glide takes collision damage from how much of its speed a block took away: ```java // javap -p -c on LivingEntity (travel's fall-flying branch) 22-26: getDeltaMovement().horizontalDistance() -> d3 // before the move 27-33: setDeltaMovement(updateFallFlyingMovement(...)) 36-44: move(MoverType.SELF, getDeltaMovement()) 57-64: getDeltaMovement().horizontalDistance() -> d5 // after the move 66-70: handleFallFlyingCollisions(d3, d5) ``` ```java // handleFallFlyingCollisions if (horizontalCollision) { float f = (float)((d3 - d5) * 10.0 - 3.0); if (f > 0) { playSound(getFallDamageSound((int)f)); hurt(flyIntoWall, f); } } ``` `d5` is small because `Entity.move` ends by leaving the delta at the movement it resolved. Horizon's `move_entity` does not write the resolved movement back - it only multiplies the velocity by the block speed factor - so the "after" value Horizon read from `player.velocity` was the same as the "before" one and `(d3 - d5) * 10 - 3` came out at -3, i.e. no damage, which is the report: flying into blocks at speed often does nothing. The after value is now the horizontal distance the player actually travelled during the move, which is what vanilla's resolved delta measures. **Proven:** on the build VM, `cargo test -q -p horizon-client-lib --lib a_glide_hurts_by_what_a_collision_took_off_its_speed` → `1 passed`: a move that lost nothing reads -3.0, losing exactly 0.3 reads 0.0 (no damage at the boundary), 0.5 -> 0.1 reads 1.0, and 1.2 -> 0.0 reads 9.0. `cargo clippy -q -p horizon-client-lib --lib` → clean. **Not proven:** not flown in game; the check is the report's own - glide into a wall at speed and take `fly_into_wall` damage plus the fall sound, more of it the faster the stop. Note: this changes what the damage reads, not the rest of the glide. `move_entity` still leaves the player's velocity unclipped after a collision (vanilla zeroes the blocked axis there); that is a wider change affecting every entity's move and is left alone here, since the position, collision flags and the damage all no longer depend on it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6922
No description provided.