mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +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]);
|
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{
|
protected function spawnEntitiesOnChunk(int $chunkX, int $chunkZ) : void{
|
||||||
foreach($this->getWorld()->getChunk($chunkX, $chunkZ)->getEntities() as $entity){
|
foreach($this->getWorld()->getChunk($chunkX, $chunkZ)->getEntities() as $entity){
|
||||||
if($entity !== $this and !$entity->isFlaggedForDespawn()){
|
if($entity !== $this and !$entity->isFlaggedForDespawn()){
|
||||||
@ -738,12 +747,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
}elseif($this->spawnChunkLoadCount++ === $this->spawnThreshold){
|
}elseif($this->spawnChunkLoadCount++ === $this->spawnThreshold){
|
||||||
$this->spawnChunkLoadCount = -1;
|
$this->spawnChunkLoadCount = -1;
|
||||||
|
|
||||||
foreach($this->usedChunks as $chunkHash => $status){
|
$this->spawnEntitiesOnAllChunks();
|
||||||
if($status->equals(UsedChunkStatus::SENT())){
|
|
||||||
World::getXZ($chunkHash, $_x, $_z);
|
|
||||||
$this->spawnEntitiesOnChunk($_x, $_z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getNetworkSession()->notifyTerrainReady();
|
$this->getNetworkSession()->notifyTerrainReady();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user