World: use Facing::OFFSET in getHighestAdjacentLight()

This commit is contained in:
Dylan K. Taylor 2023-08-03 16:51:09 +01:00
parent 6ac45526f9
commit 1cf508abdb
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1727,14 +1727,10 @@ class World implements ChunkManager{
*/ */
private function getHighestAdjacentLight(int $x, int $y, int $z, \Closure $lightGetter) : int{ private function getHighestAdjacentLight(int $x, int $y, int $z, \Closure $lightGetter) : int{
$max = 0; $max = 0;
foreach([ foreach(Facing::OFFSET as [$offsetX, $offsetY, $offsetZ]){
[$x + 1, $y, $z], $x1 = $x + $offsetX;
[$x - 1, $y, $z], $y1 = $y + $offsetY;
[$x, $y + 1, $z], $z1 = $z + $offsetZ;
[$x, $y - 1, $z],
[$x, $y, $z + 1],
[$x, $y, $z - 1]
] as [$x1, $y1, $z1]){
if( if(
!$this->isInWorld($x1, $y1, $z1) || !$this->isInWorld($x1, $y1, $z1) ||
($chunk = $this->getChunk($x1 >> Chunk::COORD_BIT_SIZE, $z1 >> Chunk::COORD_BIT_SIZE)) === null || ($chunk = $this->getChunk($x1 >> Chunk::COORD_BIT_SIZE, $z1 >> Chunk::COORD_BIT_SIZE)) === null ||