World: skip random block ticking on chunks that don't have any light

typically this is a state that only lasts for a tick or so, but it's a race condition that is regardless very commonly encountered.
If you were very unlucky, you might have noticed grass randomly dying when you were spawning or flying around, even though it was in full sky light.
This commit is contained in:
Dylan K. Taylor 2020-09-04 18:08:42 +01:00
parent a68b0b1f93
commit 2e45398072

View File

@ -894,6 +894,9 @@ class World implements ChunkManager{
$dz = mt_rand(-$randRange, $randRange);
$hash = World::chunkHash($dx + $chunkX, $dz + $chunkZ);
if(!isset($chunkTickList[$hash]) and isset($this->chunks[$hash])){
if(!$this->chunks[$hash]->isLightPopulated()){
continue;
}
//check adjacent chunks are loaded
for($cx = -1; $cx <= 1; ++$cx){
for($cz = -1; $cz <= 1; ++$cz){