22declare(strict_types=1);
26use pocketmine\block\utils\SupportType;
37 private int $lightLevel;
39 protected bool $hanging =
false;
42 $this->lightLevel = $lightLevel;
43 parent::__construct($idInfo, $name, $typeInfo);
47 $w->bool($this->hanging);
50 public function isHanging() : bool{ return $this->hanging; }
54 $this->hanging = $hanging;
59 return $this->lightLevel;
68 ->trim(
Facing::UP, $this->hanging ? 6 / 16 : 8 / 16)
69 ->trim(
Facing::DOWN, $this->hanging ? 2 / 16 : 0)
70 ->squash(
Axis::X, 5 / 16)
71 ->squash(
Axis::Z, 5 / 16)
76 return SupportType::NONE;
80 $downSupport = $this->canBeSupportedAt($blockReplace,
Facing::DOWN);
81 if(!$downSupport && !$this->canBeSupportedAt($blockReplace, Facing::UP)){
85 $this->hanging = $face === Facing::DOWN || !$downSupport;
86 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
91 if(!$this->canBeSupportedAt($this, $face)){
92 $this->position->getWorld()->useBreakOn($this->position);
96 private function canBeSupportedAt(Block $block,
int $face) : bool{
97 return $block->getAdjacentSupportType($face)->hasCenterSupport();
getSupportType(int $facing)
describeBlockOnlyState(RuntimeDataDescriber $w)
recalculateCollisionBoxes()
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
setHanging(bool $hanging)