mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 06:48:34 +00:00
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.math;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
|
||||
import java.util.Comparator;
|
||||
@ -47,26 +48,18 @@ public class BlockVector2 {
|
||||
* cdef
|
||||
* </pre>
|
||||
*/
|
||||
public static final Comparator<BlockVector2> COMPARING_GRID_ARRANGEMENT =
|
||||
Comparator.comparingInt(BlockVector2::getZ).thenComparingInt(BlockVector2::getX);
|
||||
public static final Comparator<BlockVector2> COMPARING_GRID_ARRANGEMENT = (a, b) -> {
|
||||
return ComparisonChain.start()
|
||||
.compare(a.getBlockZ(), b.getBlockZ())
|
||||
.compare(a.getBlockX(), b.getBlockX())
|
||||
.result();
|
||||
};
|
||||
|
||||
public static BlockVector2 at(double x, double z) {
|
||||
return at((int) Math.floor(x), (int) Math.floor(z));
|
||||
}
|
||||
|
||||
public static BlockVector2 at(int x, int z) {
|
||||
switch (x) {
|
||||
case 0:
|
||||
if (z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new BlockVector2(x, z);
|
||||
}
|
||||
|
||||
@ -349,27 +342,6 @@ public class BlockVector2 {
|
||||
return divide(n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components right.
|
||||
*
|
||||
* @param x the value to shift x by
|
||||
* @param z the value to shift z by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector2 shr(int x, int z) {
|
||||
return at(this.x >> x, this.z >> z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift all components right by {@code n}.
|
||||
*
|
||||
* @param n the value to shift by
|
||||
* @return a new vector
|
||||
*/
|
||||
public BlockVector2 shr(int n) {
|
||||
return shr(n, n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the vector.
|
||||
*
|
||||
@ -519,8 +491,8 @@ public class BlockVector2 {
|
||||
*/
|
||||
public BlockVector2 getMinimum(BlockVector2 v2) {
|
||||
return new BlockVector2(
|
||||
Math.min(x, v2.x),
|
||||
Math.min(z, v2.z)
|
||||
Math.min(x, v2.x),
|
||||
Math.min(z, v2.z)
|
||||
);
|
||||
}
|
||||
|
||||
@ -532,8 +504,8 @@ public class BlockVector2 {
|
||||
*/
|
||||
public BlockVector2 getMaximum(BlockVector2 v2) {
|
||||
return new BlockVector2(
|
||||
Math.max(x, v2.x),
|
||||
Math.max(z, v2.z)
|
||||
Math.max(x, v2.x),
|
||||
Math.max(z, v2.z)
|
||||
);
|
||||
}
|
||||
|
||||
@ -599,4 +571,5 @@ public class BlockVector2 {
|
||||
public String toString() {
|
||||
return "(" + x + ", " + z + ")";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -44,20 +44,6 @@ public class BlockVector3 {
|
||||
}
|
||||
|
||||
public static BlockVector3 at(int x, int y, int z) {
|
||||
// switch for efficiency on typical cases
|
||||
// in MC y is rarely 0/1 on selections
|
||||
switch (y) {
|
||||
case 0:
|
||||
if (x == 0 && z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (x == 1 && z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new BlockVector3(x, y, z);
|
||||
}
|
||||
|
||||
|
@ -33,19 +33,6 @@ public class Vector2 {
|
||||
public static final Vector2 ONE = new Vector2(1, 1);
|
||||
|
||||
public static Vector2 at(double x, double z) {
|
||||
int xTrunc = (int) x;
|
||||
switch (xTrunc) {
|
||||
case 0:
|
||||
if (x == 0 && z == 0) {
|
||||
return ZERO;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (x == 1 && z == 1) {
|
||||
return ONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new Vector2(x, z);
|
||||
}
|
||||
|
||||
|
@ -39,21 +39,6 @@ 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);
|
||||
}
|
||||
|
||||
@ -651,9 +636,9 @@ public class Vector3 {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String x = "" + getX();
|
||||
String y = "" + getY();
|
||||
String z = "" + getZ();
|
||||
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