mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-11 16:29:40 +00:00
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:
parent
68f5eada32
commit
f0d62cf4ce
@ -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{
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user