pocketmine\block\RedstoneSource::activate PHP Method

activate() public method

public activate ( array $ignore = [] )
$ignore array
    public function activate(array $ignore = [])
    {
        if ($this->canCalc()) {
            $this->activated = true;
            /** @var Door $block */
            $sides = [Vector3::SIDE_EAST, Vector3::SIDE_WEST, Vector3::SIDE_SOUTH, Vector3::SIDE_NORTH, Vector3::SIDE_DOWN];
            foreach ($sides as $side) {
                if (!in_array($side, $ignore)) {
                    $block = $this->getSide($side);
                    $this->activateBlock($block);
                }
            }
        }
    }

Usage Example

示例#1
0
 public function activate(array $ignore = [])
 {
     parent::activate($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 ($block instanceof Door or $block instanceof Trapdoor) {
             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);
         }
     }
     $this->checkTorchOn($this->getSide($faces[$side]), [$this->getOppositeSide($faces[$side])]);
 }
All Usage Examples Of pocketmine\block\RedstoneSource::activate