isHead() === $head) || $block->getTypeId() === BlockTypeIds::CLAY || $block->hasTypeTag(BlockTypeTags::DIRT) || $block->hasTypeTag(BlockTypeTags::MUD); } public function onNearbyBlockChange() : void{ if( (!$this->isHead() && !$this->getSide(Facing::UP) instanceof BaseBigDripleaf) || !$this->canBeSupportedBy($this->getSide(Facing::DOWN), false) ){ $this->position->getWorld()->useBreakOn($this->position); } } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $block = $blockReplace->getSide(Facing::DOWN); if(!$this->canBeSupportedBy($block, true)){ return false; } if($player !== null){ $this->facing = Facing::opposite($player->getHorizontalFacing()); } if($block instanceof BaseBigDripleaf){ $this->facing = $block->facing; $tx->addBlock($block->position, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($this->facing)); } return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($item instanceof Fertilizer && $this->grow($player)){ $item->pop(); return true; } return false; } private function seekToHead() : ?BaseBigDripleaf{ if($this->isHead()){ return $this; } $step = 1; while(($next = $this->getSide(Facing::UP, $step)) instanceof BaseBigDripleaf){ if($next->isHead()){ return $next; } $step++; } return null; } private function grow(?Player $player) : bool{ $head = $this->seekToHead(); if($head === null){ return false; } $pos = $head->position; $up = $pos->up(); $world = $pos->getWorld(); if( !$world->isInWorld($up->getFloorX(), $up->getFloorY(), $up->getFloorZ()) || $world->getBlock($up)->getTypeId() !== BlockTypeIds::AIR ){ return false; } $tx = new BlockTransaction($world); $tx->addBlock($pos, VanillaBlocks::BIG_DRIPLEAF_STEM()->setFacing($head->facing)); $tx->addBlock($up, VanillaBlocks::BIG_DRIPLEAF_HEAD()->setFacing($head->facing)); $ev = new StructureGrowEvent($head, $tx, $player); $ev->call(); if(!$ev->isCancelled()){ return $tx->apply(); } return false; } public function getFlameEncouragement() : int{ return 15; } public function getFlammability() : int{ return 100; } public function getSupportType(int $facing) : SupportType{ return SupportType::NONE; } }