22declare(strict_types=1);
26use pocketmine\block\utils\SupportType;
27use pocketmine\block\utils\WallConnectionType;
42 protected array $connections = [];
43 protected bool $post =
false;
46 $w->wallConnections($this->connections);
47 $w->bool($this->post);
56 public function getConnection(
int $face) : ?WallConnectionType{
57 return $this->connections[$face] ?? null;
66 $this->connections = $connections;
71 public function setConnection(
int $face, ?WallConnectionType $type) : self{
73 throw new \InvalidArgumentException(
"Facing can only be north, east, south or west");
76 $this->connections[$face] = $type;
78 unset($this->connections[$face]);
83 public function isPost() : bool{ return $this->post; }
86 public function setPost(
bool $post) : self{
92 if($this->recalculateConnections()){
93 $this->position->getWorld()->setBlock($this->position, $this);
97 protected function recalculateConnections() : bool{
102 foreach(Facing::HORIZONTAL as $facing){
103 $block = $this->getSide($facing);
104 if($block instanceof
static || $block instanceof FenceGate || $block instanceof Thin || $block->getSupportType(Facing::opposite($facing)) === SupportType::FULL){
105 if(!isset($this->connections[$facing])){
106 $this->connections[$facing] = WallConnectionType::SHORT;
109 }elseif(isset($this->connections[$facing])){
110 unset($this->connections[$facing]);
115 $up = $this->getSide(Facing::UP)->getTypeId() !== BlockTypeIds::AIR;
116 if($up !== $this->post){
127 $north = isset($this->connections[
Facing::NORTH]);
128 $south = isset($this->connections[Facing::SOUTH]);
129 $west = isset($this->connections[Facing::WEST]);
130 $east = isset($this->connections[Facing::EAST]);
136 ($north && $south && !$west && !$east) ||
137 (!$north && !$south && $west && $east)
146 ->extend(Facing::UP, 0.5)
147 ->trim(Facing::NORTH, $north ? 0 : $inset)
148 ->trim(Facing::SOUTH, $south ? 0 : $inset)
149 ->trim(Facing::WEST, $west ? 0 : $inset)
150 ->trim(Facing::EAST, $east ? 0 : $inset)
155 return
Facing::axis($facing) ===
Axis::Y ? SupportType::CENTER : SupportType::NONE;
describeBlockOnlyState(RuntimeDataDescriber $w)
recalculateCollisionBoxes()
getSupportType(int $facing)
setConnections(array $connections)
setConnection(int $face, ?WallConnectionType $type)