+ current.distanceSquared(neighbor.getKey()); if (!costs.containsKey(neighbor.getKey()) || cost < costs.get(neighbor.getKey())) { costs.put(neighbor.getKey(), cost);
@Override public boolean isFinished(VectorNode node) { double distanceSquared = node.getVector().distanceSquared(goal); return goal.equals(node.location) || distanceSquared <= leeway; } }
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); } } } }
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 {
try inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
/** * 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); } } }
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;
/** * 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); }
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;
if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT))
} else { double moveDistanceSquared = moveDistance * moveDistance; double distanceSquared = direction.distanceSquared(targetDirection); if (distanceSquared <= moveDistanceSquared) { direction = targetDirection;
double distanceSquared = targetVelocity.distanceSquared(velocity); if (distanceSquared <= steerDistanceSquared) { velocity = targetVelocity;
} else { double moveDistanceSquared = move * move; double distanceSquared = direction.distanceSquared(mageDirection); if (distanceSquared <= moveDistanceSquared) { direction = mageDirection;