@Override public Vector getDirection() { return velocity.normalize(); }
@Override public void setDirection(Vector vector) { setVelocity(vector.normalize().multiply(velocity.length())); }
@Override public Arrow spawnArrow(Location location, Vector velocity, float speed, float spread) { // Transformative magic Vector randVec = new Vector(ThreadLocalRandom.current().nextGaussian(), ThreadLocalRandom .current().nextGaussian(), ThreadLocalRandom.current().nextGaussian()); randVec.multiply(0.0075 * spread); velocity.normalize(); velocity.add(randVec); velocity.multiply(speed); // yaw = Math.atan2(x, z) * 180.0D / 3.1415927410125732D; // pitch = Math.atan2(y, Math.sqrt(x * x + z * z)) * 180.0D / 3.1415927410125732D Arrow arrow = spawn(location, Arrow.class); arrow.setVelocity(velocity); return arrow; }
/** * Maps {0, 0, 0} to {0, 1, 0} and all other vectors to their normalized form. * * @param ray the ray to transform * @return a ray of length 1 */ public static Vector getVelocityRay(Vector ray) { Vector velocityRay = ray.clone(); if (velocityRay.lengthSquared() == 0) { velocityRay.setX(0); velocityRay.setY(1); velocityRay.setZ(0); } else { velocityRay.normalize(); } return velocityRay; }
direction.normalize();
.getRayBetween(getLocation(), ((LivingEntity) source).getEyeLocation()); Vector rayLength = RayUtil.getVelocityRay(distance).normalize();
public static Vector getRandomVector() { double x, y, z; x = random.nextDouble() * 2 - 1; y = random.nextDouble() * 2 - 1; z = random.nextDouble() * 2 - 1; return new Vector(x, y, z).normalize(); }
protected Vector getDirection() { Location origin = this.getOrigin(); Location target = this.getTarget(); if (origin == null) return new Vector(0, 1, 0); Vector direction = target == null ? origin.getDirection() : target.toVector().subtract(origin.toVector()); return direction.normalize(); }
public int getEarthbendableBlocksLength(final Block block, Vector direction, final int maxlength) { final Location location = block.getLocation(); direction = direction.normalize(); for (int i = 0; i <= maxlength; i++) { final double j = i; if (!this.isEarthbendable(location.clone().add(direction.clone().multiply(j)).getBlock())) { return i; } } return maxlength; }
/** * Returns the location of the tip of the left arm assuming it is fully * extended. Use the displayLeftArm() check to see if it is fully extended. * * @return location of the tip of the left arm */ public Location getLeftArmEnd() { final Location l1 = GeneralMethods.getLeftSide(this.player.getLocation(), 2).add(0, 1.5, 0); return l1.clone().add(this.player.getLocation().getDirection().normalize().multiply(this.initLength)); }
@Override public void execute(Arena arena, MABoss boss) { Location bLoc = boss.getEntity().getLocation(); for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) { Location loc = p.getLocation(); Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ()); p.setVelocity(v.normalize().setY(0.8)); } } }
@Override public void execute(Arena arena, MABoss boss) { LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM); if (target == null) return; Location bLoc = boss.getEntity().getLocation(); Location loc = target.getLocation(); Vector v = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ()); target.setVelocity(v.normalize().setY(0.8)); } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }
void setVelocity(Vector velocity) { try { this.times = (int) (50 * this.ball.getMeta().getModifiers().getRollingDistanceModifier()); this.getSpigotEntity().setVelocity(velocity); final Vector normalized = velocity.clone().normalize(); this.originVector = velocity.clone(); this.reduceVector = new Vector(normalized.getX() / this.times , 0.0784 * this.ball.getMeta().getModifiers().getGravityModifier() , normalized.getZ() / this.times); } catch (IllegalArgumentException ignored) { } }