pocketmine\block\Sugarcane::onUpdate PHP Метод

onUpdate() публичный Метод

public onUpdate ( $type )
    public function onUpdate($type)
    {
        if ($type === Level::BLOCK_UPDATE_NORMAL) {
            $down = $this->getSide(0);
            if ($down->isTransparent() === true and $down->getId() !== self::SUGARCANE_BLOCK) {
                $this->getLevel()->useBreakOn($this);
                return Level::BLOCK_UPDATE_NORMAL;
            }
        } elseif ($type === Level::BLOCK_UPDATE_RANDOM) {
            if ($this->getSide(0)->getId() !== self::SUGARCANE_BLOCK) {
                if ($this->meta === 0xf) {
                    for ($y = 1; $y < 3; ++$y) {
                        $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
                        if ($b->getId() === self::AIR) {
                            $this->getLevel()->setBlock($b, new Sugarcane(), true);
                            break;
                        }
                    }
                    $this->meta = 0;
                    $this->getLevel()->setBlock($this, $this, true);
                } else {
                    ++$this->meta;
                    $this->getLevel()->setBlock($this, $this, true);
                }
                return Level::BLOCK_UPDATE_RANDOM;
            }
        }
        return false;
    }