22declare(strict_types=1);
27use pocketmine\block\utils\HorizontalFacingTrait;
29use pocketmine\block\utils\PoweredByRedstoneTrait;
30use pocketmine\block\utils\StaticSupportTrait;
31use pocketmine\block\utils\SupportType;
41 use HorizontalFacingTrait;
42 use PoweredByRedstoneTrait;
43 use StaticSupportTrait;
45 public const MIN_DELAY = 1;
46 public const MAX_DELAY = 4;
48 protected int $delay = self::MIN_DELAY;
51 $w->horizontalFacing($this->facing);
52 $w->
boundedIntAuto(self::MIN_DELAY, self::MAX_DELAY, $this->delay);
53 $w->bool($this->powered);
56 public function getDelay() : int{ return $this->delay; }
60 if($delay < self::MIN_DELAY || $delay > self::MAX_DELAY){
61 throw new \InvalidArgumentException(
"Delay must be in range " . self::MIN_DELAY .
" ... " . self::MAX_DELAY);
63 $this->delay = $delay;
73 $this->facing = Facing::opposite($player->getHorizontalFacing());
76 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
80 if(++$this->delay > self::MAX_DELAY){
81 $this->delay = self::MIN_DELAY;
83 $this->position->getWorld()->setBlock($this->position, $this);
87 private function canBeSupportedAt(Block $block) : bool{
88 return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
recalculateCollisionBoxes()
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
describeBlockOnlyState(RuntimeDataDescriber $w)
boundedIntAuto(int $min, int $max, int &$value)