本文整理了Java中org.bukkit.util.Vector.<init>()
方法的一些代码示例,展示了Vector.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.<init>()
方法的具体详情如下:
包路径:org.bukkit.util.Vector
类名称:Vector
方法名:<init>
[英]Construct the vector with all components as 0.
[中]构造向量,使所有组件都为0。
代码示例来源:origin: Bukkit/Bukkit
/**
* Constructs a new {@link Vector} based on this Location
*
* @return New Vector containing the coordinates represented by this
* Location
*/
public Vector toVector() {
return new Vector(x, y, z);
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Gets a new midpoint vector between this vector and another.
*
* @param other The other vector
* @return a new midpoint vector
*/
public Vector getMidpoint(Vector other) {
double x = (this.x + other.x) / 2;
double y = (this.y + other.y) / 2;
double z = (this.z + other.z) / 2;
return new Vector(x, y, z);
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public Vector getSize() {
return new Vector(1, 1, 1);
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public Vector getSize() {
return new Vector(width, vertSize, depth);
}
代码示例来源:origin: GlowstoneMC/Glowstone
public GlowJungleTemple(Random random, Location location) {
super(random, location, new Vector(12, 14, 15));
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Gets the minimum components of two vectors.
*
* @param v1 The first vector.
* @param v2 The second vector.
* @return minimum
*/
public static Vector getMinimum(Vector v1, Vector v2) {
return new Vector(Math.min(v1.x, v2.x), Math.min(v1.y, v2.y), Math.min(v1.z, v2.z));
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Gets the maximum components of two vectors.
*
* @param v1 The first vector.
* @param v2 The second vector.
* @return maximum
*/
public static Vector getMaximum(Vector v1, Vector v2) {
return new Vector(Math.max(v1.x, v2.x), Math.max(v1.y, v2.y), Math.max(v1.z, v2.z));
}
代码示例来源:origin: Bukkit/Bukkit
/**
* Gets a random vector with components having a random value between 0
* and 1.
*
* @return A random vector.
*/
public static Vector getRandom() {
return new Vector(random.nextDouble(), random.nextDouble(), random.nextDouble());
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public boolean canPlace(int baseX, int baseY, int baseZ, World world) {
Vector from = new Vector(baseX, baseY, baseZ);
Vector to = new Vector(baseX, baseY + height - 1, baseZ);
int blocks = countAvailableBlocks(from, to, world);
if (blocks == -1) {
return true;
} else if (blocks > 5) {
height = blocks;
return true;
}
return false;
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Updates the structure's bounding box to be the bounding box of the union of its pieces.
*/
public void wrapAllPieces() {
boundingBox = new StructureBoundingBox(
new Vector(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
new Vector(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE));
children.stream().filter(Objects::nonNull)
.forEach(piece -> boundingBox.expandTo(piece.getBoundingBox()));
}
代码示例来源:origin: Bukkit/Bukkit
public static Vector deserialize(Map<String, Object> args) {
double x = 0;
double y = 0;
double z = 0;
if (args.containsKey("x")) {
x = (Double) args.get("x");
}
if (args.containsKey("y")) {
y = (Double) args.get("y");
}
if (args.containsKey("z")) {
z = (Double) args.get("z");
}
return new Vector(x, y, z);
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public List<Entity> getNearbyEntities(double x, double y, double z) {
// This behavior is similar to CraftBukkit, where a call with args
// (0, 0, 0) finds any entities whose bounding boxes intersect that of
// this entity.
BoundingBox searchBox = BoundingBox
.fromPositionAndSize(location.toVector(), new Vector(0, 0, 0));
Vector vec = new Vector(x, y, z);
Vector vec2 = new Vector(0, 0.5 * y, 0);
searchBox.minCorner.subtract(vec).add(vec2);
searchBox.maxCorner.add(vec).add(vec2);
return world.getEntityManager().getEntitiesInside(searchBox, this);
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void setOnGround(boolean onGround) {
super.setOnGround(onGround);
if (onGround) {
setLife((short) 0); // Despawn timer only starts when we stick in a block
setVelocity(new Vector(0, 0, 0));
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a minecart.
*
* @param location the location
* @param minecartType the minecart type (i.e. the type of block carried, if any)
*/
public GlowMinecart(Location location, MinecartType minecartType) {
super(location);
setSize(0.98f, 0.7f);
setAirDrag(0.95);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
this.minecartType = minecartType;
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates an arrow entity.
*
* @param location the initial location
*/
public GlowArrow(Location location) {
super(location);
setGravityAccel(new Vector(0, -0.05, 0));
setAirDrag(0.99);
setApplyDragBeforeAccel(true);
setBoundingBox(0.5, 0.5);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a boat.
*
* @param location the boat's location
*/
public GlowBoat(Location location) {
super(location);
setSize(1.375f, 0.5625f);
setAirDrag(0.95);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
setWoodType(TreeSpecies.GENERIC);
}
代码示例来源:origin: GlowstoneMC/Glowstone
private void createNewBoundingBox(Location location, Vector size) {
Vector min = new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ());
Vector max = new Vector(location.getBlockX() + size.getBlockX() - 1,
location.getBlockY() + size.getBlockY() - 1,
location.getBlockZ() + size.getBlockZ() - 1);
boundingBox = new StructureBoundingBox(min, max);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Returns the position where an item will emerge from the dispenser.
* @param block a dispenser block
* @return the position as a Vector
*/
public static Vector getDispensePosition(GlowBlock block) {
BlockFace facing = getFacing(block);
double x = block.getX() + 0.7 * facing.getModX();
double y = block.getY() + 0.7 * facing.getModY();
double z = block.getZ() + 0.7 * facing.getModZ();
return new Vector(x, y, z);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a thrown egg with default speed.
*
* @param location the position and facing of the thrower
*/
public GlowEgg(Location location) {
super(location);
setAirDrag(0.99);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
setApplyDragBeforeAccel(true);
setVelocity(location.getDirection().multiply(3));
setBoundingBox(0.25, 0.25);
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a thrown snowball with default speed.
*
* @param location the position and facing of the thrower
*/
public GlowSnowball(Location location) {
super(location);
setAirDrag(0.99);
setGravityAccel(new Vector(0, VERTICAL_GRAVITY_ACCEL, 0));
setApplyDragBeforeAccel(true);
setVelocity(location.getDirection().multiply(3));
setBoundingBox(0.25, 0.25);
}
内容来源于网络,如有侵权,请联系作者删除!