pocketmine\block\WoodenButton::onUpdate PHP Method

onUpdate() public method

public onUpdate ( $type )
    public function onUpdate($type)
    {
        if ($type == Level::BLOCK_UPDATE_SCHEDULED) {
            if ($this->isActivated()) {
                $this->meta ^= 0x8;
                $this->getLevel()->setBlock($this, $this, true, false);
                $this->getLevel()->addSound(new ButtonClickSound($this));
                $this->deactivate();
            }
            return Level::BLOCK_UPDATE_SCHEDULED;
        }
        if ($type === Level::BLOCK_UPDATE_NORMAL) {
            $side = $this->getDamage();
            if ($this->isActivated()) {
                $side ^= 0x8;
            }
            $faces = [0 => 1, 1 => 0, 2 => 3, 3 => 2, 4 => 5, 5 => 4];
            if ($this->getSide($faces[$side]) instanceof Transparent) {
                $this->getLevel()->useBreakOn($this);
                return Level::BLOCK_UPDATE_NORMAL;
            }
        }
        return false;
    }