mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Player: extract some entity spawning logic into a separate function
This commit is contained in:
parent
de49a361c0
commit
cdeedbad8b
@ -682,6 +682,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
unset($this->loadQueue[$index]);
|
||||
}
|
||||
|
||||
protected function spawnEntitiesOnAllChunks() : void{
|
||||
foreach($this->usedChunks as $chunkHash => $status){
|
||||
if($status->equals(UsedChunkStatus::SENT())){
|
||||
World::getXZ($chunkHash, $chunkX, $chunkZ);
|
||||
$this->spawnEntitiesOnChunk($chunkX, $chunkZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void{
|
||||
foreach($this->getWorld()->getChunk($chunkX, $chunkZ)->getEntities() as $entity){
|
||||
if($entity !== $this and !$entity->isFlaggedForDespawn()){
|
||||
@ -738,12 +747,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}elseif($this->spawnChunkLoadCount++ === $this->spawnThreshold){
|
||||
$this->spawnChunkLoadCount = -1;
|
||||
|
||||
foreach($this->usedChunks as $chunkHash => $status){
|
||||
if($status->equals(UsedChunkStatus::SENT())){
|
||||
World::getXZ($chunkHash, $_x, $_z);
|
||||
$this->spawnEntitiesOnChunk($_x, $_z);
|
||||
}
|
||||
}
|
||||
$this->spawnEntitiesOnAllChunks();
|
||||
|
||||
$this->getNetworkSession()->notifyTerrainReady();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user