*/ protected array $connections = []; protected function recalculateCollisionBoxes() : array{ $bb = AxisAlignedBB::one(); foreach(Facing::ALL as $facing){ if(!isset($this->connections[$facing->value])){ $bb = $bb->trimmedCopy($facing, 2 / 16); } } return [$bb]; } public function readStateFromWorld() : Block{ parent::readStateFromWorld(); $this->collisionBoxes = null; foreach(Facing::ALL as $facing){ $block = $this->getSide($facing); if(match($block->getTypeId()){ BlockTypeIds::END_STONE, BlockTypeIds::CHORUS_FLOWER, $this->getTypeId() => true, default => false }){ $this->connections[$facing->value] = true; }else{ unset($this->connections[$facing->value]); } } return $this; } private function canBeSupportedBy(Block $block) : bool{ return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE; } private function canBeSupportedAt(Block $block) : bool{ $position = $block->position; $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; } } } return $this->canBeSupportedBy($down); } public function getDropsForCompatibleTool(Item $item) : array{ if(mt_rand(0, 1) === 1){ return [VanillaItems::CHORUS_FRUIT()]; } return []; } }