本文整理了Java中org.bukkit.util.Vector.setX()
方法的一些代码示例,展示了Vector.setX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.setX()
方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:setX
[英]Set the X component.
[中]设置X分量。
代码示例来源: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
/**
* 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
/**
* 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
movement.setX(movement.getX() / mag);
movement.setZ(movement.getZ() / mag);
double z = Math.sin(yaw);
double x = Math.cos(yaw);
movement.setX(movement.getZ() * x - movement.getX() * z);
movement.setZ(movement.getX() * x + movement.getZ() * z);
代码示例来源:origin: GlowstoneMC/Glowstone
delta.setX(Math.abs(delta.getX()));
delta.setY(Math.abs(delta.getY()));
delta.setZ(Math.abs(delta.getZ()));
代码示例来源:origin: GlowstoneMC/Glowstone
velocity.setX(velocity.getX() * 1.15);
velocity.setY(velocity.getY() + 0.04);
velocity.setZ(velocity.getZ() * 1.15);
double dz = direction.getZ() * 0.1 + (direction.getZ() * 1.5 - velocity.getZ()) * 0.5;
velocity.setX(velocity.getX() + dx);
velocity.setY(velocity.getY() + dy);
velocity.setZ(velocity.getZ() + dz);
代码示例来源:origin: GlowstoneMC/Glowstone
delta.setX(Math.abs(delta.getX()));
delta.setY(Math.abs(delta.getY()));
delta.setZ(Math.abs(delta.getZ()));
代码示例来源:origin: GlowstoneMC/Glowstone
Location pendingLocationX = location.clone().add(velocity.getX(), 0, 0);
if (pendingLocationX.getBlock().getType().isSolid()) {
velocity.setX(0);
velocity.setX(velocity.getX() * slipMultiplier);
velocity.setY(0);
velocity.setZ(velocity.getZ() * slipMultiplier);
} else {
velocity.setX(velocity.getX() * airDrag);
velocity.setZ(velocity.getZ() * airDrag);
代码示例来源:origin: ProjectKorra/ProjectKorra
/**
* Rotates a vector around the Y plane.
*/
public static Vector rotateXZ(final Vector vec, final double theta) {
final Vector vec2 = vec.clone();
final double x = vec2.getX();
final double z = vec2.getZ();
vec2.setX(x * Math.cos(Math.toRadians(theta)) - z * Math.sin(Math.toRadians(theta)));
vec2.setZ(x * Math.sin(Math.toRadians(theta)) + z * Math.cos(Math.toRadians(theta)));
return vec2;
}
代码示例来源:origin: eccentricdevotion/TARDIS
private static Vector rotateAroundAxisY(Vector v, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = v.getX() * cos + v.getZ() * sin;
double z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).setZ(z);
}
代码示例来源:origin: Slikey/EffectLib
public static final Vector rotateAroundAxisY(Vector v, double angle) {
double x, z, cos, sin;
cos = Math.cos(angle);
sin = Math.sin(angle);
x = v.getX() * cos + v.getZ() * sin;
z = v.getX() * -sin + v.getZ() * cos;
return v.setX(x).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: 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: elBukkit/MagicPlugin
public BoundingBox expand(double size) {
this.min.setX(this.min.getX() - size);
this.min.setY(this.min.getY() - size);
this.min.setZ(this.min.getZ() - size);
this.max.setX(this.max.getX() + size);
this.max.setY(this.max.getY() + size);
this.max.setZ(this.max.getZ() + size);
return this;
}
代码示例来源: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: CitizensDev/CitizensAPI
public VectorGoal(Location dest, float range) {
if (!MinecraftBlockExaminer.canStandIn(dest.getBlock().getType())) {
dest = MinecraftBlockExaminer.findValidLocation(dest, 1);
}
this.leeway = range;
this.goal = dest.toVector();
goal.setX(goal.getBlockX()).setY(goal.getBlockY()).setZ(goal.getBlockZ());
}
代码示例来源:origin: elBukkit/MagicPlugin
public BoundingBox scale(double scale)
{
if (scale <= 0 || scale == 1) return this;
Vector center = this.center();
this.min.setX((this.min.getX() - center.getX()) * scale + center.getX());
this.min.setY((this.min.getY() - center.getY()) * scale + center.getY());
this.min.setZ((this.min.getZ() - center.getZ()) * scale + center.getZ());
this.max.setX((this.max.getX() - center.getX()) * scale + center.getX());
this.max.setY((this.max.getY() - center.getY()) * scale + center.getY());
this.max.setZ((this.max.getZ() - center.getZ()) * scale + center.getZ());
return this;
}
代码示例来源:origin: bergerkiller/BKCommonLib
public static Vector lerp(Vector vec1, Vector vec2, double stage) {
Vector newvec = new Vector();
newvec.setX(lerp(vec1.getX(), vec2.getX(), stage));
newvec.setY(lerp(vec1.getY(), vec2.getY(), stage));
newvec.setZ(lerp(vec1.getZ(), vec2.getZ(), stage));
return newvec;
}
内容来源于网络,如有侵权,请联系作者删除!