Avoid unnecessary Entity::getWorld() calls in loops

This commit is contained in:
Dylan K. Taylor
2023-11-17 13:58:41 +00:00
parent 0f620fad94
commit fbcf4649eb
3 changed files with 10 additions and 8 deletions

View File

@ -813,13 +813,13 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->usedChunks[$index] = UsedChunkStatus::REQUESTED_GENERATION;
$this->activeChunkGenerationRequests[$index] = true;
unset($this->loadQueue[$index]);
$this->getWorld()->registerChunkLoader($this->chunkLoader, $X, $Z, true);
$this->getWorld()->registerChunkListener($this, $X, $Z);
$world->registerChunkLoader($this->chunkLoader, $X, $Z, true);
$world->registerChunkListener($this, $X, $Z);
if(isset($this->tickingChunks[$index])){
$this->getWorld()->registerTickingChunk($this->chunkTicker, $X, $Z);
$world->registerTickingChunk($this->chunkTicker, $X, $Z);
}
$this->getWorld()->requestChunkPopulation($X, $Z, $this->chunkLoader)->onCompletion(
$world->requestChunkPopulation($X, $Z, $this->chunkLoader)->onCompletion(
function() use ($X, $Z, $index, $world) : void{
if(!$this->isConnected() || !isset($this->usedChunks[$index]) || $world !== $this->getWorld()){
return;