Skip to content

player/player.go: Only deal fall damage on an actual vertical collision#1283

Closed
root-nat wants to merge 1 commit into
df-mc:masterfrom
root-nat:fix/fall-damage-near-blocks
Closed

player/player.go: Only deal fall damage on an actual vertical collision#1283
root-nat wants to merge 1 commit into
df-mc:masterfrom
root-nat:fix/fall-damage-near-blocks

Conversation

@root-nat

@root-nat root-nat commented Jun 23, 2026

Copy link
Copy Markdown

Problem

When a player falls close to a block at its side it takes premature fall damage (#1003). The cause is checkOnGround: it extended the probe box opposite to the whole movement (deltaPos.Mul(-1.0)), which while falling pushes the box upwards and sideways, so a block next to the fall path intersects it and the player is wrongly reported on the ground.

Fix

Extend the probe straight down only — by 0.05 plus the tick's descent — keeping the player's exact horizontal footprint:

.Extend(mgl64.Vec3{0, -0.05}).Extend(mgl64.Vec3{0, math.Min(deltaPos[1], 0)})

A block at the side is no longer mistaken for ground, while a stepped or fast descent still finds the ground beneath the footprint. updateFallState is left untouched. This is the root-cause fix suggested in the previous review, rather than patching the fall-damage path.

Testing

Verified in-game on 1.26.30:

Fixes #1003.

🤖 Generated with Claude Code

The on-ground check used for fall damage extends the player bounding box
along the movement of the tick, reporting a landing as soon as it intersects
any block. While falling next to a block at the side, that intersection
registered a landing in mid-air, dealing premature fall damage and clearing
the accumulated fall distance.

Also require a vertical collision on the tick before applying the damage. A
real landing always truncates the downward movement, whereas brushing a block
sideways does not, so the fall distance keeps accumulating until the player
actually reaches the ground.

Fixes df-mc#1003.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TwistedAsylumMC

Copy link
Copy Markdown
Member

We should fix the on ground being set to true when falling past blocks rather than this

@root-nat

Copy link
Copy Markdown
Author

Thanks for the steer — agreed, patching updateFallState was treating the symptom.

I've reworked it to fix checkOnGround directly. The probe box was extended opposite to the whole movement (deltaPos.Mul(-1.0)), which while falling pushes it upwards and sideways, so a block next to the fall path intersects it and the player reports as grounded. The rework extends the probe straight down only — by 0.05 plus the tick's descent — keeping the player's exact horizontal footprint:

.Extend(mgl64.Vec3{0, -0.05}).Extend(mgl64.Vec3{0, math.Min(deltaPos[1], 0)})

A block at the side is no longer mistaken for ground, while a stepped or fast descent still finds the ground beneath the footprint, so the sprinting-down-stairs fix from #1044 should hold (the 0.6-wide footprint always straddles the step it is leaving, and the descent term keeps the downward reach in step with the gap). The idle-tick call, which passes a zero delta, is unchanged.

Does this match what you had in mind? If so I'll reopen with it — I'll give the stairs/slabs case a run in-game first either way.

@root-nat

Copy link
Copy Markdown
Author

Continued in #1286 with the root-cause checkOnGround rework (this PR could not be reopened after the branch was force-pushed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fall damage when getting close to blocks while falling

2 participants