Entity: fixed current movement not being accounted for in fall height

this caused incorrect damage when falling from heights, as well as a bug in #4434.
This commit is contained in:
Dylan K. Taylor 2021-09-06 12:53:37 +01:00
parent 956780c6a6
commit 931c3ed77d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1029,13 +1029,7 @@ abstract class Entity{
}
protected function updateFallState(float $distanceThisTick, bool $onGround) : ?float{
if($onGround){
if($this->fallDistance > 0){
$newVerticalVelocity = $this->onHitGround();
$this->resetFallDistance();
return $newVerticalVelocity;
}
}elseif($distanceThisTick < $this->fallDistance){
if($distanceThisTick < $this->fallDistance){
//we've fallen some distance (distanceThisTick is negative)
//or we ascended back towards where fall distance was measured from initially (distanceThisTick is positive but less than existing fallDistance)
$this->fallDistance -= $distanceThisTick;
@ -1044,6 +1038,11 @@ abstract class Entity{
//reset it so it will be measured starting from the new, higher position
$this->fallDistance = 0;
}
if($onGround && $this->fallDistance > 0){
$newVerticalVelocity = $this->onHitGround();
$this->resetFallDistance();
return $newVerticalVelocity;
}
return null;
}