World: don't try to load chunks to read light levels

sync chunk load is useless here because lighting isn't immediately calculated anyway and it isn't available directly from the chunk when loaded.
This commit is contained in:
Dylan K. Taylor 2020-10-31 20:38:15 +00:00
parent 68f5eada32
commit f0d62cf4ce
2 changed files with 8 additions and 7 deletions

View File

@ -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{

View File

@ -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