mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
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:
parent
b331f8e1c9
commit
c83c0eb935
@ -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();
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user