DaylightSensor: Avoid triggering useless block updates if calculated power is unchanged

This commit is contained in:
Dylan K. Taylor 2019-08-10 17:49:31 +01:00
parent 774e6fe8a3
commit 4c694c57f4

View File

@ -95,8 +95,11 @@ class DaylightSensor extends Transparent{
}
public function onScheduledUpdate() : void{
$this->power = $this->recalculatePower();
$this->pos->getWorld()->setBlock($this->pos, $this);
$newPower = $this->recalculatePower();
if($this->power !== $newPower){
$this->power = $newPower;
$this->pos->getWorld()->setBlock($this->pos, $this);
}
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 20);
}