Exemplo n.º 1
0
  private void progress() {
    if (!Tools.canBend(player, Abilities.OctopusForm)
        || (!player.isSneaking() && !sourceselected)
        || !Tools.hasAbility(player, Abilities.OctopusForm)) {
      remove();
      return;
    }

    if (!sourceblock.getWorld().equals(player.getWorld())) {
      remove();
      return;
    }

    if (sourceblock.getLocation().distance(player.getLocation()) > range && sourceselected) {
      remove();
      return;
    }

    if (System.currentTimeMillis() > time + interval) {
      time = System.currentTimeMillis();

      Location location = player.getLocation();

      if (sourceselected) {
        Tools.playFocusWaterEffect(sourceblock);
      } else if (settingup) {
        if (sourceblock.getY() < location.getBlockY()) {
          source.revertBlock();
          Block newblock = sourceblock.getRelative(BlockFace.UP);
          sourcelocation = newblock.getLocation();
          if (!Tools.isSolid(newblock)) {
            source = new TempBlock(newblock, Material.WATER, full);
            sourceblock = newblock;
          } else {
            remove();
          }
        } else if (sourceblock.getY() > location.getBlockY()) {
          source.revertBlock();
          Block newblock = sourceblock.getRelative(BlockFace.DOWN);
          sourcelocation = newblock.getLocation();
          if (!Tools.isSolid(newblock)) {
            source = new TempBlock(newblock, Material.WATER, full);
            sourceblock = newblock;
          } else {
            remove();
          }
        } else if (sourcelocation.distance(location) > radius) {
          Vector vector =
              Tools.getDirection(sourcelocation, location.getBlock().getLocation()).normalize();
          sourcelocation.add(vector);
          Block newblock = sourcelocation.getBlock();
          if (!newblock.equals(sourceblock)) {
            source.revertBlock();
            if (!Tools.isSolid(newblock)) {
              source = new TempBlock(newblock, Material.WATER, full);
              sourceblock = newblock;
            }
          }
        } else {
          incrementStep();
          source.revertBlock();
          Vector vector = new Vector(1, 0, 0);
          startangle = vector.angle(Tools.getDirection(sourceblock.getLocation(), location));
          angle = startangle;
        }
      } else if (forming) {

        if (angle - startangle >= 360) {
          y += 1;
        } else {
          angle += 20;
        }
        formOctopus();
        if (y == 2) {
          incrementStep();
        }
      } else if (formed) {
        animstep += 1;
        if (animstep > 8) animstep = 1;
        formOctopus();
      } else {
        remove();
      }
    }
  }