Beispiel #1
0
  /**
   * This method launches near by entities
   *
   * @return true if a entity was thrown.
   */
  protected boolean shoot() {

    boolean resultBoolean = false;
    Location location = BukkitUtil.toSign(getSign()).getLocation();
    EntityType type = EntityType.MOB_HOSTILE;

    if (!getSign().getLine(3).isEmpty()) {
      type = EntityType.fromString(getSign().getLine(3));
    }

    try {
      for (Entity e : LocationUtil.getNearbyEntities(location, new Vector(3, 3, 3))) {
        if (e.isDead() || !e.isValid()) {
          continue;
        }
        if (!type.is(e)) {
          continue;
        }

        String[] split = RegexUtil.COLON_PATTERN.split(getSign().getLine(2));
        double x = Double.parseDouble(split[0]);
        double y = Double.parseDouble(split[1]);
        double z = Double.parseDouble(split[2]);

        e.setVelocity(new org.bukkit.util.Vector(x, y, z).add(e.getVelocity()));

        resultBoolean = true;
      }
    } catch (Exception ignored) {
    }

    return resultBoolean;
  }
 private void affect(Entity entity) {
   BendingHitEvent event = new BendingHitEvent(this, entity);
   Bending.callEvent(event);
   if (event.isCancelled()) {
     return;
   }
   if (entity == player) {
     return;
   }
   Vector direction = origin.clone().subtract(entity.getLocation()).toVector();
   double distance = direction.length();
   entity.setVelocity(
       entity.getVelocity().add(direction.normalize().multiply(PUSH * distance / RADIUS)));
   entity.setFallDistance(0);
 }
Beispiel #3
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void EntityDamageEvent(EntityDamageEvent e) {

    Entity damaged = e.getEntity();

    if (damaged instanceof Player) {

      CEventHandler.handleEvent((Player) damaged, e, damageNature);

      if (damaged.hasMetadata("ce.springs")) {
        e.setCancelled(true);
        Vector vel = damaged.getVelocity();
        vel.setY((vel.getY() * -0.75) > 1 ? vel.getY() * -0.75 : 0);
        damaged.setVelocity(vel);
      }
    }
  }
 boolean projectileHitLocation(Entity projectile, ProjectileInfo info) {
   if (!requireHitEntity
       && !info.done
       && (maxDistanceSquared == 0
           || projectile.getLocation().distanceSquared(info.start) <= maxDistanceSquared)) {
     if (aoeRadius == 0) {
       for (Subspell spell : spells) {
         if (spell.isTargetedLocationSpell()) {
           Location loc = projectile.getLocation();
           Util.setLocationFacingFromVector(loc, projectile.getVelocity());
           spell.castAtLocation(info.player, loc, info.power);
           playSpellEffects(EffectPosition.TARGET, loc);
         }
       }
       sendMessage(strHitCaster, info.player, MagicSpells.NULL_ARGS);
     } else {
       aoe(projectile, info);
     }
     info.done = true;
   }
   return true;
 }
 public Velocity getVelocity() {
   Vector v = e.getVelocity();
   return new Velocity(v.length(), v.getX(), v.getY(), v.getZ());
 }