Player: fixed orderChunks performance issue on newly-generated maps

every time a chunk passed through Level->generateChunkCallback(), it fired onChunkChanged() for chunk listeners, which in turn caused players to rerun chunk orders even though the target chunk had not been sent yet anyway.
This commit is contained in:
Dylan K. Taylor 2020-11-05 16:17:39 +00:00
parent bfdcc12e81
commit 37ee3f2775

View File

@ -4122,7 +4122,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
}
public function onChunkChanged(Chunk $chunk){
if(isset($this->usedChunks[$hash = Level::chunkHash($chunk->getX(), $chunk->getZ())])){
$hasSent = $this->usedChunks[$hash = Level::chunkHash($chunk->getX(), $chunk->getZ())] ?? false;
if($hasSent){
$this->usedChunks[$hash] = false;
$this->nextChunkOrderRun = 0;
}