22declare(strict_types=1);
26use pocketmine\block\utils\HorizontalFacingTrait;
27use pocketmine\block\utils\SupportType;
28use pocketmine\block\utils\WoodTypeTrait;
40 use HorizontalFacingTrait;
42 protected bool $open =
false;
43 protected bool $inWall =
false;
46 $w->horizontalFacing($this->facing);
47 $w->bool($this->open);
48 $w->bool($this->inWall);
51 public function isOpen() : bool{ return $this->open; }
54 public function setOpen(
bool $open) : self{
59 public function isInWall() : bool{ return $this->inWall; }
63 $this->inWall = $inWall;
75 return SupportType::NONE;
78 private function checkInWall() : bool{
80 $this->getSide(
Facing::rotateY($this->facing, false)) instanceof
Wall ||
81 $this->getSide(
Facing::rotateY($this->facing, true)) instanceof
Wall
87 $this->facing = $player->getHorizontalFacing();
90 $this->inWall = $this->checkInWall();
92 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
96 $inWall = $this->checkInWall();
97 if($inWall !== $this->inWall){
98 $this->inWall = $inWall;
99 $this->position->getWorld()->setBlock($this->position, $this);
104 $this->open = !$this->open;
105 if($this->open && $player !==
null){
106 $playerFacing = $player->getHorizontalFacing();
107 if($playerFacing === Facing::opposite($this->facing)){
108 $this->facing = $playerFacing;
112 $world = $this->position->getWorld();
113 $world->setBlock($this->position, $this);
114 $world->addSound($this->position,
new DoorSound());
119 return $this->woodType->isFlammable() ? 300 : 0;
123 return $this->woodType->isFlammable() ? 5 : 0;
127 return $this->woodType->isFlammable() ? 20 : 0;
onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player=null, array &$returnedItems=[])
describeBlockOnlyState(RuntimeDataDescriber $w)
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
getSupportType(int $facing)
recalculateCollisionBoxes()