diff --git a/src/world/World.php b/src/world/World.php index 54fe5ffed..b3e6e9beb 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -1215,19 +1215,6 @@ class World implements ChunkManager{ return $collides; } - public function getFullLight(Vector3 $pos) : int{ - return $this->getFullLightAt($pos->x, $pos->y, $pos->z); - } - - public function getFullLightAt(int $x, int $y, int $z) : int{ - $skyLight = $this->getRealBlockSkyLightAt($x, $y, $z); - if($skyLight < 15){ - return max($skyLight, $this->getBlockLightAt($x, $y, $z)); - }else{ - return $skyLight; - } - } - /** * Computes the percentage of a circle away from noon the sun is currently at. This can be multiplied by 2 * M_PI to * get an angle in radians, or by 360 to get an angle in degrees. @@ -1285,6 +1272,34 @@ class World implements ChunkManager{ return $this->skyLightReduction; } + public function getFullLight(Vector3 $pos) : int{ + return $this->getFullLightAt($pos->x, $pos->y, $pos->z); + } + + public function getFullLightAt(int $x, int $y, int $z) : int{ + $skyLight = $this->getRealBlockSkyLightAt($x, $y, $z); + if($skyLight < 15){ + return max($skyLight, $this->getBlockLightAt($x, $y, $z)); + }else{ + return $skyLight; + } + } + + /** + * Gets the raw block skylight level + * + * @return int 0-15 + */ + 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 && $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) + } + /** * Returns the sky light level at the specified coordinates, offset by the current time and weather. * @@ -1295,6 +1310,21 @@ class World implements ChunkManager{ return $light < 0 ? 0 : $light; } + /** + * Gets the raw block light level + * + * @return int 0-15 + */ + 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 && $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) + } + public function updateAllLight(int $x, int $y, int $z) : void{ if(($chunk = $this->getChunk($x >> 4, $z >> 4)) === null || $chunk->isLightPopulated() !== true){ $this->logger->debug("Skipped runtime light update of x=$x,y=$y,z=$z because the target area has not received base light calculation"); @@ -1937,36 +1967,6 @@ class World implements ChunkManager{ return ($chunk = $this->loadChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null; } - /** - * Gets the raw block skylight level - * - * @return int 0-15 - */ - 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 && $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) - } - - /** - * Gets the raw block light level - * - * @return int 0-15 - */ - 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 && $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) - } - public function getBiomeId(int $x, int $z) : int{ if(($chunk = $this->loadChunk($x >> 4, $z >> 4)) !== null){ return $chunk->getBiomeId($x & 0x0f, $z & 0x0f);