mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
Living: added calculateFallDamage()
to clean up the way that fall damage is handled for flying players; also, onHitGround() isn't only doing fall damage things these days.
This commit is contained in:
parent
6b7e671794
commit
d4d00a9b80
@ -305,8 +305,12 @@ abstract class Living extends Entity{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function calculateFallDamage(float $fallDistance) : float{
|
||||||
|
return ceil($fallDistance - 3 - (($jumpBoost = $this->effectManager->get(VanillaEffects::JUMP_BOOST())) !== null ? $jumpBoost->getEffectLevel() : 0));
|
||||||
|
}
|
||||||
|
|
||||||
protected function onHitGround() : void{
|
protected function onHitGround() : void{
|
||||||
$damage = ceil($this->fallDistance - 3 - (($jumpBoost = $this->effectManager->get(VanillaEffects::JUMP_BOOST())) !== null ? $jumpBoost->getEffectLevel() : 0));
|
$damage = $this->calculateFallDamage($this->fallDistance);
|
||||||
if($damage > 0){
|
if($damage > 0){
|
||||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage);
|
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage);
|
||||||
$this->attack($ev);
|
$this->attack($ev);
|
||||||
|
@ -1200,10 +1200,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
$this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET);
|
$this->sendPosition($from, $from->yaw, $from->pitch, MovePlayerPacket::MODE_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function onHitGround() : void{
|
protected function calculateFallDamage(float $fallDistance) : float{
|
||||||
if(!$this->flying){
|
return $this->flying ? 0 : parent::calculateFallDamage($fallDistance);
|
||||||
parent::onHitGround();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jump() : void{
|
public function jump() : void{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user