mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
DaylightSensor: Avoid triggering useless block updates if calculated power is unchanged
This commit is contained in:
parent
774e6fe8a3
commit
4c694c57f4
@ -95,8 +95,11 @@ class DaylightSensor extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onScheduledUpdate() : void{
|
public function onScheduledUpdate() : void{
|
||||||
$this->power = $this->recalculatePower();
|
$newPower = $this->recalculatePower();
|
||||||
|
if($this->power !== $newPower){
|
||||||
|
$this->power = $newPower;
|
||||||
$this->pos->getWorld()->setBlock($this->pos, $this);
|
$this->pos->getWorld()->setBlock($this->pos, $this);
|
||||||
|
}
|
||||||
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 20);
|
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user