本文整理汇总了Java中org.bukkit.util.Vector.distanceSquared方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.distanceSquared方法的具体用法?Java Vector.distanceSquared怎么用?Java Vector.distanceSquared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.util.Vector
的用法示例。
在下文中一共展示了Vector.distanceSquared方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNearest
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public EventRule getNearest(Vector pos) {
EventRule nearest = null;
double distance = Double.POSITIVE_INFINITY;
for(EventRule rule : byPriority) {
double d = pos.distanceSquared(rule.region().getBounds().center());
if(d < distance) {
nearest = rule;
distance = d;
}
}
return nearest;
}
示例2: distanceSquared
import org.bukkit.util.Vector; //导入方法依赖的package包/类
public double distanceSquared(Vector point) {
if(delta.isZero()) {
return point.distanceSquared(start);
} else {
final double t = perpendicularProjectionParameter(point);
if(t <= 0) {
return point.distanceSquared(start);
} else if(t >= 1) {
return point.distanceSquared(finish);
} else {
return point.distanceSquared(parametricPoint(t));
}
}
}
示例3: run
import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void run()
{
final Location playerLocation = player.getLocation();
// Checks if the player is still on the line
Vector position = playerLocation.toVector();
Vector origin = getStart().toVector();
Vector director = yodel.getAngleVector();
double k;
if (isZero(origin)) origin = getEnd().toVector();
try
{
k = director.getX() * (position.getX() - origin.getX())
+ director.getY() * (position.getY() - origin.getY())
+ director.getZ() * (position.getZ() - origin.getZ());
k /= NumberConversions.square(director.getX())
+ NumberConversions.square(director.getY())
+ NumberConversions.square(director.getZ());
}
catch (ArithmeticException e)
{
this.hub.getLogger().log(Level.SEVERE, "Division by zero while checking route on yodel, remains unfixed", e);
return;
}
Vector projection = origin.add(director.multiply(k));
if (projection.distanceSquared(position) > 4)
{
player.teleport(projection.toLocation(playerLocation.getWorld()).setDirection(playerLocation.getDirection()));
}
// Updates the velocity
player.setVelocity(velocityStep);
player.setFallDistance(0);
// Checks if the line is finished (either we are on the finish zone, or out of the path if for some
// reason the landing zone was not entered)
if (playerLocation.distanceSquared(getEnd()) < 6
|| playerLocation.distanceSquared(getStart()) > yodel.getLength() + 10)
{
this.yodel.stop(player);
}
}
示例4: awayFromSpawn
import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
* Function to check proximity to nether spawn location
*
* @param player
* @return true if in the spawn area, false if not
*/
private boolean awayFromSpawn(Player player) {
Vector p = player.getLocation().toVector().multiply(new Vector(1, 0, 1));
Vector spawn = player.getWorld().getSpawnLocation().toVector().multiply(new Vector(1, 0, 1));
return spawn.distanceSquared(p) < (Settings.netherSpawnRadius * Settings.netherSpawnRadius);
}