pocketmine\block\RedstoneSource::deactivate PHP Méthode

deactivate() public méthode

public deactivate ( array $ignore = [] )
$ignore array
    public function deactivate(array $ignore = [])
    {
        if ($this->canCalc()) {
            $this->activated = false;
            /** @var Door $block */
            $sides = [Vector3::SIDE_EAST, Vector3::SIDE_WEST, Vector3::SIDE_SOUTH, Vector3::SIDE_NORTH];
            foreach ($sides as $side) {
                if (!in_array($side, $ignore)) {
                    $block = $this->getSide($side);
                    $this->deactivateBlock($block);
                }
            }
            if (!in_array(Vector3::SIDE_DOWN, $ignore)) {
                $block = $this->getSide(Vector3::SIDE_DOWN);
                if (!$this->checkPower($block)) {
                    /** @var $block ActiveRedstoneLamp */
                    if ($block->getId() == Block::ACTIVE_REDSTONE_LAMP) {
                        $block->turnOff();
                    }
                }
                $block = $this->getSide(Vector3::SIDE_DOWN, 2);
                $this->deactivateBlock($block);
            }
        }
    }

Usage Example

Exemple #1
0
 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])]);
 }
All Usage Examples Of pocketmine\block\RedstoneSource::deactivate