diff --git a/src/world/World.php b/src/world/World.php index 74342b68d..01dab4449 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1839,7 +1839,10 @@ class World implements ChunkManager{ * @return int 0-15 */ public function getPotentialBlockSkyLightAt(int $x, int $y, int $z) : int{ - return $this->getOrLoadChunk($x >> 4, $z >> 4, true)->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); + if(($chunk = $this->getChunk($x >> 4, $z >> 4, false)) !== null){ + 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) } /** @@ -1848,7 +1851,10 @@ class World implements ChunkManager{ * @return int 0-15 */ public function getBlockLightAt(int $x, int $y, int $z) : int{ - return $this->getOrLoadChunk($x >> 4, $z >> 4, true)->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); + if(($chunk = $this->getChunk($x >> 4, $z >> 4, false)) !== null){ + 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) } public function getBiomeId(int $x, int $z) : int{ diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index e07ad407c..f98b36f58 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -555,11 +555,6 @@ parameters: count: 3 path: ../../../src/world/World.php - - - message: "#^Cannot call method getSubChunk\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#" - count: 2 - path: ../../../src/world/World.php - - message: "#^Cannot call method getBiomeId\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#" count: 1