Leaves: make more findLog() params optional

This commit is contained in:
Dylan K. Taylor 2018-09-13 16:49:22 +01:00
parent fee42e9f34
commit 3b772f54e9

View File

@ -68,7 +68,7 @@ class Leaves extends Transparent{
} }
protected function findLog(Block $pos, array $visited, int $distance, ?int $fromSide = null) : bool{ protected function findLog(Block $pos, array $visited = [], int $distance = 0, ?int $fromSide = null) : bool{
$index = $pos->x . "." . $pos->y . "." . $pos->z; $index = $pos->x . "." . $pos->y . "." . $pos->z;
if(isset($visited[$index])){ if(isset($visited[$index])){
return false; return false;
@ -111,11 +111,10 @@ class Leaves extends Transparent{
public function onRandomTick() : void{ public function onRandomTick() : void{
if(($this->meta & 0b00001100) === 0x08){ if(($this->meta & 0b00001100) === 0x08){
$this->meta &= 0x03; $this->meta &= 0x03;
$visited = [];
$this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this)); $this->getLevel()->getServer()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
if($ev->isCancelled() or $this->findLog($this, $visited, 0)){ if($ev->isCancelled() or $this->findLog($this)){
$this->getLevel()->setBlock($this, $this, false, false); $this->getLevel()->setBlock($this, $this, false, false);
}else{ }else{
$this->getLevel()->useBreakOn($this); $this->getLevel()->useBreakOn($this);