mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
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:
parent
956780c6a6
commit
931c3ed77d
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user