22declare(strict_types=1);
26use pocketmine\block\utils\StaticSupportTrait;
39 use StaticSupportTrait;
41 private int $axis = Axis::X;
44 $w->horizontalAxis($this->axis);
47 public function getAxis() : int{ return $this->axis; }
50 public function setAxis(
int $axis) : self{
51 if($axis !==
Axis::X && $axis !==
Axis::Z){
52 throw new \InvalidArgumentException(
"Axis must be X or Z only");
60 $playerBlockPos = $player->getPosition()->floor();
61 $directionVector = $blockReplace->position->subtractVector($playerBlockPos)->normalize();
62 $angle = rad2deg(atan2($directionVector->getZ(), $directionVector->getX()));
64 if($angle <= 45 || 315 <= $angle || (135 <= $angle && $angle <= 225)){
67 $this->axis = Axis::Z;
71 $this->dead = !$this->isCoveredWithWater();
73 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
76 private function canBeSupportedAt(Block $block) : bool{
77 return $block->getAdjacentSupportType(Facing::DOWN)->hasCenterSupport();
81 return
VanillaItems::CORAL_FAN()->setCoralType($this->coralType)->setDead($this->dead);
describeBlockOnlyState(RuntimeDataDescriber $w)
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)