/** * Gets the size of the box. * * @return The size */ public Vector3d getSize() { if (this.size == null) { this.size = this.max.sub(this.min); } return this.size; }
/** * Subtract vector components to the position on this instance, returning a * new Location instance. * * @param x The x component * @param y The y component * @param z The z component * @return A new instance */ public Location<E> sub(double x, double y, double z) { return setPosition(getPosition().sub(x, y, z)); }
/** * Expands this bounding box by a given amount in both directions and * returns a new box. The expansion is applied half and half to the * minimum and maximum corners. * * @param x The amount of expansion for the x coordinate * @param y The amount of expansion for the y coordinate * @param z The amount of expansion for the z coordinate * @return The new expanded box */ public AABB expand(double x, double y, double z) { x /= 2; y /= 2; z /= 2; return new AABB(this.min.sub(x, y, z), this.max.add(x, y, z)); }
/** * Sets the direction and ending location. This or setting the direction * is required and can only be done once. * * @param end The ending location * @return This for chained calls */ public BlockRayBuilder<E> to(Vector3d end) { checkState(this.direction == null, "Direction has already been set"); checkNotNull(end, "end"); checkArgument(!this.position.equals(end), "Start and end cannot be equal"); this.direction = end.sub(this.position).normalize(); return stopFilter(new TargetBlockFilter<>(end)); }
/** * Returns whether the given vector is along this axis. * * @param vector The vector to test * @return True if it is along this axis */ public boolean isVectorAlongAxis(final Vector3d vector) { return vector.abs().normalize().sub(this.direction).lengthSquared() == 0; }
private static AABB newIntersectingAABB(AABB with) { final Vector3d wMin = with.getMin(); final Vector3d wSize = with.getSize(); final double iSizeX = RANDOM.nextDouble() * wSize.getX(); final double iSizeY = RANDOM.nextDouble() * wSize.getY(); final double iSizeZ = RANDOM.nextDouble() * wSize.getZ(); final double eSizeX = RANDOM.nextDouble() * 4 + 4; final double eSizeY = RANDOM.nextDouble() * 4 + 4; final double eSizeZ = RANDOM.nextDouble() * 4 + 4; final Vector3d min = wMin.sub(eSizeX, eSizeY, eSizeZ); final Vector3d max = wMin.add(iSizeX, iSizeY, iSizeZ); return new AABB(min, max); }
/** * Gets the size of the box. * * @return The size */ public Vector3d getSize() { if (this.size == null) { this.size = this.max.sub(this.min); } return this.size; }
public Vector3d sub(float x, float y, float z) { return sub((double) x, (double) y, (double) z); }
public Vector3d sub(Vector3d v) { return sub(v.x, v.y, v.z); }
public Vector3d sub(float x, float y, float z) { return sub((double) x, (double) y, (double) z); }
public Vector3d sub(Vector3d v) { return sub(v.x, v.y, v.z); }
public VectorPoint subtract(double x, double y, double z) { return of(this.position.sub(x, y, z), this.direction); }
public VectorPoint subtract(double x, double y, double z) { return of(this.position.sub(x, y, z), this.direction); }
/** * Subtract vector components to the position on this instance, returning a * new Location instance. * * @param x The x component * @param y The y component * @param z The z component * @return A new instance */ public Location<E> sub(double x, double y, double z) { return setPosition(getPosition().sub(x, y, z)); }
/** * Expands this bounding box by a given amount in both directions and * returns a new box. The expansion is applied half and half to the * minimum and maximum corners. * * @param x The amount of expansion for the x coordinate * @param y The amount of expansion for the y coordinate * @param z The amount of expansion for the z coordinate * @return The new expanded box */ public AABB expand(double x, double y, double z) { x /= 2; y /= 2; z /= 2; return new AABB(this.min.sub(x, y, z), this.max.add(x, y, z)); }
/** * Sets the direction and ending location. This or setting the direction is required and can only be done once. * * @param end The ending location * @return This for chained calls */ public BlockRayBuilder<E> to(Vector3d end) { checkState(this.direction == null, "Direction has already been set"); checkNotNull(end, "end"); checkArgument(!this.position.equals(end), "Start and end cannot be equal"); this.direction = end.sub(this.position).normalize(); return stopFilter(new TargetBlockFilter<>(end)); }
/** * Returns whether the given vector is along this axis. * * @param vector The vector to test * @return True if it is along this axis */ public boolean isVectorAlongAxis(final Vector3d vector) { return vector.abs().normalize().sub(this.direction).lengthSquared() == 0; }
private void doFireball(final SnipeData v) { Player pl = v.owner().getPlayer(); Vector3d target = this.targetBlock.getPosition().sub(pl.getLocation().getPosition().add(0, 1.72, 0)); pl.launchProjectile(SmallFireball.class, target.normalize()); }
private void doLargeFireball(final SnipeData v) { Player pl = v.owner().getPlayer(); Vector3d target = this.targetBlock.getPosition().sub(pl.getLocation().getPosition().add(0, 1.72, 0)); pl.launchProjectile(LargeFireball.class, target.normalize()); }