Remove hacks for triggering adjacent light refill

This commit is contained in:
Dylan K. Taylor 2019-01-13 14:17:56 +00:00
parent 82788774b0
commit 1dca9074d5
2 changed files with 10 additions and 12 deletions

View File

@ -1440,8 +1440,8 @@ class Level implements ChunkManager, Metadatable{
for($i = $y; $i >= $newHeightMap; --$i){
$this->skyLightUpdate->setAndUpdateLight($x, $i, $z, 15);
}
}else{ //No heightmap change, block changed "underground"
$this->skyLightUpdate->setAndUpdateLight($x, $y, $z, max(0, $this->getHighestAdjacentBlockSkyLight($x, $y, $z) - BlockFactory::$lightFilter[($source->getId() << 4) | $source->getDamage()]));
}else{ //No heightmap change, block changed "underground" - trigger recalculation from surroundings
$this->skyLightUpdate->setAndUpdateLight($x, $y, $z, 0);
}
$this->timings->doBlockSkyLightUpdates->stopTiming();
@ -1471,12 +1471,10 @@ class Level implements ChunkManager, Metadatable{
$this->timings->doBlockLightUpdates->startTiming();
$block = $this->getBlockAt($x, $y, $z);
$newLevel = max($block->getLightLevel(), $this->getHighestAdjacentBlockLight($x, $y, $z) - BlockFactory::$lightFilter[($block->getId() << 4) | $block->getDamage()]);
if($this->blockLightUpdate === null){
$this->blockLightUpdate = new BlockLightUpdate($this);
}
$this->blockLightUpdate->setAndUpdateLight($x, $y, $z, $newLevel);
$this->blockLightUpdate->setAndUpdateLight($x, $y, $z, $block->getLightLevel());
$this->timings->doBlockLightUpdates->stopTiming();
}

View File

@ -72,17 +72,17 @@ abstract class LightUpdate{
if($oldLevel !== $newLevel){
$this->setLight($x, $y, $z, $newLevel);
if($oldLevel < $newLevel){ //light increased
}
if($newLevel > $oldLevel){ //light increased
$this->spreadVisited[$blockHash] = true;
$this->spreadQueue->enqueue([$x, $y, $z]);
}else{ //light removed
}elseif($newLevel < 15){ //light removed or stayed the same, force recheck nearby environment
$this->removalVisited[$blockHash] = true;
$this->removalQueue->enqueue([$x, $y, $z, $oldLevel]);
}
}
}
}
}
public function execute(){
$this->prepareNodes();