Entity: Move responsibility of checking for despawn to Level

this ensures that flagging for despawn will always work as intended, including when onUpdate() is overridden.
This commit is contained in:
Dylan K. Taylor 2018-06-07 12:31:21 +01:00
parent b331f8e1c9
commit c83c0eb935
2 changed files with 3 additions and 5 deletions

View File

@ -1333,11 +1333,6 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->lastUpdate = $currentTick;
if($this->needsDespawn){
$this->close();
return false;
}
if(!$this->isAlive()){
if($this->onDeathUpdate($tickDiff)){
$this->flagForDespawn();

View File

@ -745,6 +745,9 @@ class Level implements ChunkManager, Metadatable{
if($entity->isClosed() or !$entity->onUpdate($currentTick)){
unset($this->updateEntities[$id]);
}
if($entity->isFlaggedForDespawn()){
$entity->close();
}
}
Timings::$tickEntityTimer->stopTiming();
$this->timings->entityTick->stopTiming();