コード例 #1
0
ファイル: AirCombo.java プロジェクト: PhanaticD/ProjectKorra
  @Override
  public void progress() {
    progressCounter++;
    if (player.isDead() || !player.isOnline()) {
      remove();
      return;
    } else if (currentLoc != null && GeneralMethods.isRegionProtectedFromBuild(this, currentLoc)) {
      remove();
      return;
    }

    if (abilityName.equalsIgnoreCase("Twister")) {
      if (destination == null) {
        state = AbilityState.TWISTER_MOVING;
        direction = player.getEyeLocation().getDirection().clone().normalize();
        direction.setY(0);
        origin = player.getLocation().add(direction.clone().multiply(2));
        destination = player.getLocation().add(direction.clone().multiply(range));
        currentLoc = origin.clone();
      }
      if (origin.distanceSquared(currentLoc) < origin.distanceSquared(destination)
          && state == AbilityState.TWISTER_MOVING) {
        currentLoc.add(direction.clone().multiply(speed));
      } else if (state == AbilityState.TWISTER_MOVING) {
        state = AbilityState.TWISTER_STATIONARY;
        time = System.currentTimeMillis();
      } else if (System.currentTimeMillis() - time >= twisterRemoveDelay) {
        remove();
        return;
      } else if (GeneralMethods.isRegionProtectedFromBuild(this, currentLoc)) {
        remove();
        return;
      }

      Block topBlock = GeneralMethods.getTopBlock(currentLoc, 3, -3);
      if (topBlock == null) {
        remove();
        return;
      }
      currentLoc.setY(topBlock.getLocation().getY());

      double height = twisterHeight;
      double radius = twisterRadius;
      for (double y = 0; y < height; y += twisterHeightParticles) {
        double animRadius = ((radius / height) * y);
        for (double i = -180; i <= 180; i += twisterDegreeParticles) {
          Vector animDir = GeneralMethods.rotateXZ(new Vector(1, 0, 1), i);
          Location animLoc = currentLoc.clone().add(animDir.multiply(animRadius));
          animLoc.add(0, y, 0);
          playAirbendingParticles(animLoc, 1, 0, 0, 0);
        }
      }
      playAirbendingSound(currentLoc);

      for (int i = 0; i < height; i += 3) {
        for (Entity entity :
            GeneralMethods.getEntitiesAroundPoint(currentLoc.clone().add(0, i, 0), radius * 0.75)) {
          if (!affectedEntities.contains(entity) && !entity.equals(player)) {
            affectedEntities.add(entity);
          }
        }
      }

      for (Entity entity : affectedEntities) {
        Vector forceDir =
            GeneralMethods.getDirection(entity.getLocation(), currentLoc.clone().add(0, height, 0));
        if (entity instanceof Player) {
          if (Commands.invincible.contains(((Player) entity).getName())) {
            break;
          }
        }
        entity.setVelocity(forceDir.clone().normalize().multiply(0.3));
      }
    } else if (abilityName.equalsIgnoreCase("AirStream")) {
      if (destination == null) {
        origin = player.getEyeLocation();
        currentLoc = origin.clone();
      }
      Entity target = GeneralMethods.getTargetedEntity(player, range);
      if (target instanceof Player) {
        if (Commands.invincible.contains(((Player) target).getName())) {
          return;
        }
      }

      if (target != null && target.getLocation().distanceSquared(currentLoc) > 49) {
        destination = target.getLocation();
      } else {
        destination = GeneralMethods.getTargetedLocation(player, range, getTransparentMaterial());
      }

      direction = GeneralMethods.getDirection(currentLoc, destination).normalize();
      currentLoc.add(direction.clone().multiply(speed));

      if (player.getWorld() != currentLoc.getWorld()) {
        remove();
        return;
      } else if (!player.isSneaking()) {
        remove();
        return;
      } else if (player.getWorld().equals(currentLoc.getWorld())
          && Math.abs(player.getLocation().distanceSquared(currentLoc)) > range * range) {
        remove();
        return;
      } else if (affectedEntities.size() > 0
          && System.currentTimeMillis() - time >= airStreamEntityCarryDuration) {
        remove();
        return;
      } else if (!isTransparent(currentLoc.getBlock())) {
        remove();
        return;
      } else if (currentLoc.getY() - origin.getY() > airStreamMaxEntityHeight) {
        remove();
        return;
      } else if (GeneralMethods.isRegionProtectedFromBuild(this, currentLoc)) {
        remove();
        return;
      } else if (FireAbility.isWithinFireShield(currentLoc)) {
        remove();
        return;
      } else if (isWithinAirShield(currentLoc)) {
        remove();
        return;
      } else if (!isTransparent(currentLoc.getBlock())) {
        currentLoc.subtract(direction.clone().multiply(speed));
      }

      for (int i = 0; i < 10; i++) {
        BukkitRunnable br =
            new BukkitRunnable() {
              final Location loc = currentLoc.clone();
              final Vector dir = direction.clone();

              @Override
              public void run() {
                for (int angle = -180; angle <= 180; angle += 45) {
                  Vector orthog = GeneralMethods.getOrthogonalVector(dir.clone(), angle, 0.5);
                  playAirbendingParticles(loc.clone().add(orthog), 1, 0F, 0F, 0F);
                }
              }
            };
        br.runTaskLater(ProjectKorra.plugin, i * 2);
        tasks.add(br);
      }

      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(currentLoc, 2.8)) {
        if (affectedEntities.size() == 0) {
          // Set the timer to remove the ability
          time = System.currentTimeMillis();
        }
        if (!entity.equals(player) && !affectedEntities.contains(entity)) {
          affectedEntities.add(entity);
          if (entity instanceof Player) {
            flights.add(new Flight((Player) entity, player));
          }
        }
      }

      for (Entity entity : affectedEntities) {
        Vector force = GeneralMethods.getDirection(entity.getLocation(), currentLoc);
        entity.setVelocity(force.clone().normalize().multiply(speed));
        entity.setFallDistance(0F);
      }
    } else if (abilityName.equalsIgnoreCase("AirSweep")) {
      if (origin == null) {
        direction = player.getEyeLocation().getDirection().normalize();
        origin = player.getLocation().add(direction.clone().multiply(10));
      }
      if (progressCounter < 8) {
        return;
      }
      if (destination == null) {
        destination =
            player
                .getLocation()
                .add(player.getEyeLocation().getDirection().normalize().multiply(10));
        Vector origToDest = GeneralMethods.getDirection(origin, destination);
        for (double i = 0; i < 30; i++) {
          Vector vec =
              GeneralMethods.getDirection(
                  player.getLocation(), origin.clone().add(origToDest.clone().multiply(i / 30)));

          FireComboStream fs =
              new FireComboStream(null, vec, player.getLocation(), range, speed, "AirSweep");
          fs.setDensity(1);
          fs.setSpread(0F);
          fs.setUseNewParticles(true);
          fs.setParticleEffect(getAirbendingParticles());
          fs.setCollides(false);
          fs.runTaskTimer(ProjectKorra.plugin, (long) (i / 2.5), 1L);
          tasks.add(fs);
        }
      }
      manageAirVectors();
    }
  }
コード例 #2
0
  private void progress() {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (player.isDead()
        || !player.isOnline()
        || !GeneralMethods.canBend(player.getName(), "IceBlast")
        || bPlayer.isOnCooldown("IceBlast")) {
      cancel();
      return;
    }

    if (!player.getWorld().equals(location.getWorld())) {
      cancel();
      return;
    }

    if (player.getEyeLocation().distance(location) >= range) {
      if (progressing) {
        breakParticles(20);
        cancel();
        returnWater();
      } else {
        breakParticles(20);
        cancel();
      }
      return;
    }

    if ((GeneralMethods.getBoundAbility(player) == null
            || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("IceBlast"))
        && prepared) {
      cancel();
      return;
    }

    if (System.currentTimeMillis() < time + interval) return;

    time = System.currentTimeMillis();

    if (progressing) {

      Vector direction;

      if (location.getBlockY() == firstdestination.getBlockY()) settingup = false;

      if (location.distance(destination) <= 2) {
        cancel();
        returnWater();
        return;
      }

      if (settingup) {
        direction = GeneralMethods.getDirection(location, firstdestination).normalize();
      } else {
        direction = GeneralMethods.getDirection(location, destination).normalize();
      }

      location.add(direction);

      Block block = location.getBlock();

      if (block.equals(sourceblock)) return;

      source.revertBlock();
      source = null;

      if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
        GeneralMethods.breakBlock(block);
      } else if (!WaterMethods.isWater(block)) {
        breakParticles(20);
        cancel();
        returnWater();
        return;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", location)) {
        cancel();
        returnWater();
        return;
      }

      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, affectingradius)) {
        if (entity.getEntityId() != player.getEntityId() && entity instanceof LivingEntity) {
          affect((LivingEntity) entity);
          progressing = false;
          returnWater();
        }
      }

      if (!progressing) {
        cancel();
        return;
      }

      sourceblock = block;
      source = new TempBlock(sourceblock, Material.PACKED_ICE, data);

      for (int x = 0; x < 10; x++) {
        ParticleEffect.ITEM_CRACK.display(
            new ParticleEffect.ItemData(Material.ICE, (byte) 0),
            new Vector(
                ((Math.random() - 0.5) * .5),
                ((Math.random() - 0.5) * .5),
                ((Math.random() - 0.5) * .5)),
            .5f,
            location,
            257.0D);
        ParticleEffect.SNOW_SHOVEL.display(
            location,
            (float) (Math.random() - 0.5),
            (float) (Math.random() - 0.5),
            (float) (Math.random() - 0.5),
            0,
            5);
      }
      if (GeneralMethods.rand.nextInt(4) == 0) {
        WaterMethods.playIcebendingSound(location);
      }
      location = location.add(direction.clone());

    } else if (prepared) {
      WaterMethods.playFocusWaterEffect(sourceblock);
    }
  }
コード例 #3
0
  private boolean progress() {
    if (player.isDead()
        || !player.isOnline()
        || !GeneralMethods.canBend(player.getName(), "EarthBlast")) {
      breakBlock();
      return false;
    }
    if (System.currentTimeMillis() - time >= interval) {
      time = System.currentTimeMillis();

      if (falling) {
        breakBlock();
        return false;
      }

      if (!EarthMethods.isEarthbendable(player, sourceblock)
          && sourceblock.getType() != Material.COBBLESTONE) {
        instances.remove(id);
        return false;
      }

      if (!progressing && !falling) {

        if (GeneralMethods.getBoundAbility(player) == null) {
          unfocusBlock();
          return false;
        }

        if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast")) {
          unfocusBlock();
          return false;
        }

        if (sourceblock == null) {
          instances.remove(id);
          return false;
        }
        if (!player.getWorld().equals(sourceblock.getWorld())) {
          unfocusBlock();
          return false;
        }
        if (sourceblock.getLocation().distance(player.getLocation()) > preparerange) {
          unfocusBlock();
          return false;
        }
      }

      if (falling) {
        breakBlock();

      } else {
        if (!progressing) {
          return false;
        }

        if (sourceblock.getY() == firstdestination.getBlockY()) {
          settingup = false;
        }

        Vector direction;
        if (settingup) {
          direction = GeneralMethods.getDirection(location, firstdestination).normalize();
        } else {
          direction = GeneralMethods.getDirection(location, destination).normalize();
        }

        location = location.clone().add(direction);

        WaterMethods.removeWaterSpouts(location, player);
        AirMethods.removeAirSpouts(location, player);

        Block block = location.getBlock();
        if (block.getLocation().equals(sourceblock.getLocation())) {
          location = location.clone().add(direction);
          block = location.getBlock();
        }

        if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
          GeneralMethods.breakBlock(block);
        } else if (!settingup) {
          breakBlock();
          return false;
        } else {
          location = location.clone().subtract(direction);
          direction = GeneralMethods.getDirection(location, destination).normalize();
          location = location.clone().add(direction);

          WaterMethods.removeWaterSpouts(location, player);
          AirMethods.removeAirSpouts(location, player);
          double radius = FireBlast.AFFECTING_RADIUS;
          Player source = player;
          if (EarthBlast.annihilateBlasts(location, radius, source)
              || WaterManipulation.annihilateBlasts(location, radius, source)
              || FireBlast.annihilateBlasts(location, radius, source)) {
            breakBlock();
            return false;
          }

          Combustion.removeAroundPoint(location, radius);

          Block block2 = location.getBlock();
          if (block2.getLocation().equals(sourceblock.getLocation())) {
            location = location.clone().add(direction);
            block2 = location.getBlock();
          }

          if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
            GeneralMethods.breakBlock(block);
          } else {
            breakBlock();
            return false;
          }
        }

        for (Entity entity :
            GeneralMethods.getEntitiesAroundPoint(location, FireBlast.AFFECTING_RADIUS)) {
          if (GeneralMethods.isRegionProtectedFromBuild(
              player, "EarthBlast", entity.getLocation())) {
            continue;
          }
          if (entity instanceof LivingEntity
              && (entity.getEntityId() != player.getEntityId() || hitself)) {

            AirMethods.breakBreathbendingHold(entity);

            Location location = player.getEyeLocation();
            Vector vector = location.getDirection();
            entity.setVelocity(vector.normalize().multiply(pushfactor));
            double damage = this.damage;
            if (EarthMethods.isMetal(sourceblock) && EarthMethods.canMetalbend(player)) {
              damage = EarthMethods.getMetalAugment(this.damage);
            }
            GeneralMethods.damageEntity(player, entity, damage);
            progressing = false;
          }
        }

        if (!progressing) {
          breakBlock();
          return false;
        }

        if (revert) {
          // Methods.addTempEarthBlock(sourceblock, block);
          if (sourceblock.getType() == Material.RED_SANDSTONE) {
            sourceblock.setType(sourcetype);
            if (sourcetype == Material.SAND) {
              sourceblock.setData((byte) 0x1);
            }
          } else {
            sourceblock.setType(sourcetype);
          }
          EarthMethods.moveEarthBlock(sourceblock, block);

          if (block.getType() == Material.SAND) {
            block.setType(Material.SANDSTONE);
          }
          if (block.getType() == Material.GRAVEL) {
            block.setType(Material.STONE);
          }
        } else {
          block.setType(sourceblock.getType());
          sourceblock.setType(Material.AIR);
        }

        sourceblock = block;

        if (location.distance(destination) < 1) {
          if (sourcetype == Material.SAND || sourcetype == Material.GRAVEL) {
            progressing = false;
            if (sourceblock.getType() == Material.RED_SANDSTONE) {
              sourcetype = Material.SAND;
              sourceblock.setType(sourcetype);
              sourceblock.setData((byte) 0x1);
            } else {
              sourceblock.setType(sourcetype);
            }
          }

          falling = true;
          progressing = false;
        }

        return true;
      }
    }

    return false;
  }