org.bukkit.util.Vector.angle()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.bukkit.util.Vector.angle()方法的一些代码示例,展示了Vector.angle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.angle()方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:angle

Vector.angle介绍

[英]Gets the angle between this vector and another in radians.
[中]获取此向量与另一个向量之间的角度(以弧度为单位)。

代码示例

代码示例来源:origin: NyaaCat/RPGItems-reloaded

/**
 * Gets angle between vectors.
 *
 * @param v1 the v 1
 * @param v2 the v 2
 * @return the angle between vectors
 */
public static float getAngleBetweenVectors(org.bukkit.util.Vector v1, org.bukkit.util.Vector v2) {
  return Math.abs((float) Math.toDegrees(v1.angle(v2)));
}

代码示例来源:origin: ProjectKorra/ProjectKorra

private void startConeBurst() {
  if (this.isCharged) {
    final Location location = this.player.getEyeLocation();
    final Vector vector = location.getDirection();
    final double angle = Math.toRadians(30);
    double x, y, z;
    final double r = 1;
    for (double theta = 0; theta <= 180; theta += this.blastAngleTheta) {
      final double dphi = this.blastAnglePhi / Math.sin(Math.toRadians(theta));
      for (double phi = 0; phi < 360; phi += dphi) {
        final double rphi = Math.toRadians(phi);
        final double rtheta = Math.toRadians(theta);
        x = r * Math.cos(rphi) * Math.sin(rtheta);
        y = r * Math.sin(rphi) * Math.sin(rtheta);
        z = r * Math.cos(rtheta);
        final Vector direction = new Vector(x, z, y);
        if (direction.angle(vector) <= angle) {
          final AirBlast blast = new AirBlast(this.player, location, direction.normalize(), this.pushFactor, this);
          blast.setDamage(this.damage);
        }
      }
    }
  }
}

代码示例来源:origin: ProjectKorra/ProjectKorra

private void coneBurst() {
  if (this.charged) {
    final Location location = this.player.getEyeLocation();
    final List<Block> safeBlocks = GeneralMethods.getBlocksAroundPoint(this.player.getLocation(), 2);
    final Vector vector = location.getDirection();
    final double angle = Math.toRadians(30);
    double x, y, z;
    final double r = 1;
    for (double theta = 0; theta <= 180; theta += this.angleTheta) {
      final double dphi = this.anglePhi / Math.sin(Math.toRadians(theta));
      for (double phi = 0; phi < 360; phi += dphi) {
        final double rphi = Math.toRadians(phi);
        final double rtheta = Math.toRadians(theta);
        x = r * Math.cos(rphi) * Math.sin(rtheta);
        y = r * Math.sin(rphi) * Math.sin(rtheta);
        z = r * Math.cos(rtheta);
        final Vector direction = new Vector(x, z, y);
        if (direction.angle(vector) <= angle) {
          final FireBlast fblast = new FireBlast(location, direction.normalize(), this.player, this.damage, safeBlocks);
          fblast.setRange(this.range);
        }
      }
    }
    this.bPlayer.addCooldown(this);
  }
  this.remove();
}

代码示例来源:origin: ProjectKorra/ProjectKorra

private void attack() {
  if (!this.formed || this.bPlayer.isOnCooldown("OctopusAttack")) {
    return;
  }
  this.bPlayer.addCooldown("OctopusAttack", this.usageCooldown);
  final double tentacleAngle = (new Vector(1, 0, 0)).angle(this.player.getEyeLocation().getDirection()) + this.angleIncrement / 2;
  for (double tangle = tentacleAngle; tangle < tentacleAngle + 360; tangle += this.angleIncrement) {
    final double phi = Math.toRadians(tangle);
    this.affect(this.player.getLocation().clone().add(new Vector(this.radius * Math.cos(phi), 1, this.radius * Math.sin(phi))));
  }
}

代码示例来源:origin: ProjectKorra/ProjectKorra

public static void coneShockwave(final Player player) {
  final Shockwave shockWave = getAbility(player, Shockwave.class);
  if (shockWave != null) {
    if (shockWave.charged) {
      final double dtheta = 360.0 / (2 * Math.PI * shockWave.range) - 1;
      for (double theta = 0; theta < 360; theta += dtheta) {
        final double rtheta = Math.toRadians(theta);
        final Vector vector = new Vector(Math.cos(rtheta), 0, Math.sin(rtheta));
        if (vector.angle(player.getEyeLocation().getDirection()) < shockWave.angle) {
          new Ripple(player, vector.normalize());
        }
      }
      shockWave.bPlayer.addCooldown(shockWave);
      shockWave.remove();
    }
  }
}

代码示例来源:origin: ProjectKorra/ProjectKorra

eyeDir.setY(0);
final double tentacleAngle = Math.toDegrees((new Vector(1, 0, 0)).angle(eyeDir)) + this.angleIncrement / 2;
int astep = this.currentAnimationStep;
for (double tangle = tentacleAngle; tangle < tentacleAngle + 360; tangle += this.angleIncrement) {

代码示例来源:origin: NoCheatPlus/NoCheatPlus

vec2.setY(dirY);
vec2.setZ(dirZ);
return vec2.angle(vec1);

代码示例来源:origin: ProjectKorra/ProjectKorra

if (Math.abs(Math.toDegrees(this.player.getEyeLocation().getDirection().angle(this.direction))) > 20 || !this.player.isSneaking()) {
  this.bPlayer.addCooldown(this);
  this.remove();

代码示例来源:origin: ProjectKorra/ProjectKorra

if (this.up.angle(this.player.getEyeLocation().getDirection()) > this.angle) {
  if (this.cancelWithAngle) {
    this.remove();

代码示例来源:origin: elBukkit/MagicPlugin

double angle = targetDirection.angle(direction);
if (angle > crashEntityFOV) continue;
if (crashEntityDamage > 0 && entity instanceof Damageable) {

代码示例来源:origin: ProjectKorra/ProjectKorra

if (this.prevDir.angle(this.player.getEyeLocation().getDirection()) > 45 || this.prevDir.angle(this.player.getEyeLocation().getDirection()) < -45) {
  this.multiplier = 1;

代码示例来源:origin: elBukkit/MagicPlugin

angle = targetDirection.angle(sourceDirection);

代码示例来源:origin: ProjectKorra/ProjectKorra

final double startAngle = this.player.getEyeLocation().getDirection().angle(new Vector(1, 0, 0));
final double dx = this.radius * Math.cos(startAngle);
final double dy = 0;

代码示例来源:origin: ProjectKorra/ProjectKorra

this.startAngle = vector.angle(GeneralMethods.getDirection(this.sourceBlock.getLocation(), location));
this.angle = this.startAngle;

代码示例来源:origin: ProjectKorra/ProjectKorra

final Vector compare = direction.clone();
compare.setY(0);
if (Math.abs(direction.angle(compare)) > Math.toRadians(this.maxAngle)) {
  return;

代码示例来源:origin: elBukkit/MagicPlugin

Mage targetMage = actionContext.getController().getMage(hitPlayer);
if (hitPlayer.isBlocking()) {
  double angle = velocity.angle(hitPlayer.getEyeLocation().getDirection().multiply(-1));
  if ((reflectLimit < 0 || reflectCount < reflectLimit) && !bypassBackfire && targetMage.isReflected(angle)) {
    velocity = hitPlayer.getEyeLocation().getDirection().normalize().multiply(velocity.length());

相关文章