22declare(strict_types=1);
26use pocketmine\block\utils\SupportType;
36 protected int $facing = Facing::UP;
39 $w->facingExcept($this->facing,
Facing::DOWN);
42 public function getFacing() : int{ return $this->facing; }
46 if($facing ===
Facing::DOWN){
47 throw new \InvalidArgumentException(
"Torch may not face DOWN");
49 $this->facing = $facing;
58 if(!$this->canBeSupportedAt($this,
Facing::opposite($this->facing))){
59 $this->position->getWorld()->useBreakOn($this->position);
64 if($face !==
Facing::DOWN && $this->canBeSupportedAt($blockReplace,
Facing::opposite($face))){
65 $this->facing = $face;
66 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
75 if($this->canBeSupportedAt($blockReplace, $side)){
76 $this->facing = Facing::opposite($side);
77 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
84 private function canBeSupportedAt(Block $block,
int $face) : bool{
85 return $face === Facing::DOWN ?
86 $block->getAdjacentSupportType($face)->hasCenterSupport() :
87 $block->getAdjacentSupportType($face) === SupportType::FULL;
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
describeBlockOnlyState(RuntimeDataDescriber $w)