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

x33g5p2x  于2022-01-31 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(95)

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

Vector.setY介绍

[英]Set the Y component.
[中]设置Y分量。

代码示例

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

/**
 * Gets a unit-vector pointing in the direction that this Location is
 * facing.
 *
 * @return a vector pointing the direction of this location's {@link
 *     #getPitch() pitch} and {@link #getYaw() yaw}
 */
public Vector getDirection() {
  Vector vector = new Vector();
  double rotX = this.getYaw();
  double rotY = this.getPitch();
  vector.setY(-Math.sin(Math.toRadians(rotY)));
  double xz = Math.cos(Math.toRadians(rotY));
  vector.setX(-xz * Math.sin(Math.toRadians(rotX)));
  vector.setZ(xz * Math.cos(Math.toRadians(rotX)));
  return vector;
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Moves this box so that its center is the given point.
 * @param x the center X coordinate
 * @param y the center Y coordinate
 * @param z the center Z coordinate
 */
public void setCenter(double x, double y, double z) {
  minCorner.setX(x - width / 2);
  minCorner.setY(y);
  minCorner.setZ(z - depth / 2);
  maxCorner.setX(x + width / 2);
  maxCorner.setY(y + vertSize);
  maxCorner.setZ(z + depth / 2);
}

代码示例来源:origin: GlowstoneMC/Glowstone

protected void jump() {
  if (location.getBlock().isLiquid()) {
    // jump out more when you breach the surface of the liquid
    if (location.getBlock().getRelative(BlockFace.UP).isEmpty()) {
      velocity.setY(velocity.getY() + 0.3);
    }
    // less jumping in liquid
    velocity.setY(velocity.getY() + 0.04);
  } else {
    // jump normally
    velocity.setY(velocity.getY() + 0.42);
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Converts two Vector instances to a BoundingBox.
 * @param a any corner
 * @param b the corner opposite {@code a}
 * @return a bounding box from {@code a} to {@code b}
 */
public static BoundingBox fromCorners(Vector a, Vector b) {
  BoundingBox box = new BoundingBox();
  box.minCorner.setX(Math.min(a.getX(), b.getX()));
  box.minCorner.setY(Math.min(a.getY(), b.getY()));
  box.minCorner.setZ(Math.min(a.getZ(), b.getZ()));
  box.maxCorner.setX(Math.max(a.getX(), b.getX()));
  box.maxCorner.setY(Math.max(a.getY(), b.getY()));
  box.maxCorner.setZ(Math.max(a.getZ(), b.getZ()));
  return box;
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * Creates a bounding box that is effectively the entire given block.
 * @param block the block
 */
public BlockBoundingBox(Block block) {
  minCorner.setX(block.getX());
  minCorner.setY(block.getY());
  minCorner.setZ(block.getZ());
  maxCorner.setX(block.getX() + 1);
  maxCorner.setY(block.getY() + 0.95);
  maxCorner.setZ(block.getZ() + 1);
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
protected void updateBoundingBox() {
  BlockFace rightFace = getRightFace();
  double modX = Math.abs(rightFace.getModX() * art.getBlockWidth());
  double modY = art.getBlockHeight();
  double modZ = Math.abs(rightFace.getModZ() * art.getBlockWidth());
  if (modX == 0.0) {
    modX = PAINTING_DEPTH;
  } else if (modZ == 0.0) {
    modZ = PAINTING_DEPTH;
  }
  // restrict the bounding box to not reach exactly onto the next blocks
  modX -= 0.00001;
  modY -= 0.00001;
  modZ -= 0.00001;
  boundingBox = new EntityBoundingBox(modX, modY, modZ);
  super.updateBoundingBox();
  // y of the painting is in the center, but for most other it is at the foot
  // therefore center it here
  boundingBox.minCorner.setY(location.getY() - modY / 2);
  boundingBox.maxCorner.setY(location.getY() + modY / 2);
}

代码示例来源:origin: GlowstoneMC/Glowstone

/**
 * 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;
}

代码示例来源:origin: GlowstoneMC/Glowstone

protected Vector getVelocityFromMovement() {
  movement.setY(0);

代码示例来源:origin: GlowstoneMC/Glowstone

velocity.setY(0);
  velocity.setY(velocity.getY() + getGravityAccel().getY() / 4);
} else if (location.getBlock().getType() == Material.LAVA) {
  velocity.multiply(liquidDrag - 0.3);
  velocity.setY(velocity.getY() + getGravityAccel().getY() / 4);
} else {
  if (applyDragBeforeAccel) {
    velocity.setY(airDrag * velocity.getY() + getGravityAccel().getY());
  } else {
    velocity.setY(airDrag * (velocity.getY() + getGravityAccel().getY()));
    velocity.setY(0);
    velocity.setZ(velocity.getZ() * slipMultiplier);
  } else {
  case WATER:
  case LAVA:
    velocity.setY(velocity.getY() + getGravityAccel().getY() / 4);
    break;
  default:
    velocity.setY(velocity.getY() + getGravityAccel().getY() / 4);

代码示例来源:origin: GlowstoneMC/Glowstone

delta.setY(Math.abs(delta.getY()));
delta.setZ(Math.abs(delta.getZ()));
int flatDistance = (int) Math.round(Math.hypot(delta.getX(), delta.getZ()) * 100.0);

代码示例来源:origin: GlowstoneMC/Glowstone

velocity.setY(velocity.getY() + 0.04);
velocity.setZ(velocity.getZ() * 1.15);
setVelocity(velocity);
velocity.setY(velocity.getY() + dy);
velocity.setZ(velocity.getZ() + dz);

代码示例来源:origin: GlowstoneMC/Glowstone

delta.setY(Math.abs(delta.getY()));
delta.setZ(Math.abs(delta.getZ()));
int flatDistance = (int) Math.round(Math.hypot(delta.getX(), delta.getZ()) * 100.0);

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

startClone.setY(startClone.getY() + yOffset);

代码示例来源:origin: Slikey/EffectLib

public static final Vector rotateAroundAxisX(Vector v, double angle) {
  double y, z, cos, sin;
  cos = Math.cos(angle);
  sin = Math.sin(angle);
  y = v.getY() * cos - v.getZ() * sin;
  z = v.getY() * sin + v.getZ() * cos;
  return v.setY(y).setZ(z);
}

代码示例来源:origin: Slikey/EffectLib

public static final Vector rotateAroundAxisZ(Vector v, double angle) {
  double x, y, cos, sin;
  cos = Math.cos(angle);
  sin = Math.sin(angle);
  x = v.getX() * cos - v.getY() * sin;
  y = v.getX() * sin + v.getY() * cos;
  return v.setX(x).setY(y);
}

代码示例来源:origin: Slikey/EffectLib

@Override
public void onRun() {
  Location location = getLocation();
  for (int i = 0; i < 10; i++) {
    Vector v = RandomUtils.getRandomCircleVector().multiply(RandomUtils.random.nextDouble() * 0.6d);
    v.setY(RandomUtils.random.nextFloat() * 1.8);
    location.add(v);
    display(particle, location);
    location.subtract(v);
  }
}

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

public static void setVelocity(Entity entity, Vector velocity) {
    if (!MathUtils.isFinite(velocity.getX()) || !MathUtils.isFinite(velocity.getY()) || !MathUtils.isFinite(velocity.getZ())) {
      return;
    }
    if (Math.abs(velocity.getX()) > MAX_VELOCITY) velocity.setX(MAX_VELOCITY * Math.signum(velocity.getX()));
    if (Math.abs(velocity.getY()) > MAX_VELOCITY) velocity.setY(MAX_VELOCITY * Math.signum(velocity.getY()));
    if (Math.abs(velocity.getZ()) > MAX_VELOCITY) velocity.setZ(MAX_VELOCITY * Math.signum(velocity.getZ()));
    entity.setVelocity(velocity);
  }
}

代码示例来源:origin: CitizensDev/CitizensAPI

public VectorNode(VectorNode parent, Vector location, PathInfo info) {
  super(parent);
  this.location = location.setX(location.getBlockX()).setY(location.getBlockY()).setZ(location.getBlockZ());
  this.info = info;
}

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

@Override
public PowerResult<Double> hit(Player player, ItemStack stack, LivingEntity entity, double damage, EntityDamageByEntityEvent event) {
  if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost();
  if (rand.nextInt(chance) == 0) {
    Bukkit.getScheduler().runTask(RPGItems.plugin, () -> entity.setVelocity(player.getLocation().getDirection().setY(power)));
  }
  return PowerResult.ok(damage);
}

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

private void jump(final Player p) {
  if (!GeneralMethods.isSolid(p.getLocation().getBlock().getRelative(BlockFace.DOWN))) {
    this.remove();
    return;
  }
  final Vector vec = p.getVelocity();
  vec.setY(this.height);
  p.setVelocity(vec);
  this.bPlayer.addCooldown(this);
  return;
}

相关文章