getAllSides() as $facing => $block){ $id = $block->getTypeId(); if($id !== BlockTypeIds::END_STONE && $id !== BlockTypeIds::CHORUS_FLOWER && !$block->hasSameTypeId($this)){ $bb->trim($facing, 2 / 16); } } return [$bb]; } private function canBeSupportedBy(Block $block) : bool{ return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE; } private function canStay(Position $position) : bool{ $world = $position->getWorld(); $down = $world->getBlock($position->down()); $verticalAir = $down->getTypeId() === BlockTypeIds::AIR || $world->getBlock($position->up())->getTypeId() === BlockTypeIds::AIR; foreach($position->sidesAroundAxis(Axis::Y) as $sidePosition){ $block = $world->getBlock($sidePosition); if($block->getTypeId() === BlockTypeIds::CHORUS_PLANT){ if(!$verticalAir){ return false; } if($this->canBeSupportedBy($block->getSide(Facing::DOWN))){ return true; } } } if($this->canBeSupportedBy($down)){ return true; } return false; } public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if(!$this->canStay($blockReplace->getPosition())){ return false; } return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } public function onNearbyBlockChange() : void{ if(!$this->canStay($this->position)){ $this->position->getWorld()->useBreakOn($this->position); } } public function getDropsForCompatibleTool(Item $item) : array{ if(mt_rand(0, 1) === 1){ return [VanillaItems::CHORUS_FRUIT()]; } return []; } }