22declare(strict_types=1);
26use pocketmine\block\utils\FacesOppositePlacingPlayerTrait;
29use pocketmine\block\utils\PoweredByRedstoneTrait;
30use pocketmine\block\utils\StaticSupportTrait;
31use pocketmine\block\utils\SupportType;
40 use FacesOppositePlacingPlayerTrait;
41 use PoweredByRedstoneTrait;
42 use StaticSupportTrait;
44 public const MIN_DELAY = 1;
45 public const MAX_DELAY = 4;
47 protected int $delay = self::MIN_DELAY;
50 $w->enum($this->facing);
51 $w->
boundedIntAuto(self::MIN_DELAY, self::MAX_DELAY, $this->delay);
52 $w->bool($this->powered);
55 public function getDelay() : int{ return $this->delay; }
59 if($delay < self::MIN_DELAY || $delay > self::MAX_DELAY){
60 throw new \InvalidArgumentException(
"Delay must be in range " . self::MIN_DELAY .
" ... " . self::MAX_DELAY);
62 $this->delay = $delay;
71 if(++$this->delay > self::MAX_DELAY){
72 $this->delay = self::MIN_DELAY;
74 $this->position->getWorld()->setBlock($this->position, $this);
78 private function canBeSupportedAt(Block $block) : bool{
79 return $block->getAdjacentSupportType(Facing::DOWN) !== SupportType::NONE;
onInteract(Item $item, Facing $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
recalculateCollisionBoxes()
describeBlockOnlyState(RuntimeDataDescriber $w)
boundedIntAuto(int $min, int $max, int &$value)