Annotate all the things

This commit is contained in:
FalsePattern committed 2022-08-06 13:12:55 +02:00
1 parent 980e8a8776
commit da1ef6c8c7
63 files changed
+623 -369

No files matched your search

@@ -33,8 +33,6 @@ import org.apache.logging.log4j.Logger;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Vec3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
@@ -53,6 +51,7 @@ public class BlockPos extends Vec3i {
/**
* An immutable block pos with zero as all coordinates.
*/
@StableAPI.Expose
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
private static final Logger LOGGER = LogManager.getLogger();
private static final int NUM_X_BITS = 1 + MathUtil.log2(MathUtil.smallestEncompassingPowerOfTwo(30000000));
@@ -64,22 +63,27 @@ public class BlockPos extends Vec3i {
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
@StableAPI.Expose
public BlockPos(@NonNull Entity source) {
this(source.posX, source.posY, source.posZ);
}
@StableAPI.Expose
public BlockPos(double x, double y, double z) {
super(x, y, z);
}
@StableAPI.Expose
public BlockPos(@NonNull Vec3 vec) {
this(vec.xCoord, vec.yCoord, vec.zCoord);
}
@StableAPI.Expose
public BlockPos(@NonNull Vec3i source) {
this(source.getX(), source.getY(), source.getZ());
}
@StableAPI.Expose
public BlockPos(int x, int y, int z) {
super(x, y, z);
}
@@ -87,6 +91,7 @@ public class BlockPos extends Vec3i {
/**
* Create a BlockPos from a serialized long value (created by toLong)
*/
@StableAPI.Expose
public static BlockPos fromLong(long serialized) {
return new BlockPos((int) (serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS),
(int) (serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS),
@@ -99,13 +104,14 @@ public class BlockPos extends Vec3i {
* <p>
* In situations where it is usable, prefer
* {@link #getAllInBoxMutable(BlockPos, BlockPos) instead as it has better performance (fewer allocations)
*
* <p>
* @param from One corner of the box
* @param to Another corner of the box
*
* <p>
* @see #getAllInBox(int, int, int, int, int, int)
* @see #getAllInBoxMutable(BlockPos, BlockPos)
*/
@StableAPI.Expose
public static Iterable<BlockPos> getAllInBox(@NonNull BlockPos from, @NonNull BlockPos to) {
return getAllInBox(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()),
Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()),
@@ -118,17 +124,18 @@ public class BlockPos extends Vec3i {
* <p>
* In situations where it is usable, prefer
* {@link #getAllInBoxMutable(BlockPos, BlockPos) instead as it has better performance (fewer allocations)
*
* <p>
* @param x0 The lower x coordinate
* @param y0 The lower y coordinate
* @param z0 The lower z coordinate
* @param x1 The upper x coordinate
* @param y1 The upper y coordinate
* @param z1 The upper z coordinate
*
* <p>
* @see #getAllInBox(BlockPos, BlockPos)
* @see #getAllInBoxMutable(BlockPos, BlockPos)
*/
@StableAPI.Expose
public static Iterable<BlockPos> getAllInBox(final int x0, final int y0, final int z0, final int x1, final int y1, final int z1) {
return () -> new AbstractIterator<BlockPos>() {
private boolean first = true;
@@ -179,6 +186,7 @@ public class BlockPos extends Vec3i {
* @see #getAllInBox(int, int, int, int, int, int)
* @see #getAllInBoxMutable(BlockPos, BlockPos)
*/
@StableAPI.Expose
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(@NonNull BlockPos from, @NonNull BlockPos to) {
return getAllInBoxMutable(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()),
Math.min(from.getZ(), to.getZ()), Math.max(from.getX(), to.getX()),
@@ -205,6 +213,7 @@ public class BlockPos extends Vec3i {
* @see #getAllInBox(int, int, int, int, int, int)
* @see #getAllInBoxMutable(BlockPos, BlockPos)
*/
@StableAPI.Expose
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(final int x0, final int y0, final int z0, final int x1, final int y1, final int z1) {
return () -> new AbstractIterator<MutableBlockPos>() {
private MutableBlockPos pos;
@@ -233,6 +242,7 @@ public class BlockPos extends Vec3i {
};
}
@StableAPI.Expose
public long toLong() {
return ((long) x & X_MASK) << X_SHIFT | ((long) y & Y_MASK) << Y_SHIFT | ((long) z & Z_MASK);
}
@@ -240,6 +250,7 @@ public class BlockPos extends Vec3i {
/**
* Add the given coordinates to the coordinates of this BlockPos
*/
@StableAPI.Expose
public BlockPos add(double x, double y, double z) {
if (x == 0.0D && y == 0.0D && z == 0.0D) {
return this;
@@ -250,6 +261,7 @@ public class BlockPos extends Vec3i {
/**
* Add the given Vector to this BlockPos
*/
@StableAPI.Expose
public BlockPos add(@NonNull Vec3i vec) {
return add(vec.getX(), vec.getY(), vec.getZ());
}
@@ -257,6 +269,7 @@ public class BlockPos extends Vec3i {
/**
* Add the given coordinates to the coordinates of this BlockPos
*/
@StableAPI.Expose
public BlockPos add(int x, int y, int z) {
if (x == 0 && y == 0 && z == 0) {
return this;
@@ -267,18 +280,22 @@ public class BlockPos extends Vec3i {
/**
* Subtract the given Vector from this BlockPos
*/
@StableAPI.Expose
public BlockPos subtract(@NonNull Vec3i vec) {
return add(-vec.getX(), -vec.getY(), -vec.getZ());
}
@StableAPI.Expose
public BlockPos up() {
return up(1);
}
@StableAPI.Expose
public BlockPos up(int blocks) {
return offset(UP, blocks);
}
@StableAPI.Expose
public BlockPos offset(@NonNull EnumFacing facing, int blocks) {
if (blocks == 0) {
return this;
@@ -287,50 +304,62 @@ public class BlockPos extends Vec3i {
z + facing.getFrontOffsetZ() * blocks);
}
@StableAPI.Expose
public BlockPos down() {
return down(1);
}
@StableAPI.Expose
public BlockPos down(int blocks) {
return offset(DOWN, blocks);
}
@StableAPI.Expose
public BlockPos north() {
return north(1);
}
@StableAPI.Expose
public BlockPos north(int blocks) {
return offset(NORTH, blocks);
}
@StableAPI.Expose
public BlockPos south() {
return south(1);
}
@StableAPI.Expose
public BlockPos south(int blocks) {
return offset(SOUTH, blocks);
}
@StableAPI.Expose
public BlockPos west() {
return west(1);
}
@StableAPI.Expose
public BlockPos west(int blocks) {
return offset(WEST, blocks);
}
@StableAPI.Expose
public BlockPos east() {
return east(1);
}
@StableAPI.Expose
public BlockPos east(int blocks) {
return offset(EAST, blocks);
}
@StableAPI.Expose
public BlockPos offset(@NonNull EnumFacing facing) {
return offset(facing, 1);
}
@StableAPI.Expose
public BlockPos rotate(@NonNull Rotation rotation) {
switch (rotation) {
case NONE:
@@ -351,12 +380,14 @@ public class BlockPos extends Vec3i {
x * vec.getY() - y * vec.getX());
}
@StableAPI.Expose
public BlockPos toImmutable() {
return this;
}
@Setter
@Getter
@Setter(onMethod_ = @StableAPI.Expose)
@Getter(onMethod_ = @StableAPI.Expose)
@StableAPI(since = "0.10.0")
public static class MutableBlockPos extends BlockPos {
/**
* Mutable X Coordinate
@@ -371,14 +402,17 @@ public class BlockPos extends Vec3i {
*/
protected int z;
@StableAPI.Expose
public MutableBlockPos() {
this(ORIGIN);
}
@StableAPI.Expose
public MutableBlockPos(@NonNull BlockPos blockPos) {
this(blockPos.getX(), blockPos.getY(), blockPos.getZ());
}
@StableAPI.Expose
public MutableBlockPos(int x, int y, int z) {
super(ORIGIN);
this.x = x;
@@ -406,19 +440,21 @@ public class BlockPos extends Vec3i {
return super.rotate(rotation).toImmutable();
}
@StableAPI.Expose
public BlockPos toImmutable() {
return new BlockPos(this);
}
@SideOnly(Side.CLIENT)
public BlockPos.MutableBlockPos setPos(@NonNull Entity entity) {
return this.setPos(entity.posX, entity.posY, entity.posZ);
}
@StableAPI.Expose
public BlockPos.MutableBlockPos setPos(double x, double y, double z) {
return setPos(MathUtil.floor(x), MathUtil.floor(y), MathUtil.floor(z));
}
@StableAPI.Expose
public BlockPos.MutableBlockPos setPos(int x, int y, int z) {
this.x = x;
this.y = y;
@@ -426,20 +462,24 @@ public class BlockPos extends Vec3i {
return this;
}
@StableAPI.Expose
public BlockPos.MutableBlockPos setPos(@NonNull Vec3i vec) {
return this.setPos(vec.getX(), vec.getY(), vec.getZ());
}
@StableAPI.Expose
public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing) {
return this.move(facing, 1);
}
@StableAPI.Expose
public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing, int blocks) {
return this.setPos(x + facing.getFrontOffsetX() * blocks, y + facing.getFrontOffsetY() * blocks,
z + facing.getFrontOffsetZ() * blocks);
}
}
@StableAPI(since = "0.10.0")
public static final class PooledMutableBlockPos extends BlockPos.MutableBlockPos {
private static final List<BlockPos.PooledMutableBlockPos> POOL = new ArrayList<>();
private boolean released;
@@ -448,10 +488,12 @@ public class BlockPos extends Vec3i {
super(x, y, z);
}
@StableAPI.Expose
public static BlockPos.PooledMutableBlockPos retain() {
return retain(0, 0, 0);
}
@StableAPI.Expose
public static BlockPos.PooledMutableBlockPos retain(int x, int y, int z) {
synchronized (POOL) {
if (!POOL.isEmpty()) {
@@ -466,15 +508,17 @@ public class BlockPos extends Vec3i {
return new BlockPos.PooledMutableBlockPos(x, y, z);
}
@StableAPI.Expose
public static BlockPos.PooledMutableBlockPos retain(double x, double y, double z) {
return retain(MathUtil.floor(x), MathUtil.floor(y), MathUtil.floor(z));
}
@SideOnly(Side.CLIENT)
@StableAPI.Expose
public static BlockPos.PooledMutableBlockPos retain(@NonNull Vec3i vec) {
return retain(vec.getX(), vec.getY(), vec.getZ());
}
@StableAPI.Expose
public void release() {
synchronized (POOL) {
if (POOL.size() < 100) {
@@ -485,7 +529,6 @@ public class BlockPos extends Vec3i {
}
@Override
@SideOnly(Side.CLIENT)
public BlockPos.PooledMutableBlockPos setPos(@NonNull Entity entity) {
return (BlockPos.PooledMutableBlockPos) super.setPos(entity);
}
@@ -41,10 +41,12 @@ public class ChunkPos {
/**
* The x position of the chunk.
*/
@StableAPI.Expose
public final int x;
/**
* The z position of the chunk.
*/
@StableAPI.Expose
public final int z;
/**
@@ -52,6 +54,7 @@ public class ChunkPos {
*
* @param blockPos the block pos
*/
@StableAPI.Expose
public ChunkPos(@NonNull BlockPos blockPos) {
x = blockPos.getX() >> 4;
z = blockPos.getZ() >> 4;
@@ -65,6 +68,7 @@ public class ChunkPos {
*
* @return the unique chunk long
*/
@StableAPI.Expose
public static long asLong(int x, int z) {
return (long) x & 0xFFFFFFFFL | ((long) z & 0xFFFFFFFFL) << 32;
}
@@ -76,6 +80,7 @@ public class ChunkPos {
*
* @return the distance sq
*/
@StableAPI.Expose
public double getDistanceSq(@NonNull Entity entity) {
val dX = ((x << 4) + 8) - entity.posX;
val dY = ((z << 4) + 8) - entity.posZ;
@@ -87,6 +92,7 @@ public class ChunkPos {
*
* @return the x start
*/
@StableAPI.Expose
public int getXStart() {
return x << 4;
}
@@ -96,6 +102,7 @@ public class ChunkPos {
*
* @return the z start
*/
@StableAPI.Expose
public int getZStart() {
return z << 4;
}
@@ -105,6 +112,7 @@ public class ChunkPos {
*
* @return the x end
*/
@StableAPI.Expose
public int getXEnd() {
return (x << 4) + 15;
}
@@ -114,6 +122,7 @@ public class ChunkPos {
*
* @return the z end
*/
@StableAPI.Expose
public int getZEnd() {
return (z << 4) + 15;
}
@@ -127,6 +136,7 @@ public class ChunkPos {
*
* @return the relative block position
*/
@StableAPI.Expose
public BlockPos getBlock(int x, int y, int z) {
return new BlockPos((this.x << 4) + x, y, (this.z << 4) + z);
}
@@ -49,26 +49,32 @@ public class GuiLabel extends Gui {
/**
* The id of the label.
*/
@StableAPI.Expose
public int id;
/**
* The x position of the label.
*/
@StableAPI.Expose
public int x;
/**
* The y position of the label.
*/
@StableAPI.Expose
public int y;
/**
* The visibility of the label.
*/
@StableAPI.Expose
public boolean visible = true;
/**
* The label width.
*/
@StableAPI.Expose
protected int width;
/**
* The label height.
*/
@StableAPI.Expose
protected int height;
private boolean centered = false;
@@ -83,6 +89,7 @@ public class GuiLabel extends Gui {
* @param height the height
* @param textColour the text colour
*/
@StableAPI.Expose
public GuiLabel(@NonNull FontRenderer fontRenderer, int id, int x, int y, int width, int height, int textColour) {
this.fontRenderer = fontRenderer;
this.id = id;
@@ -98,6 +105,7 @@ public class GuiLabel extends Gui {
*
* @param text string to add
*/
@StableAPI.Expose
public void addLine(@NonNull String text) {
lines.add(I18n.format(text));
}
@@ -107,6 +115,7 @@ public class GuiLabel extends Gui {
*
* @return the GuiLabel itself
*/
@StableAPI.Expose
public GuiLabel setCentered() {
centered = true;
return this;
@@ -120,6 +129,7 @@ public class GuiLabel extends Gui {
* @param mouseX the mouse x
* @param mouseY the mouse y
*/
@StableAPI.Expose
public void drawLabel(@NonNull Minecraft minecraft, int mouseX, int mouseY) {
if (!visible) {
return;
@@ -21,6 +21,7 @@
package com.falsepattern.lib.compat;
import com.falsepattern.lib.DeprecationDetails;
import com.falsepattern.lib.StableAPI;
import com.falsepattern.lib.util.MathUtil;
import java.util.Random;
@@ -30,6 +31,7 @@ import java.util.Random;
*/
@Deprecated
@DeprecationDetails(deprecatedSince = "0.10.0")
@StableAPI(since = "0.9.2")
public class MathHelper {
/**
* Though it looks like an array, this is really more like a mapping. Key (index of this array) is the upper 5 bits
@@ -54,6 +56,7 @@ public class MathHelper {
/**
* sin looked up in a table
*/
@StableAPI.Expose
public static float sin(float a) {
return SIN_TABLE[(int) (a * 10430.378F) & 65535];
}
@@ -61,14 +64,17 @@ public class MathHelper {
/**
* cos looked up in the sin table with the appropriate offset
*/
@StableAPI.Expose
public static float cos(float a) {
return SIN_TABLE[(int) (a * 10430.378F + 16384.0F) & 65535];
}
@StableAPI.Expose
public static float sqrt_float(float a) {
return (float) Math.sqrt(a);
}
@StableAPI.Expose
public static float sqrt_double(double a) {
return (float) Math.sqrt(a);
}
@@ -76,6 +82,7 @@ public class MathHelper {
/**
* Returns the greatest integer less than or equal to the float argument
*/
@StableAPI.Expose
public static int floor_float(float a) {
int i = (int) a;
return a < (float) i ? i - 1 : i;
@@ -84,6 +91,7 @@ public class MathHelper {
/**
* returns par0 cast as an int, and no greater than Integer.MAX_VALUE-1024
*/
@StableAPI.Expose
public static int truncateDoubleToInt(double a) {
return (int) (a + 1024.0D) - 1024;
}
@@ -91,6 +99,7 @@ public class MathHelper {
/**
* Returns the greatest integer less than or equal to the double argument
*/
@StableAPI.Expose
public static int floor_double(double a) {
int i = (int) a;
return a < (double) i ? i - 1 : i;
@@ -99,15 +108,18 @@ public class MathHelper {
/**
* Long version of floor_double
*/
@StableAPI.Expose
public static long floor_double_long(double a) {
long i = (long) a;
return a < (double) i ? i - 1L : i;
}
@StableAPI.Expose
public static int absFloor(double a) {
return (int) (a >= 0.0D ? a : -a + 1.0D);
}
@StableAPI.Expose
public static float abs(float a) {
return a >= 0.0F ? a : -a;
}
@@ -115,15 +127,18 @@ public class MathHelper {
/**
* Returns the unsigned value of an int.
*/
@StableAPI.Expose
public static int abs_int(int a) {
return a >= 0 ? a : -a;
}
@StableAPI.Expose
public static int ceiling_float_int(float a) {
int i = (int) a;
return a > (float) i ? i + 1 : i;
}
@StableAPI.Expose
public static int ceiling_double_int(double a) {
int i = (int) a;
return a > (double) i ? i + 1 : i;
@@ -133,6 +148,7 @@ public class MathHelper {
* Returns the value of the first parameter, clamped to be within the lower and upper limits given by the second and
* third parameters.
*/
@StableAPI.Expose
public static int clamp_int(int a, int min, int max) {
return a < min ? min : (Math.min(a, max));
}
@@ -141,14 +157,17 @@ public class MathHelper {
* Returns the value of the first parameter, clamped to be within the lower and upper limits given by the second and
* third parameters
*/
@StableAPI.Expose
public static float clamp_float(float a, float min, float max) {
return a < min ? min : Math.min(a, max);
}
@StableAPI.Expose
public static double clamp_double(double a, double min, double max) {
return a < min ? min : Math.min(a, max);
}
@StableAPI.Expose
public static double denormalizeClamp(double min, double max, double normalized) {
return normalized < 0.0D ? min : (normalized > 1.0D ? max : min + (max - min) * normalized);
}
@@ -156,6 +175,7 @@ public class MathHelper {
/**
* Maximum of the absolute value of two numbers.
*/
@StableAPI.Expose
public static double abs_max(double a, double b) {
if (a < 0.0D) {
a = -a;
@@ -171,6 +191,7 @@ public class MathHelper {
/**
* Buckets an integer with specified bucket sizes. Args: i, bucketSize
*/
@StableAPI.Expose
public static int bucketInt(int i, int bucketSize) {
return i < 0 ? -((-i - 1) / bucketSize) - 1 : i / bucketSize;
}
@@ -178,22 +199,27 @@ public class MathHelper {
/**
* Tests if a string is null or of length zero
*/
@StableAPI.Expose
public static boolean stringNullOrLengthZero(String str) {
return str == null || str.length() == 0;
}
@StableAPI.Expose
public static int getRandomIntegerInRange(Random rng, int min, int max) {
return min >= max ? min : rng.nextInt(max - min + 1) + min;
}
@StableAPI.Expose
public static float randomFloatClamp(Random rng, float min, float max) {
return min >= max ? min : rng.nextFloat() * (max - min) + min;
}
@StableAPI.Expose
public static double getRandomDoubleInRange(Random rng, double min, double max) {
return min >= max ? min : rng.nextDouble() * (max - min) + min;
}
@StableAPI.Expose
public static double average(long[] values) {
long i = 0L;
@@ -207,6 +233,7 @@ public class MathHelper {
/**
* the angle is reduced to an angle between -180 and +180 by mod, and a 360 check
*/
@StableAPI.Expose
public static float wrapAngleTo180_float(float angle) {
angle %= 360.0F;
@@ -224,6 +251,7 @@ public class MathHelper {
/**
* the angle is reduced to an angle between -180 and +180 by mod, and a 360 check
*/
@StableAPI.Expose
public static double wrapAngleTo180_double(double angle) {
angle %= 360.0D;
@@ -241,6 +269,7 @@ public class MathHelper {
/**
* parses the string as integer or returns the second parameter if it fails
*/
@StableAPI.Expose
public static int parseIntWithDefault(String str, int def) {
try {
return Integer.parseInt(str);
@@ -252,6 +281,7 @@ public class MathHelper {
/**
* parses the string as integer or returns the second parameter if it fails. this value is capped to par2
*/
@StableAPI.Expose
public static int parseIntWithDefaultAndMax(String str, int def, int min) {
int k;
@@ -271,6 +301,7 @@ public class MathHelper {
/**
* parses the string as double or returns the second parameter if it fails.
*/
@StableAPI.Expose
public static double parseDoubleWithDefault(String str, double def) {
double d1 = def;
@@ -282,6 +313,7 @@ public class MathHelper {
return d1;
}
@StableAPI.Expose
public static double parseDoubleWithDefaultAndMin(String str, double def, double min) {
double d2;
@@ -301,6 +333,7 @@ public class MathHelper {
/**
* Returns the input value rounded up to the next highest power of two.
*/
@StableAPI.Expose
public static int roundUpToPowerOfTwo(int a) {
int j = a - 1;
j |= j >> 1;
@@ -332,6 +365,7 @@ public class MathHelper {
* Efficiently calculates the floor of the base-2 log of an integer value. This is effectively the index of the
* highest bit that is set. For example, if the number in binary is 0...100101, this will return 5.
*/
@StableAPI.Expose
public static int calculateLogBaseTwo(int a) {
/*
* Uses a B(2, 5) De Bruijn sequence and a lookup table to efficiently calculate the log-base-two of the given
@@ -341,6 +375,7 @@ public class MathHelper {
return calculateLogBaseTwoDeBruijn(a) - (isPowerOfTwo(a) ? 0 : 1);
}
@StableAPI.Expose
public static int roundUp(int a, int b) {
if (b == 0) {
return 0;
@@ -28,16 +28,22 @@ import net.minecraft.util.EnumFacing;
@StableAPI(since = "0.6.0")
public enum Rotation {
@StableAPI.Expose
NONE,
@StableAPI.Expose
CLOCKWISE_90,
@StableAPI.Expose
CLOCKWISE_180,
@StableAPI.Expose
COUNTERCLOCKWISE_90;
@StableAPI.Expose
public Rotation add(@NonNull Rotation rotation) {
val values = Rotation.values();
return values[(ordinal() + rotation.ordinal()) % values.length];
}
@StableAPI.Expose
public EnumFacing rotate(@NonNull EnumFacing facing) {
if (facing == EnumFacing.UP || facing == EnumFacing.DOWN) {
return facing;
@@ -87,6 +93,7 @@ public enum Rotation {
}
}
@StableAPI.Expose
public int rotate(int x, int z) {
switch (this) {
case CLOCKWISE_90:
@@ -42,10 +42,14 @@ public class Vec3i implements Comparable<Vec3i> {
/**
* A static zero vector
*/
@StableAPI.Expose
public static final Vec3i NULL_VECTOR = new Vec3i(0, 0, 0);
@StableAPI.Expose
protected final int x;
@StableAPI.Expose
protected final int y;
@StableAPI.Expose
protected final int z;
/**
@@ -55,10 +59,12 @@ public class Vec3i implements Comparable<Vec3i> {
* @param y the y
* @param z the z
*/
@StableAPI.Expose
public Vec3i(double x, double y, double z) {
this(MathUtil.floor(x), MathUtil.floor(y), MathUtil.floor(z));
}
@Override
public int compareTo(@NonNull Vec3i vec) {
return y == vec.getY() ? z == vec.getZ() ? x - vec.getX() : z - vec.getZ() : y - vec.getY();
}
@@ -70,6 +76,7 @@ public class Vec3i implements Comparable<Vec3i> {
*
* @return the new resulting vector
*/
@StableAPI.Expose
public Vec3i crossProduct(@NonNull Vec3i vec) {
return new Vec3i(y * vec.getZ() - z * vec.getY(), z * vec.getX() - x * vec.getZ(),
x * vec.getY() - y * vec.getX());
@@ -84,6 +91,7 @@ public class Vec3i implements Comparable<Vec3i> {
*
* @return the distance
*/
@StableAPI.Expose
public double getDistance(int x, int y, int z) {
return Math.sqrt(distanceSq(x, y, z));
}
@@ -97,6 +105,7 @@ public class Vec3i implements Comparable<Vec3i> {
*
* @return the square distance
*/
@StableAPI.Expose
public double distanceSq(int x, int y, int z) {
val dX = this.x - x;
val dY = this.y - y;
@@ -111,6 +120,7 @@ public class Vec3i implements Comparable<Vec3i> {
*
* @return the square distance
*/
@StableAPI.Expose
public double distanceSq(@NonNull Vec3i vec) {
return distanceSq(vec.getX(), vec.getY(), vec.getZ());
}
@@ -124,6 +134,7 @@ public class Vec3i implements Comparable<Vec3i> {
*
* @return the square distance to center
*/
@StableAPI.Expose
public double distanceSqToCenter(double x, double y, double z) {
val dX = this.x + 0.5D - x;
val dY = this.y + 0.5D - y;