本文整理了Java中org.bukkit.util.Vector.distanceSquared()
方法的一些代码示例,展示了Vector.distanceSquared()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.distanceSquared()
方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:distanceSquared
[英]Get the squared distance between this vector and another.
[中]得到这个向量和另一个向量之间的平方距离。
代码示例来源:origin: GlowstoneMC/Glowstone
+ current.distanceSquared(neighbor.getKey());
if (!costs.containsKey(neighbor.getKey()) || cost < costs.get(neighbor.getKey())) {
costs.put(neighbor.getKey(), cost);
代码示例来源:origin: CitizensDev/CitizensAPI
@Override
public boolean isFinished(VectorNode node) {
double distanceSquared = node.getVector().distanceSquared(goal);
return goal.equals(node.location) || distanceSquared <= leeway;
}
}
代码示例来源:origin: elBukkit/MagicPlugin
public void sendToMages(String message, Location location, int range) {
int rangeSquared = range * range;
if (message != null && message.length() > 0) {
for (Mage mage : mages.values())
{
if (!mage.isPlayer() || mage.isDead() || !mage.isOnline() || !mage.hasLocation()) continue;
if (!mage.getLocation().getWorld().equals(location.getWorld())) continue;
if (mage.getLocation().toVector().distanceSquared(location.toVector()) < rangeSquared) {
mage.sendMessage(message);
}
}
}
}
代码示例来源:origin: elBukkit/MagicPlugin
Vector hit = getIntersection(p1.getY() - min.getY(), p2.getY() - min.getY(), p1, p2, 2);
if (currentHit != null && hit != null) {
if (currentHit.distanceSquared(p1) < hit.distanceSquared(p1)) {
return currentHit;
} else {
if (currentHit.distanceSquared(p1) < hit.distanceSquared(p1)) {
return currentHit;
} else {
if (currentHit.distanceSquared(p1) < hit.distanceSquared(p1)) {
return currentHit;
} else {
if (currentHit.distanceSquared(p1) < hit.distanceSquared(p1)) {
return currentHit;
} else {
if (currentHit.distanceSquared(p1) < hit.distanceSquared(p1)) {
return currentHit;
} else {
代码示例来源:origin: TotalFreedom/TotalFreedomMod
try
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
代码示例来源:origin: BentoBoxWorld/BentoBox
/**
* Spawn particles to the player.
* They are only displayed if they are within the server's view distance.
* @param particle Particle to display.
* @param dustOptions Particle.DustOptions for the particle to display.
* Cannot be null when particle is {@link Particle#REDSTONE}.
* @param x X coordinate of the particle to display.
* @param y Y coordinate of the particle to display.
* @param z Z coordinate of the particle to display.
*/
public void spawnParticle(Particle particle, Particle.DustOptions dustOptions, double x, double y, double z) {
if (particle.equals(Particle.REDSTONE) && dustOptions == null) {
// Security check that will avoid later unexpected exceptions.
throw new IllegalArgumentException("A non-null Particle.DustOptions must be provided when using Particle.REDSTONE as particle.");
}
// Check if this particle is beyond the viewing distance of the server
if (player.getLocation().toVector().distanceSquared(new Vector(x,y,z)) < (Bukkit.getServer().getViewDistance()*256*Bukkit.getServer().getViewDistance())) {
if (particle.equals(Particle.REDSTONE)) {
player.spawnParticle(particle, x, y, z, 1, 0, 0, 0, 1, dustOptions);
} else {
player.spawnParticle(particle, x, y, z, 1);
}
}
}
代码示例来源:origin: mcmonkeyprojects/Sentinel
Vector relative = entity.getLocation().toVector().subtract(centerVec);
for (int i = 0; i < 36; i++) {
double dist = relative.distanceSquared(directionReferenceVectors[i].clone().multiply(range));
if (dist < threatDists[i]) {
threatDists[i] = dist;
代码示例来源:origin: BentoBoxWorld/BentoBox
/**
* Function to check proximity to nether or end spawn location.
* Used when playing with the standard nether or end.
*
* @param location - the location
* @return true if in the spawn area, false if not
*/
private boolean atSpawn(Location location) {
Vector p = location.toVector().multiply(new Vector(1, 0, 1));
Vector spawn = location.getWorld().getSpawnLocation().toVector().multiply(new Vector(1, 0, 1));
int radiusSquared = plugin.getIWM().getNetherSpawnRadius(location.getWorld()) * plugin.getIWM().getNetherSpawnRadius(location.getWorld());
return (spawn.distanceSquared(p) < radiusSquared);
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
double minAxis = Math.min(entityBb.getHeight(), Math.min(entityBb.getWidthX(), entityBb.getWidthZ()));
double maximum = minAxis * minAxis;
double ds = entityBb.getMax().distanceSquared(entityBb.getMin()) - maxAxis * maxAxis;
Vector head;
if (entityBb.getHeight() * entityBb.getHeight() > ds) {
} else {
Vector hitPoint = Utils.hitPoint(damagerBb, sweep.getValue());
double squared = hitPoint.distanceSquared(head);
hs = squared <= maximum;
代码示例来源:origin: TotalFreedom/TotalFreedomMod
if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
代码示例来源:origin: elBukkit/MagicPlugin
} else {
double moveDistanceSquared = moveDistance * moveDistance;
double distanceSquared = direction.distanceSquared(targetDirection);
if (distanceSquared <= moveDistanceSquared) {
direction = targetDirection;
代码示例来源:origin: elBukkit/MagicPlugin
double distanceSquared = targetVelocity.distanceSquared(velocity);
if (distanceSquared <= steerDistanceSquared) {
velocity = targetVelocity;
代码示例来源:origin: elBukkit/MagicPlugin
} else {
double moveDistanceSquared = move * move;
double distanceSquared = direction.distanceSquared(mageDirection);
if (distanceSquared <= moveDistanceSquared) {
direction = mageDirection;
内容来源于网络,如有侵权,请联系作者删除!