mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Cleaned up death animation handling, removed dead ticking from non-Living entities
This commit is contained in:
@ -393,10 +393,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
/** @var bool */
|
||||
public $onGround;
|
||||
/** @var int */
|
||||
public $deadTicks = 0;
|
||||
/** @var int */
|
||||
protected $maxDeadTicks = 0;
|
||||
/** @var int */
|
||||
protected $age = 0;
|
||||
|
||||
/** @var float */
|
||||
@ -878,6 +874,16 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
$this->scheduleUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to tick entities while dead. Returns whether the entity should be flagged for despawn yet.
|
||||
*
|
||||
* @param int $tickDiff
|
||||
* @return bool
|
||||
*/
|
||||
protected function onDeathUpdate(int $tickDiff) : bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isAlive() : bool{
|
||||
return $this->health > 0;
|
||||
}
|
||||
@ -1267,13 +1273,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
|
||||
}
|
||||
|
||||
if(!$this->isAlive()){
|
||||
$this->deadTicks += $tickDiff;
|
||||
if($this->deadTicks >= $this->maxDeadTicks){
|
||||
$this->despawnFromAll();
|
||||
if(!$this->isPlayer){
|
||||
$this->flagForDespawn();
|
||||
}
|
||||
if($this->onDeathUpdate($tickDiff)){
|
||||
$this->flagForDespawn();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user