mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-11 14:02:05 +00:00
Clean up BlockLightUpdate::recalculateChunk
- Remove unnecessary null checks for blockLayer and liquidLayer (they are now non-nullable) - Deduplicate code by scanning both layers in a single loop - Simplify logic flow by checking palettes first before scanning blocks
This commit is contained in:
parent
7c651928ea
commit
e5a38f270c
@ -65,31 +65,18 @@ class BlockLightUpdate extends LightUpdate{
|
||||
foreach($chunk->getSubChunks() as $subChunkY => $subChunk){
|
||||
$subChunk->setBlockLightArray(LightArray::fill(0));
|
||||
|
||||
$foundLightEmitter = false;
|
||||
|
||||
// Check block layer for light emitters
|
||||
$blockLayer = $subChunk->getBlockLayer();
|
||||
if($blockLayer !== null){
|
||||
foreach($blockLayer->getPalette() as $state){
|
||||
$hasLightEmitter = false;
|
||||
foreach([$subChunk->getBlockLayer(), $subChunk->getLiquidLayer()] as $layer){
|
||||
foreach($layer->getPalette() as $state){
|
||||
if(($this->lightEmitters[$state] ?? 0) > 0){
|
||||
$lightSources += $this->scanForLightEmittingBlocks($subChunk, $chunkX << SubChunk::COORD_BIT_SIZE, $subChunkY << SubChunk::COORD_BIT_SIZE, $chunkZ << SubChunk::COORD_BIT_SIZE);
|
||||
$foundLightEmitter = true;
|
||||
break;
|
||||
$hasLightEmitter = true;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check liquid layer for light emitters if not found in block layer
|
||||
if(!$foundLightEmitter){
|
||||
$liquidLayer = $subChunk->getLiquidLayer();
|
||||
if($liquidLayer !== null){
|
||||
foreach($liquidLayer->getPalette() as $state){
|
||||
if(($this->lightEmitters[$state] ?? 0) > 0){
|
||||
if($hasLightEmitter){
|
||||
$lightSources += $this->scanForLightEmittingBlocks($subChunk, $chunkX << SubChunk::COORD_BIT_SIZE, $subChunkY << SubChunk::COORD_BIT_SIZE, $chunkZ << SubChunk::COORD_BIT_SIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user