meta = $meta; } public function getName() : string{ return "Mycelium"; } public function getToolType() : int{ return BlockToolType::TYPE_SHOVEL; } public function getHardness() : float{ return 0.6; } public function getDropsForCompatibleTool(Item $item) : array{ return [ ItemFactory::get(Item::DIRT) ]; } public function ticksRandomly() : bool{ return true; } public function onRandomTick() : void{ //TODO: light levels $x = mt_rand($this->x - 1, $this->x + 1); $y = mt_rand($this->y - 2, $this->y + 2); $z = mt_rand($this->z - 1, $this->z + 1); $block = $this->getLevel()->getBlockAt($x, $y, $z); if($block->getId() === Block::DIRT){ if($block->getSide(Vector3::SIDE_UP) instanceof Transparent){ Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, BlockFactory::get(Block::MYCELIUM))); if(!$ev->isCancelled()){ $this->getLevel()->setBlock($block, $ev->getNewState()); } } } } }