22declare(strict_types=1);
26use pocketmine\block\utils\SupportType;
34 protected array $connections = [];
36 public function getThickness() :
float{
43 $this->collisionBoxes =
null;
45 foreach(Facing::HORIZONTAL as $facing){
46 $block = $this->
getSide($facing);
48 $this->connections[$facing] =
true;
50 unset($this->connections[$facing]);
61 $inset = 0.5 - $this->getThickness() / 2;
66 $connectWest = isset($this->connections[Facing::WEST]);
67 $connectEast = isset($this->connections[Facing::EAST]);
69 if($connectWest || $connectEast){
72 ->squash(Axis::Z, $inset)
73 ->extend(Facing::UP, 0.5)
74 ->trim(Facing::WEST, $connectWest ? 0 : $inset)
75 ->trim(Facing::EAST, $connectEast ? 0 : $inset);
78 $connectNorth = isset($this->connections[Facing::NORTH]);
79 $connectSouth = isset($this->connections[Facing::SOUTH]);
81 if($connectNorth || $connectSouth){
84 ->squash(Axis::X, $inset)
85 ->extend(Facing::UP, 0.5)
86 ->trim(Facing::NORTH, $connectNorth ? 0 : $inset)
87 ->trim(Facing::SOUTH, $connectSouth ? 0 : $inset);
90 if(count($bbs) === 0){
94 ->extend(Facing::UP, 0.5)
95 ->contract($inset, 0, $inset)
103 return
Facing::axis($facing) ===
Axis::Y ? SupportType::CENTER : SupportType::NONE;
getSide(int $side, int $step=1)
getSupportType(int $facing)
recalculateCollisionBoxes()
getSupportType(int $facing)
static opposite(int $direction)