Eliminate repeated calls to Position->getWorld()

as well as improving readability, it also improves performance in some areas.
This commit is contained in:
Dylan K. Taylor
2022-07-20 20:44:05 +01:00
parent 24e72ec109
commit 2940547026
39 changed files with 185 additions and 134 deletions

View File

@ -96,12 +96,13 @@ class Sapling extends Flowable{
}
public function onRandomTick() : void{
if($this->position->getWorld()->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 && mt_rand(1, 7) === 1){
$world = $this->position->getWorld();
if($world->getFullLightAt($this->position->getFloorX(), $this->position->getFloorY(), $this->position->getFloorZ()) >= 8 && mt_rand(1, 7) === 1){
if($this->ready){
$this->grow(null);
}else{
$this->ready = true;
$this->position->getWorld()->setBlock($this->position, $this);
$world->setBlock($this->position, $this);
}
}
}