facing */ protected array $connections = []; protected bool $up = false; public function readStateFromWorld() : void{ parent::readStateFromWorld(); foreach(Facing::HORIZONTAL as $facing){ $block = $this->getSide($facing); if($block instanceof static || $block instanceof FenceGate || $block instanceof Thin || ($block->isSolid() && !$block->isTransparent())){ $this->connections[$facing] = $facing; }else{ unset($this->connections[$facing]); } } $this->up = $this->getSide(Facing::UP)->getId() !== BlockLegacyIds::AIR; } protected function recalculateCollisionBoxes() : array{ //walls don't have any special collision boxes like fences do $north = isset($this->connections[Facing::NORTH]); $south = isset($this->connections[Facing::SOUTH]); $west = isset($this->connections[Facing::WEST]); $east = isset($this->connections[Facing::EAST]); $inset = 0.25; if( !$this->up && //if there is a block on top, it stays as a post ( ($north && $south && !$west && !$east) || (!$north && !$south && $west && $east) ) ){ //If connected to two sides on the same axis but not any others, AND there is not a block on top, there is no post and the wall is thinner $inset = 0.3125; } return [ AxisAlignedBB::one() ->extend(Facing::UP, 0.5) ->trim(Facing::NORTH, $north ? 0 : $inset) ->trim(Facing::SOUTH, $south ? 0 : $inset) ->trim(Facing::WEST, $west ? 0 : $inset) ->trim(Facing::EAST, $east ? 0 : $inset) ]; } public function getSupportType(int $facing) : SupportType{ return Facing::axis($facing) === Axis::Y ? SupportType::CENTER() : SupportType::NONE(); } }