Entity: Attach to level & chunk after initEntity() call, not before

this avoids leaving garbage entities attached to chunks when exceptions are thrown during initEntity().
This commit is contained in:
Dylan K. Taylor 2018-06-09 16:59:22 +01:00
parent 47742d74c8
commit 85136b7b4a

View File

@ -553,10 +553,12 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->setGenericFlag(self::DATA_FLAG_AFFECTED_BY_GRAVITY, true);
$this->setGenericFlag(self::DATA_FLAG_HAS_COLLISION, true);
$this->chunk->addEntity($this);
$this->level->addEntity($this);
$this->initEntity();
$this->propertyManager->clearDirtyProperties(); //Prevents resending properties that were set during construction
$this->chunk->addEntity($this);
$this->level->addEntity($this);
$this->lastUpdate = $this->server->getTick();
$this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));