public function deactivate(array $ignore = []) { parent::deactivate($ignore); $side = $this->meta; if ($this->isActivated()) { $side ^= 0x8; } $faces = [5 => 0, 6 => 0, 3 => 2, 1 => 4, 4 => 3, 2 => 5, 0 => 1, 7 => 1]; $block = $this->getSide($faces[$side])->getSide(Vector3::SIDE_UP); if (!$this->isRightPlace($this, $block)) { if (!$this->checkPower($block)) { if ($block instanceof Door or $block instanceof Trapdoor or $block instanceof FenceGate) { if ($block->isOpened()) { $block->onActivate(new Item(0)); } } /** @var ActiveRedstoneLamp $block */ if ($block->getId() == Block::ACTIVE_REDSTONE_LAMP) { $block->turnOff(); } } if ($block->getId() == Block::REDSTONE_WIRE) { /** @var RedstoneWire $wire */ $wire = $block; $wire->calcSignal(0, RedstoneWire::OFF); } } $this->checkTorchOff($this->getSide($faces[$side]), [$this->getOppositeSide($faces[$side])]); }
public function canCalcTurn() { if (!parent::canCalc()) { return false; } if ($this->getLevel()->getServer()->getTick() != $this->getLastUpdateTime()) { return true; } return $this->canScheduleUpdate() ? Level::BLOCK_UPDATE_SCHEDULED : false; }
public function canCalc() { if (!parent::canCalc()) { return false; } if ($this->getLevel()->getServer()->getTick() != $this->lastUpdateTime) { return true; } return false; }
public function activate(array $ignore = []) { parent::activate($ignore = []); $faces = [0 => 1, 1 => 0, 2 => 3, 3 => 2, 4 => 5, 5 => 4]; $side = $this->meta; if ($this->isActivated()) { $side ^= 0x8; } $block = $this->getSide($faces[$side])->getSide(Vector3::SIDE_UP); if (!$this->equals($block)) { $this->activateBlock($block); } if ($side != 1) { $block = $this->getSide($faces[$side], 2); $this->activateBlock($block); } $this->checkTorchOn($this->getSide($faces[$side]), [$this->getOppositeSide($faces[$side])]); }
public function activate(array $ignore = []) { parent::activate($ignore = []); $faces = [1 => 0, 2 => 3, 3 => 2, 4 => 5, 5 => 4]; $side = $this->meta; if ($this->isActivated()) { $side ^= 0x8; } $block = $this->getSide($faces[$side])->getSide(Vector3::SIDE_UP); if (!$this->isRightPlace($this, $block)) { if ($block instanceof Door or $block instanceof Trapdoor or $block instanceof FenceGate) { if (!$block->isOpened()) { $block->onActivate(new Item(0)); } } if ($block->getId() == Block::TNT) { $block->onActivate(new Item(Item::FLINT_AND_STEEL)); } /** @var ActiveRedstoneLamp $block */ if ($block->getId() == Block::INACTIVE_REDSTONE_LAMP or $block->getId() == Block::ACTIVE_REDSTONE_LAMP) { $block->turnOn(); } if ($block->getId() == Block::REDSTONE_WIRE) { /** @var RedstoneWire $wire */ $wire = $block; $wire->calcSignal($this->maxStrength, RedstoneWire::ON); } } if ($side != 1) { /** @var Door $block */ $block = $this->getSide($faces[$side], 2); if ($block instanceof Door or $block instanceof Trapdoor or $block instanceof FenceGate) { if (!$block->isOpened()) { $block->onActivate(new Item(0)); } } if ($block->getId() == Block::TNT) { $block->onActivate(new Item(Item::FLINT_AND_STEEL)); } /** @var ActiveRedstoneLamp $block */ if ($block->getId() == Block::INACTIVE_REDSTONE_LAMP or $block->getId() == Block::ACTIVE_REDSTONE_LAMP) { $block->turnOn(); } if ($block->getId() == Block::REDSTONE_WIRE) { /** @var RedstoneWire $wire */ $wire = $block; $wire->calcSignal(15, RedstoneWire::ON); } } $this->checkTorchOn($this->getSide($faces[$side]), [$this->getOppositeSide($faces[$side])]); }
public function deactivate(array $ignore = []) { parent::deactivate($ignore); $side = $this->meta; if ($this->isActivated()) { $side ^= 0x8; } $faces = [5 => 0, 6 => 0, 3 => 2, 1 => 4, 4 => 3, 2 => 5, 0 => 1, 7 => 1]; $block = $this->getSide($faces[$side])->getSide(Vector3::SIDE_UP); if (!$this->equals($block)) { $this->deactivateBlock($block); } $this->checkTorchOff($this->getSide($faces[$side]), [$this->getOppositeSide($faces[$side])]); }