Removed final remaining usages of Chunk::getSubChunk()

this clears the way to get rid of EmptySubChunk.
This commit is contained in:
Dylan K. Taylor 2020-10-31 23:07:36 +00:00
parent f50be1ba63
commit 13d7b7ee1a

View File

@ -1834,8 +1834,11 @@ class World implements ChunkManager{
* @return int 0-15 * @return int 0-15
*/ */
public function getPotentialBlockSkyLightAt(int $x, int $y, int $z) : int{ public function getPotentialBlockSkyLightAt(int $x, int $y, int $z) : int{
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){
return $chunk->getSubChunk($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); return $chunk->getSubChunkChecked($y >> 4)->getBlockSkyLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
} }
return 0; //TODO: this should probably throw instead (light not calculated yet) return 0; //TODO: this should probably throw instead (light not calculated yet)
} }
@ -1846,8 +1849,11 @@ class World implements ChunkManager{
* @return int 0-15 * @return int 0-15
*/ */
public function getBlockLightAt(int $x, int $y, int $z) : int{ public function getBlockLightAt(int $x, int $y, int $z) : int{
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){
return $chunk->getSubChunk($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f); return $chunk->getSubChunkChecked($y >> 4)->getBlockLightArray()->get($x & 0x0f, $y & 0xf, $z & 0x0f);
} }
return 0; //TODO: this should probably throw instead (light not calculated yet) return 0; //TODO: this should probably throw instead (light not calculated yet)
} }