World: do not include unloaded or unlit chunks in getHighestAdjacentBlock(Sky)Light()

This commit is contained in:
Dylan K. Taylor 2020-10-29 13:05:25 +00:00
parent 3c892182fd
commit b079772d32

View File

@ -1232,7 +1232,11 @@ class World implements ChunkManager{
[$x, $y, $z + 1], [$x, $y, $z + 1],
[$x, $y, $z - 1] [$x, $y, $z - 1]
] as [$x1, $y1, $z1]){ ] as [$x1, $y1, $z1]){
if(!$this->isInWorld($x1, $y1, $z1)){ if(
!$this->isInWorld($x1, $y1, $z1) ||
($chunk = $this->getChunk($x1 >> 4, $z1 >> 4)) === null ||
!$chunk->isLightPopulated()
){
continue; continue;
} }
$max = max($max, $this->getBlockSkyLightAt($x1, $y1, $z1)); $max = max($max, $this->getBlockSkyLightAt($x1, $y1, $z1));
@ -1253,7 +1257,11 @@ class World implements ChunkManager{
[$x, $y, $z + 1], [$x, $y, $z + 1],
[$x, $y, $z - 1] [$x, $y, $z - 1]
] as [$x1, $y1, $z1]){ ] as [$x1, $y1, $z1]){
if(!$this->isInWorld($x1, $y1, $z1)){ if(
!$this->isInWorld($x1, $y1, $z1) ||
($chunk = $this->getChunk($x1 >> 4, $z1 >> 4)) === null ||
!$chunk->isLightPopulated()
){
continue; continue;
} }
$max = max($max, $this->getBlockLightAt($x1, $y1, $z1)); $max = max($max, $this->getBlockLightAt($x1, $y1, $z1));