This commit is contained in:
dfsek
2021-12-14 11:01:28 -07:00
parent bf5e7f589d
commit 58acca3078
147 changed files with 414 additions and 479 deletions

View File

@@ -80,7 +80,7 @@ public final class Either<L, R> {
@Override
public boolean equals(Object obj) {
if(!(obj instanceof Either<?, ?> that)) return false;
return (this.leftPresent && that.leftPresent && Objects.equals(this.left, that.left))
|| (!this.leftPresent && !that.leftPresent && Objects.equals(this.right, that.right));
}

View File

@@ -56,7 +56,7 @@ public final class Pair<L, R> {
@Override
public boolean equals(Object obj) {
if(!(obj instanceof Pair<?, ?> that)) return false;
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
}
@@ -104,7 +104,7 @@ public final class Pair<L, R> {
@Override
public boolean equals(Object obj) {
if(!(obj instanceof Mutable<?, ?> that)) return false;
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
}
}

View File

@@ -42,7 +42,7 @@ public class TypeKey<T> {
if(!(b instanceof ParameterizedType pb)) {
return false;
}
return Objects.equals(pa.getOwnerType(), pb.getOwnerType())
&& pa.getRawType().equals(pb.getRawType())
&& Arrays.equals(pa.getActualTypeArguments(), pb.getActualTypeArguments());
@@ -50,13 +50,13 @@ public class TypeKey<T> {
if(!(b instanceof GenericArrayType gb)) {
return false;
}
return equals(ga.getGenericComponentType(), gb.getGenericComponentType());
} else if(a instanceof WildcardType wa) {
if(!(b instanceof WildcardType wb)) {
return false;
}
return Arrays.equals(wa.getUpperBounds(), wb.getUpperBounds())
&& Arrays.equals(wa.getLowerBounds(), wb.getLowerBounds());
} else if(a instanceof TypeVariable<?> va) {

View File

@@ -7,11 +7,10 @@ import com.dfsek.terra.api.util.Rotation;
* oh yeah
*/
public class Vector2Int {
private final int x;
private final int z;
private static final Vector2Int ZERO = new Vector2Int(0, 0);
private static final Vector2Int UNIT = new Vector2Int(0, 1);
private final int x;
private final int z;
protected Vector2Int(int x, int z) {
this.x = x;
@@ -62,19 +61,19 @@ public class Vector2Int {
this.x = x;
this.z = z;
}
public int getZ() {
return z;
}
public int getX() {
return x;
}
public void setZ(int z) {
this.z = z;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}

View File

@@ -1,10 +1,9 @@
package com.dfsek.terra.api.util.vector.integer;
public class Vector3Int {
private final int x, y, z;
private static final Vector3Int ZERO = new Vector3Int(0, 0, 0);
private static final Vector3Int UNIT = new Vector3Int(0, 1, 0);
private final int x, y, z;
protected Vector3Int(int x, int y, int z) {
this.x = x;
@@ -12,6 +11,18 @@ public class Vector3Int {
this.z = z;
}
public static Vector3Int unit() {
return UNIT;
}
public static Vector3Int zero() {
return ZERO;
}
public static Vector3Int of(int x, int y, int z) {
return new Vector3Int(x, y, z);
}
public int getX() {
return x;
}
@@ -28,18 +39,7 @@ public class Vector3Int {
return new Mutable(x, y, z);
}
public static Vector3Int unit() {
return UNIT;
}
public static Vector3Int zero() {
return ZERO;
}
public static Vector3Int of(int x, int y, int z) {
return new Vector3Int(x, y, z);
}
public static class Mutable {
private int x, y, z;
@@ -48,31 +48,31 @@ public class Vector3Int {
this.y = y;
this.z = z;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public void setZ(int z) {
this.z = z;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getZ() {
return z;
}
public void setZ(int z) {
this.z = z;
}
public Vector3Int immutable() {
return Vector3Int.of(x, y, z);
}