mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 04:38:35 +00:00
Too lazy to write a commit message
This commit is contained in:
@ -29,7 +29,7 @@ import java.util.Comparator;
|
||||
/**
|
||||
* An immutable 3-dimensional vector.
|
||||
*/
|
||||
public class BlockVector3 {
|
||||
public final class BlockVector3 {
|
||||
|
||||
public static final BlockVector3 ZERO = new BlockVector3(0, 0, 0);
|
||||
public static final BlockVector3 UNIT_X = new BlockVector3(1, 0, 0);
|
||||
@ -641,4 +641,4 @@ public class BlockVector3 {
|
||||
return "(" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import java.util.Comparator;
|
||||
/**
|
||||
* An immutable 3-dimensional vector.
|
||||
*/
|
||||
public class Vector3 {
|
||||
public final class Vector3 {
|
||||
|
||||
public static final Vector3 ZERO = new Vector3(0, 0, 0);
|
||||
public static final Vector3 UNIT_X = new Vector3(1, 0, 0);
|
||||
@ -40,6 +40,21 @@ public class Vector3 {
|
||||
public static final Vector3 ONE = new Vector3(1, 1, 1);
|
||||
|
||||
public static Vector3 at(double x, double y, double z) {
|
||||
// switch for efficiency on typical cases
|
||||
// in MC y is rarely 0/1 on selections
|
||||
int yTrunc = (int) y;
|
||||
switch (yTrunc) {
|
||||
case 0:
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (x == 1 && y == 1 && z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
@ -622,26 +637,26 @@ public class Vector3 {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (!(obj instanceof Vector3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 other = (Vector3) obj;
|
||||
return other.getX() == this.getX() && other.getZ() == this.getZ() && other.getY() == this.getY();
|
||||
return other.x == this.x && other.y == this.y && other.z == this.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30);
|
||||
int hash = 17;
|
||||
hash = 31 * hash + Double.hashCode(x);
|
||||
hash = 31 * hash + Double.hashCode(y);
|
||||
hash = 31 * hash + Double.hashCode(z);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX());
|
||||
String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY());
|
||||
String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ());
|
||||
return "(" + x + ", " + y + ", " + z + ")";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user