22declare(strict_types=1);
26use pocketmine\block\utils\HorizontalFacingTrait;
27use pocketmine\block\utils\PoweredByRedstoneTrait;
28use pocketmine\block\utils\StaticSupportTrait;
29use pocketmine\block\utils\SupportType;
39 use HorizontalFacingTrait;
40 use PoweredByRedstoneTrait;
41 use StaticSupportTrait;
43 public const MIN_DELAY = 1;
44 public const MAX_DELAY = 4;
46 protected int $delay = self::MIN_DELAY;
49 $w->horizontalFacing($this->facing);
50 $w->
boundedIntAuto(self::MIN_DELAY, self::MAX_DELAY, $this->delay);
51 $w->bool($this->powered);
54 public function getDelay() : int{ return $this->delay; }
58 if($delay < self::MIN_DELAY || $delay > self::MAX_DELAY){
59 throw new \InvalidArgumentException(
"Delay must be in range " . self::MIN_DELAY .
" ... " . self::MAX_DELAY);
61 $this->delay = $delay;
74 $this->facing = Facing::opposite($player->getHorizontalFacing());
77 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
81 if(++$this->delay > self::MAX_DELAY){
82 $this->delay = self::MIN_DELAY;
84 $this->position->getWorld()->setBlock($this->position, $this);
88 private function canBeSupportedAt(Block $block) : bool{
89 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)