World: do not access chunks for light if they aren't yet light-populated

This commit is contained in:
Dylan K. Taylor 2021-04-15 21:21:34 +01:00
parent ab9615fb9c
commit e6ecacbb2b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1921,7 +1921,7 @@ class World implements ChunkManager{
if(!$this->isInWorld($x, $y, $z)){
return $y >= self::Y_MAX ? 15 : 0;
}
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null && $chunk->isLightPopulated() === true){
return $chunk->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
}
return 0; //TODO: this should probably throw instead (light not calculated yet)
@ -1936,7 +1936,7 @@ class World implements ChunkManager{
if(!$this->isInWorld($x, $y, $z)){
return 0;
}
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null){
if(($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null && $chunk->isLightPopulated() === true){
return $chunk->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
}
return 0; //TODO: this should probably throw instead (light not calculated yet)