Package org.bukkit.util

Examples of org.bukkit.util.Vector.normalize()


        if (!(event.getVehicle() instanceof Minecart)) return;

        if (RailUtil.isTrack(event.getTo().getBlock().getType()) && event.getVehicle().getVelocity().lengthSquared() > 0) {
            Vector vel = event.getVehicle().getVelocity();
            event.getVehicle().setVelocity(vel.normalize().multiply(speed));
        }
    }

    double speed;
View Full Code Here


        if(RailUtil.isTrack(event.getPlayer().getVehicle().getLocation().getBlock().getType()))
            return;

        Vector direction = event.getPlayer().getLocation().getDirection();
        direction = direction.normalize();
        direction.setY(0);
        direction = direction.multiply(event.getPlayer().getVehicle().getVelocity().length());
        direction.setY(event.getPlayer().getVehicle().getVelocity().getY());
        event.getPlayer().getVehicle().setVelocity(direction);
    }
View Full Code Here

    for (final T other : type == null ? (List<T>) entity.getWorld().getEntities() : entity.getWorld().getEntitiesByClass(type.getType())) {
      if (other == null || other == entity || type != null && !type.isInstance(other))
        continue;
      if (target == null || targetDistanceSquared > other.getLocation().distanceSquared(entity.getLocation())) {
        final Vector t = other.getLocation().add(0, 1, 0).toVector().subtract(l);
        if (n.clone().crossProduct(t).lengthSquared() < radiusSquared && t.normalize().dot(n) >= cos45) {
          target = other;
          targetDistanceSquared = target.getLocation().distanceSquared(entity.getLocation());
        }
      }
    }
View Full Code Here

    final Entity[] ents = entities.getArray(e);
    for (final Entity en : ents) {
      assert en != null;
      final Vector mod = d.getDirection(en);
      if (v != null)
        mod.normalize().multiply(v.doubleValue());
      en.setVelocity(en.getVelocity().add(mod)); // REMIND add NoCheatPlus exception to players
    }
  }
 
  @Override
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.