age; } public function readStateFromData(int $id, int $stateMeta) : void{ $this->age = BlockDataValidator::readBoundedInt("age", $stateMeta, 0, 3); } public function getStateBitmask() : int{ return 0b11; } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); if($down->getId() === Block::SOUL_SAND){ return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } return false; } public function onNearbyBlockChange() : void{ if($this->getSide(Facing::DOWN)->getId() !== Block::SOUL_SAND){ $this->getLevel()->useBreakOn($this); } } public function ticksRandomly() : bool{ return true; } public function onRandomTick() : void{ if($this->age < 3 and mt_rand(0, 10) === 0){ //Still growing $block = clone $this; $block->age++; $ev = new BlockGrowEvent($this, $block); $ev->call(); if(!$ev->isCancelled()){ $this->getLevel()->setBlock($this, $ev->getNewState()); } } } public function getDropsForCompatibleTool(Item $item) : array{ return [ $this->asItem()->setCount($this->age === 3 ? mt_rand(2, 4) : 1) ]; } }