22declare(strict_types=1);
26use pocketmine\block\utils\AnyFacingTrait;
39 protected bool $pressed =
false;
42 $w->facing($this->facing);
43 $w->bool($this->pressed);
46 public function isPressed() : bool{ return $this->pressed; }
50 $this->pressed = $pressed;
55 if($this->canBeSupportedAt($blockReplace, $face)){
56 $this->facing = $face;
57 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
62 abstract protected function getActivationTime() : int;
66 $this->pressed =
true;
67 $world = $this->position->getWorld();
68 $world->setBlock($this->position, $this);
69 $world->scheduleDelayedBlockUpdate($this->position, $this->getActivationTime());
78 $this->pressed =
false;
79 $world = $this->position->getWorld();
80 $world->setBlock($this->position, $this);
86 if(!$this->canBeSupportedAt($this, $this->facing)){
87 $this->position->getWorld()->useBreakOn($this->position);
91 private function canBeSupportedAt(Block $block,
int $face) : bool{
92 return $block->getAdjacentSupportType(Facing::opposite($face))->hasCenterSupport();