mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
Improved single-threaded chunk generation efficiency
This commit is contained in:
parent
886ad8442c
commit
fde61b7d21
@ -1541,12 +1541,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
unset($this->chunkGenerationQueue["$x:$z"]);
|
||||
$this->setChunk($x, $z, $chunk);
|
||||
$chunk = $this->getChunk($x, $z);
|
||||
if($chunk instanceof FullChunk){
|
||||
if(!($oldChunk instanceof FullChunk) or ($oldChunk->isPopulated() === false and $chunk->isPopulated())){
|
||||
if($chunk instanceof FullChunk and (!($oldChunk instanceof FullChunk) or $oldChunk->isPopulated() === false) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($chunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setChunk($x, $z, FullChunk $chunk, $unload = true){
|
||||
$index = Level::chunkHash($x, $z);
|
||||
@ -1554,9 +1552,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
foreach($this->getUsingChunk($x, $z) as $player){
|
||||
$player->unloadChunk($x, $z);
|
||||
}
|
||||
unset($this->chunks[$index]);
|
||||
$this->provider->setChunk($x, $z, $chunk);
|
||||
$this->loadChunk($x, $z);
|
||||
$this->chunks[$index] = $chunk;
|
||||
}else{
|
||||
$this->provider->setChunk($x, $z, $chunk);
|
||||
$this->chunks[$index] = $chunk;
|
||||
|
@ -63,11 +63,9 @@ class GenerationLevelManager extends GenerationManager{
|
||||
$this->levels[$levelID]->populateChunk($chunkX, $chunkZ); //Request population directly
|
||||
if(isset($this->levels[$levelID])){
|
||||
foreach($this->levels[$levelID]->getChangedChunks() as $index => $chunk){
|
||||
if($chunk->isPopulated()){
|
||||
$this->sendChunk($levelID, $chunk);
|
||||
$this->levels[$levelID]->cleanChangedChunk($index);
|
||||
}
|
||||
}
|
||||
|
||||
$this->levels[$levelID]->doGarbageCollection();
|
||||
$this->levels[$levelID]->cleanChangedChunks();
|
||||
|
Loading…
x
Reference in New Issue
Block a user