mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 17:06:16 +00:00
DaylightSensor: Avoid triggering useless block updates if calculated power is unchanged
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user