Player: Cleaned up how hurt animations are handled

Override Living->doHitAnimation() instead to ensure that the animation always gets sent to the player.
This commit is contained in:
Dylan K. Taylor 2017-12-14 11:34:09 +00:00
parent 532600ab67
commit 3f50f88e2c

View File

@ -3607,10 +3607,15 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($source->isCancelled()){
return;
}elseif($this->getLastDamageCause() === $source and $this->spawned){
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION, null, [$this]);
}
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_DAMAGE);
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_DAMAGE);
}
protected function doHitAnimation() : void{
parent::doHitAnimation();
if($this->spawned){
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION, null, [$this]);
}
}