reformat code

This commit is contained in:
dfsek
2022-05-26 19:40:41 -07:00
parent 49857f6b91
commit ee373bbe4b
63 changed files with 214 additions and 242 deletions

View File

@@ -105,7 +105,7 @@ public class BinaryColumn {
int smallMaxY = Math.min(this.maxY, that.maxY);
if(bigMinY >= smallMaxY) return getNull();
return new BinaryColumn(bigMinY, smallMaxY, y -> this.get(y) && that.get(y));
}

View File

@@ -131,35 +131,35 @@ public class Vector2 {
return "(" + x + ", " + z + ")";
}
public static class Mutable extends Vector2 {
private Mutable(double x, double z) {
super(x, z);
}
public double getX() {
return x;
}
public Mutable setX(double x) {
this.x = x;
return this;
}
public double getZ() {
return z;
}
public Mutable setZ(double z) {
this.z = z;
return this;
}
public Vector2 immutable() {
return Vector2.of(x, z);
}
/**
* Get the length of this Vector
*
@@ -168,7 +168,7 @@ public class Vector2 {
public double length() {
return FastMath.sqrt(lengthSquared());
}
/**
* Get the squared length of this Vector
*
@@ -177,13 +177,13 @@ public class Vector2 {
public double lengthSquared() {
return x * x + z * z;
}
public Mutable add(double x, double z) {
this.x += x;
this.z += z;
return this;
}
/**
* Multiply X and Z components by a value.
*
@@ -196,7 +196,7 @@ public class Vector2 {
z *= m;
return this;
}
/**
* Add this vector to another.
*
@@ -209,7 +209,7 @@ public class Vector2 {
z += other.getZ();
return this;
}
/**
* Subtract a vector from this vector,
*
@@ -222,7 +222,7 @@ public class Vector2 {
z -= other.getZ();
return this;
}
/**
* Normalize this vector to length 1
*
@@ -232,7 +232,7 @@ public class Vector2 {
divide(length());
return this;
}
/**
* Divide X and Z components by a value.
*

View File

@@ -91,7 +91,7 @@ public class Vector3 {
public double getY() {
return y;
}
public int getBlockX() {
return FastMath.floorToInt(x);
@@ -155,70 +155,70 @@ public class Vector3 {
return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
}
public static class Mutable extends Vector3 {
private Mutable(double x, double y, double z) {
super(x, y, z);
}
public static Mutable of(double x, double y, double z) {
return new Mutable(x, y, z);
}
public Vector3 immutable() {
return Vector3.of(x, y, z);
}
public double getZ() {
return z;
}
public Mutable setZ(double z) {
this.z = z;
return this;
}
public double getX() {
return x;
}
public Mutable setX(double x) {
this.x = x;
return this;
}
public double getY() {
return y;
}
public Mutable setY(double y) {
this.y = y;
return this;
}
public double lengthSquared() {
return x * x + y * y + z * z;
}
public double length() {
return FastMath.sqrt(lengthSquared());
}
public double inverseLength() {
return FastMath.invSqrtQuick(lengthSquared());
}
public Mutable normalize() {
return this.multiply(this.inverseLength());
}
public Mutable subtract(int x, int y, int z) {
this.x -= x;
this.y -= y;
this.z -= z;
return this;
}
/**
* Calculates the dot product of this vector with another. The dot product
* is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar.
@@ -230,48 +230,48 @@ public class Vector3 {
public double dot(@NotNull Vector3 other) {
return x * other.getX() + y * other.getY() + z * other.getZ();
}
public Mutable subtract(Vector3 end) {
x -= end.getX();
y -= end.getY();
z -= end.getZ();
return this;
}
public Mutable multiply(double m) {
x *= m;
y *= m;
z *= m;
return this;
}
public Mutable add(double x, double y, double z) {
this.x += x;
this.y += y;
this.z += z;
return this;
}
public Mutable add(Vector3 other) {
this.x += other.getX();
this.y += other.getY();
this.z += other.getZ();
return this;
}
public Mutable add(Vector3Int other) {
this.x += other.getX();
this.y += other.getY();
this.z += other.getZ();
return this;
}
public Mutable add(Vector2 other) {
this.x += other.getX();
this.z += other.getZ();
return this;
}
/**
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
*
@@ -297,7 +297,7 @@ public class Vector3 {
public Mutable rotateAroundAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
return rotateAroundNonUnitAxis(axis.isNormalized() ? axis : axis.mutable().normalize().immutable(), angle);
}
/**
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
*
@@ -322,11 +322,11 @@ public class Vector3 {
public Mutable rotateAroundNonUnitAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
double x = getX(), y = getY(), z = getZ();
double x2 = axis.getX(), y2 = axis.getY(), z2 = axis.getZ();
double cosTheta = Math.cos(angle);
double sinTheta = Math.sin(angle);
double dotProduct = this.dot(axis);
double xPrime = x2 * dotProduct * (1d - cosTheta)
+ x * cosTheta
+ (-z2 * y + y2 * z) * sinTheta;
@@ -336,10 +336,10 @@ public class Vector3 {
double zPrime = z2 * dotProduct * (1d - cosTheta)
+ z * cosTheta
+ (-y2 * x + x2 * y) * sinTheta;
return setX(xPrime).setY(yPrime).setZ(zPrime);
}
/**
* Rotates the vector around the x axis.
* <p>
@@ -357,12 +357,12 @@ public class Vector3 {
public Mutable rotateAroundX(double angle) {
double angleCos = Math.cos(angle);
double angleSin = Math.sin(angle);
double y = angleCos * getY() - angleSin * getZ();
double z = angleSin * getY() + angleCos * getZ();
return setY(y).setZ(z);
}
/**
* Rotates the vector around the y axis.
* <p>
@@ -380,12 +380,12 @@ public class Vector3 {
public Mutable rotateAroundY(double angle) {
double angleCos = Math.cos(angle);
double angleSin = Math.sin(angle);
double x = angleCos * getX() + angleSin * getZ();
double z = -angleSin * getX() + angleCos * getZ();
return setX(x).setZ(z);
}
/**
* Rotates the vector around the z axis
* <p>
@@ -403,30 +403,30 @@ public class Vector3 {
public Mutable rotateAroundZ(double angle) {
double angleCos = Math.cos(angle);
double angleSin = Math.sin(angle);
double x = angleCos * getX() - angleSin * getY();
double y = angleSin * getX() + angleCos * getY();
return setX(x).setY(y);
}
@Override
public int hashCode() {
int hash = 13;
hash = 79 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
return hash;
}
public int getBlockX() {
return FastMath.floorToInt(x);
}
public int getBlockY() {
return FastMath.floorToInt(y);
}
public int getBlockZ() {
return FastMath.floorToInt(z);
}

View File

@@ -91,7 +91,7 @@ public class Vector3Int {
this.z += z;
return this;
}
public Vector3 toVector3() {
return Vector3.of(x, y, z);
}

View File

@@ -105,7 +105,7 @@ public class BufferedWorld implements WritableWorld {
return delegate;
}
public static final class Builder {
private final WritableWorld delegate;
private ReadInterceptor readInterceptor;

View File

@@ -72,20 +72,20 @@ public class Column<T extends WritableWorld> {
return (Column<T>) world.column(x + offsetX, z + offsetZ);
}
public static class BinaryColumnBuilder {
private final boolean[] arr;
private final Column<?> column;
public BinaryColumnBuilder(Column<?> column) {
this.column = column;
arr = new boolean[column.getMaxY() - column.getMinY()];
}
public BinaryColumn build() {
return new BinaryColumn(column.getMinY(), column.getMaxY(), arr);
}
public BinaryColumnBuilder set(int y) {
arr[y - column.getMinY()] = true;
return this;