Level: switch order of addEntity() and removeEntity()

now it's consistent with addTile() and removeTile()
This commit is contained in:
Dylan K. Taylor 2018-05-19 13:14:11 +01:00
parent 75d13be38e
commit 6c3fc4af46

View File

@ -2508,6 +2508,25 @@ class Level implements ChunkManager, Metadatable{
$this->timings->syncChunkSendTimer->stopTiming(); $this->timings->syncChunkSendTimer->stopTiming();
} }
/**
* @param Entity $entity
*
* @throws LevelException
*/
public function addEntity(Entity $entity){
if($entity->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to Level");
}
if($entity->getLevel() !== $this){
throw new LevelException("Invalid Entity level");
}
if($entity instanceof Player){
$this->players[$entity->getId()] = $entity;
}
$this->entities[$entity->getId()] = $entity;
}
/** /**
* Removes the entity from the level index * Removes the entity from the level index
* *
@ -2529,25 +2548,6 @@ class Level implements ChunkManager, Metadatable{
unset($this->updateEntities[$entity->getId()]); unset($this->updateEntities[$entity->getId()]);
} }
/**
* @param Entity $entity
*
* @throws LevelException
*/
public function addEntity(Entity $entity){
if($entity->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to Level");
}
if($entity->getLevel() !== $this){
throw new LevelException("Invalid Entity level");
}
if($entity instanceof Player){
$this->players[$entity->getId()] = $entity;
}
$this->entities[$entity->getId()] = $entity;
}
/** /**
* @param Tile $tile * @param Tile $tile
* *