Exemple #1
0
  public void manageAirVectors() {
    for (int i = 0; i < tasks.size(); i++) {
      if (((FireComboStream) tasks.get(i)).isCancelled()) {
        tasks.remove(i);
        i--;
      }
    }
    if (tasks.size() == 0) {
      remove();
      return;
    }
    for (int i = 0; i < tasks.size(); i++) {
      FireComboStream fstream = (FireComboStream) tasks.get(i);
      Location loc = fstream.getLocation();

      if (GeneralMethods.isRegionProtectedFromBuild(this, loc)) {
        fstream.remove();
        return;
      }

      if (!isTransparent(loc.getBlock())) {
        if (!isTransparent(loc.clone().add(0, 0.2, 0).getBlock())) {
          fstream.remove();
          return;
        }
      }
      if (i % 3 == 0) {
        for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, 2.5)) {
          if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) {
            remove();
            return;
          }
          if (!entity.equals(player) && !affectedEntities.contains(entity)) {
            affectedEntities.add(entity);
            if (knockback != 0) {
              Vector force = fstream.getDirection();
              entity.setVelocity(force.multiply(knockback));
            }
            if (damage != 0) {
              if (entity instanceof LivingEntity) {
                if (fstream.getAbility().equalsIgnoreCase("AirSweep")) {
                  DamageHandler.damageEntity(entity, damage, this);
                } else {
                  DamageHandler.damageEntity(entity, damage, this);
                }
              }
            }
          }
        }

        if (GeneralMethods.blockAbilities(player, FireCombo.getBlockableAbilities(), loc, 1)) {
          fstream.remove();
        } else AirAbility.removeAirSpouts(loc, player);
        WaterAbility.removeWaterSpouts(loc, player);
        EarthAbility.removeSandSpouts(loc, player);
      }
    }
  }
Exemple #2
0
  private void affectPeople(Location location, Vector direction) {
    WaterAbility.removeWaterSpouts(location, player);
    removeAirSpouts(location, player);
    final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, radius);
    final Vector fDirection = direction;

    for (int i = 0; i < entities.size(); i++) {
      final Entity entity = entities.get(i);
      new BukkitRunnable() {
        public void run() {
          if (GeneralMethods.isRegionProtectedFromBuild(AirSwipe.this, entity.getLocation())) {
            return;
          }
          if (entity.getEntityId() != player.getEntityId() && entity instanceof LivingEntity) {
            if (entity instanceof Player) {
              if (Commands.invincible.contains(((Player) entity).getName())) {
                return;
              }
            }
            if (entities.size() < MAX_AFFECTABLE_ENTITIES) {
              if (bPlayer.isAvatarState()) {
                GeneralMethods.setVelocity(
                    entity, fDirection.multiply(AvatarState.getValue(pushFactor)));
              } else {
                GeneralMethods.setVelocity(entity, fDirection.multiply(pushFactor));
              }
            }
            if (entity instanceof LivingEntity && !affectedEntities.contains(entity)) {
              if (damage != 0) {
                GeneralMethods.damageEntity(ability, entity, damage);
              }
              affectedEntities.add(entity);
            }
            if (entity instanceof Player) {
              new Flight((Player) entity, player);
            }
            breakBreathbendingHold(entity);
            if (elements.containsKey(fDirection)) {
              elements.remove(fDirection);
            }
          } else if (entity.getEntityId() != player.getEntityId()
              && !(entity instanceof LivingEntity)) {
            if (bPlayer.isAvatarState()) {
              GeneralMethods.setVelocity(
                  entity, fDirection.multiply(AvatarState.getValue(pushFactor)));
            } else {
              GeneralMethods.setVelocity(entity, fDirection.multiply(pushFactor));
            }
          }
        }
      }.runTaskLater(ProjectKorra.plugin, i / MAX_AFFECTABLE_ENTITIES);
    }
  }
  @Override
  public void progress() {
    if (!bPlayer.canBendIgnoreBindsCooldowns(this)) {
      remove();
      return;
    }

    getFloor();
    if (floorblock == null) {
      remove();
      return;
    }

    Vector velocity = player.getEyeLocation().getDirection().clone();
    velocity.setY(0);
    velocity = velocity.clone().normalize().multiply(speed);

    if (System.currentTimeMillis() > startTime + interval) {
      if (player.getVelocity().length() < speed * .5) {
        remove();
        return;
      }
      spinScooter();
    }

    double distance = player.getLocation().getY() - (double) floorblock.getY();
    double dx = Math.abs(distance - 2.4);
    if (distance > 2.75) {
      velocity.setY(-.25 * dx * dx);
    } else if (distance < 2) {
      velocity.setY(.25 * dx * dx);
    } else {
      velocity.setY(0);
    }

    Location loc = player.getLocation();
    if (!WaterAbility.isWater(player.getLocation().add(0, 2, 0).getBlock())) {
      loc.setY((double) floorblock.getY() + 1.5);
    } else {
      return;
    }

    player.setSprinting(false);
    player.removePotionEffect(PotionEffectType.SPEED);
    player.setVelocity(velocity);
    if (random.nextInt(4) == 0) {
      playAirbendingSound(player.getLocation());
    }
  }
Exemple #4
0
  @SuppressWarnings("deprecation")
  private void advanceSwipe() {
    affectedEntities.clear();
    for (Vector direction : elements.keySet()) {
      Location location = elements.get(direction);
      if (direction != null && location != null) {
        location = location.clone().add(direction.clone().multiply(speed));
        elements.replace(direction, location);

        if (location.distanceSquared(origin) > range * range
            || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
          elements.remove(direction);
        } else {
          removeAirSpouts(location, player);
          WaterAbility.removeWaterSpouts(location, player);

          if (EarthBlast.annihilateBlasts(location, radius, player)
              || WaterManipulation.annihilateBlasts(location, radius, player)
              || FireBlast.annihilateBlasts(location, radius, player)
              || Combustion.removeAroundPoint(location, radius)) {
            elements.remove(direction);
            damage = 0;
            remove();
            continue;
          }

          Block block = location.getBlock();
          for (Block testblock : GeneralMethods.getBlocksAroundPoint(location, radius)) {
            if (testblock.getType() == Material.FIRE) {
              testblock.setType(Material.AIR);
            }
            if (isBlockBreakable(testblock)) {
              GeneralMethods.breakBlock(testblock);
            }
          }

          if (block.getType() != Material.AIR) {
            if (isBlockBreakable(block)) {
              GeneralMethods.breakBlock(block);
            } else {
              elements.remove(direction);
            }
            if (isLava(block)) {
              if (block.getData() == 0x0) {
                block.setType(Material.OBSIDIAN);
              } else {
                block.setType(Material.COBBLESTONE);
              }
            }
          } else {
            playAirbendingParticles(location, particles, 0.2F, 0.2F, 0);
            if (random.nextInt(4) == 0) {
              playAirbendingSound(location);
            }
            affectPeople(location, direction);
          }
        }
      }
    }
    if (elements.isEmpty()) {
      remove();
    }
  }