private static void block(Player player) {
    for (int id : instances.keySet()) {
      EarthBlast blast = instances.get(id);

      if (blast.player.equals(player)) {
        continue;
      }

      if (!blast.location.getWorld().equals(player.getWorld())) {
        continue;
      }

      if (!blast.progressing) {
        continue;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthBlast", blast.location)) {
        continue;
      }

      Location location = player.getEyeLocation();
      Vector vector = location.getDirection();
      Location mloc = blast.location;
      if (mloc.distance(location) <= RANGE
          && GeneralMethods.getDistanceFromLine(vector, location, blast.location) < deflectrange
          && mloc.distance(location.clone().add(vector))
              < mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
        blast.breakBlock();
      }
    }
  }
  private static void redirectTargettedBlasts(Player player, ArrayList<EarthBlast> ignore) {
    for (int id : instances.keySet()) {
      EarthBlast blast = instances.get(id);

      if (!blast.progressing || ignore.contains(blast)) {
        continue;
      }

      if (!blast.location.getWorld().equals(player.getWorld())) {
        continue;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "EarthBlast", blast.location)) {
        continue;
      }

      if (blast.player.equals(player)) {
        blast.redirect(player, getTargetLocation(player));
      }

      Location location = player.getEyeLocation();
      Vector vector = location.getDirection();
      Location mloc = blast.location;
      if (mloc.distance(location) <= RANGE
          && GeneralMethods.getDistanceFromLine(vector, location, blast.location) < deflectrange
          && mloc.distance(location.clone().add(vector))
              < mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
        blast.redirect(player, getTargetLocation(player));
      }
    }
  }
Ejemplo n.º 3
0
  public IceSpike(Player player) {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer.isOnCooldown("IceSpike")) return;
    try {
      this.player = player;

      double lowestdistance = range + 1;
      Entity closestentity = null;
      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) {
        if (GeneralMethods.getDistanceFromLine(
                    player.getLocation().getDirection(), player.getLocation(), entity.getLocation())
                <= 2
            && (entity instanceof LivingEntity)
            && (entity.getEntityId() != player.getEntityId())) {
          double distance = player.getLocation().distance(entity.getLocation());
          if (distance < lowestdistance) {
            closestentity = entity;
            lowestdistance = distance;
          }
        }
      }
      if (closestentity != null) {
        Block temptestingblock =
            closestentity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
        // if (temptestingblock.getType() == Material.ICE){
        this.block = temptestingblock;
        // }
      } else {
        this.block = player.getTargetBlock((HashSet<Material>) null, (int) range);
      }
      for (IceSpike2 icespike : IceSpike2.instances.values()) {
        if (icespike.getBlock().equals(block)) {
          return;
        }
      }
      origin = block.getLocation();
      location = origin.clone();

    } catch (IllegalStateException e) {
      return;
    }

    loadAffectedBlocks();

    if (height != 0) {
      if (canInstantiate()) {
        id = ID;
        instances.put(id, this);
        if (ID >= Integer.MAX_VALUE) {
          ID = Integer.MIN_VALUE;
        }
        ID++;
        time = System.currentTimeMillis() - interval;
        bPlayer.addCooldown("IceSpike", cooldown);
      }
    }
  }
Ejemplo n.º 4
0
  private static void block(Player player) {
    for (int id : instances.keySet()) {
      IceBlast ice = instances.get(id);

      if (ice.player.equals(player)) continue;

      if (!ice.location.getWorld().equals(player.getWorld())) continue;

      if (!ice.progressing) continue;

      if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", ice.location)) continue;

      Location location = player.getEyeLocation();
      Vector vector = location.getDirection();
      Location mloc = ice.location;
      if (mloc.distance(location) <= defaultrange
          && GeneralMethods.getDistanceFromLine(vector, location, ice.location) < deflectrange
          && mloc.distance(location.clone().add(vector))
              < mloc.distance(location.clone().add(vector.clone().multiply(-1)))) {
        ice.cancel();
      }
    }
  }