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{
$max = 0;
foreach([
[$x + 1, $y, $z],
[$x - 1, $y, $z],
[$x, $y + 1, $z],
[$x, $y - 1, $z],
[$x, $y, $z + 1],
[$x, $y, $z - 1]
] as [$x1, $y1, $z1]){
foreach(Facing::OFFSET as [$offsetX, $offsetY, $offsetZ]){
$x1 = $x + $offsetX;
$y1 = $y + $offsetY;
$z1 = $z + $offsetZ;
if(
!$this->isInWorld($x1, $y1, $z1) ||
($chunk = $this->getChunk($x1 >> Chunk::COORD_BIT_SIZE, $z1 >> Chunk::COORD_BIT_SIZE)) === null ||