mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Level: Do not tick chunks which have unloaded adjacent chunks
Grass can cause issues here by requesting blocks randomly offset away from itself, which can cause silent chunk loading on chunk ticking. It also causes crashes if chunk autoloading is taken away, which is obviously undesired. It was also noticed that player chunkloaders cause chunks to start getting ticked as soon as they load their first chunk, which is before the entity is visible to everyone else on the server. This is probably undesired behaviour.
This commit is contained in:
parent
1983964f9e
commit
0c9946621c
@ -971,13 +971,20 @@ class Level implements ChunkManager, Metadatable{
|
||||
foreach($this->chunkTickList as $index => $loaders){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
|
||||
if(($chunk = $this->chunks[$index] ?? null) === null){
|
||||
unset($this->chunkTickList[$index]);
|
||||
continue;
|
||||
}elseif($loaders <= 0){
|
||||
for($cx = -1; $cx <= 1; ++$cx){
|
||||
for($cz = -1; $cz <= 1; ++$cz){
|
||||
if(!isset($this->chunks[Level::chunkHash($chunkX + $cx, $chunkZ + $cz)])){
|
||||
unset($this->chunkTickList[$index]);
|
||||
goto skip_to_next; //no "continue 3" thanks!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($loaders <= 0){
|
||||
unset($this->chunkTickList[$index]);
|
||||
}
|
||||
|
||||
$chunk = $this->chunks[$index];
|
||||
foreach($chunk->getEntities() as $entity){
|
||||
$entity->scheduleUpdate();
|
||||
}
|
||||
@ -1006,6 +1013,8 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skip_to_next: //dummy label to break out of nested loops
|
||||
}
|
||||
|
||||
if($this->clearChunksOnTick){
|
||||
|
Loading…
x
Reference in New Issue
Block a user