position->getWorld(); if($this->age < self::MAX_AGE){ $block = clone $this; ++$block->age; $ev = new BlockGrowEvent($this, $block); $ev->call(); if(!$ev->isCancelled()){ $world->setBlock($this->position, $ev->getNewState()); } }else{ $grow = $this->getPlant(); foreach(Facing::HORIZONTAL as $side){ if($this->getSide($side)->isSameType($grow)){ return; } } $side = $this->getSide(Facing::HORIZONTAL[array_rand(Facing::HORIZONTAL)]); $d = $side->getSide(Facing::DOWN); if($side->getId() === BlockLegacyIds::AIR && ($d->getId() === BlockLegacyIds::FARMLAND || $d->getId() === BlockLegacyIds::GRASS || $d->getId() === BlockLegacyIds::DIRT)){ $ev = new BlockGrowEvent($side, $grow); $ev->call(); if(!$ev->isCancelled()){ $world->setBlock($side->position, $ev->getNewState()); } } } } } public function getDropsForCompatibleTool(Item $item) : array{ return [ $this->asItem()->setCount(mt_rand(0, 2)) ]; } }