35 use StaticSupportTrait;
41 protected array $connections = [];
45 foreach(Facing::ALL as $facing){
46 if(!isset($this->connections[$facing])){
47 $bb->trim($facing, 2 / 16);
55 parent::readStateFromWorld();
57 $this->collisionBoxes =
null;
59 foreach(Facing::ALL as $facing){
60 $block = $this->getSide($facing);
61 if(match($block->getTypeId()){
62 BlockTypeIds::END_STONE, BlockTypeIds::CHORUS_FLOWER, $this->getTypeId() => true,
65 $this->connections[$facing] =
true;
67 unset($this->connections[$facing]);
74 private function canBeSupportedBy(Block $block) : bool{
75 return $block->hasSameTypeId($this) || $block->getTypeId() === BlockTypeIds::END_STONE;
78 private function canBeSupportedAt(Block $block) : bool{
79 $position = $block->position;
80 $world = $position->getWorld();
82 $down = $world->getBlock($position->down());
83 $verticalAir = $down->getTypeId() === BlockTypeIds::AIR || $world->getBlock($position->up())->getTypeId() === BlockTypeIds::AIR;
85 foreach($position->sidesAroundAxis(Axis::Y) as $sidePosition){
86 $block = $world->getBlock($sidePosition);
88 if($block->getTypeId() === BlockTypeIds::CHORUS_PLANT){
93 if($this->canBeSupportedBy($block->getSide(Facing::DOWN))){
99 return $this->canBeSupportedBy($down);
103 if(mt_rand(0, 1) === 1){
104 return [VanillaItems::CHORUS_FRUIT()];