mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 01:51:51 +00:00
Level: switch order of addEntity() and removeEntity()
now it's consistent with addTile() and removeTile()
This commit is contained in:
parent
75d13be38e
commit
6c3fc4af46
@ -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
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user