Use TrigUtil for coordinate comparison.

This commit is contained in:
asofold 2015-04-07 23:07:57 +02:00
parent 5b27f62223
commit 9e7736963f
2 changed files with 18 additions and 11 deletions

View File

@ -14,6 +14,7 @@ import fr.neatmonster.nocheatplus.logging.Streams;
import fr.neatmonster.nocheatplus.utilities.BlockProperties;
import fr.neatmonster.nocheatplus.utilities.PlayerLocation;
import fr.neatmonster.nocheatplus.utilities.StringUtil;
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
import fr.neatmonster.nocheatplus.utilities.build.BuildParameters;
/**
@ -48,14 +49,6 @@ public class DebugUtil {
return builder.toString();
}
public static boolean isSamePos(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
return x1 == x2 && y1 == y2 && z1 == z2;
}
public static boolean isSamePos(final Location loc1, final Location loc2){
return isSamePos(loc1.getX(), loc1.getY(), loc1.getZ(), loc2.getX(), loc2.getY(), loc2.getZ());
}
public static void addLocation(final double x, final double y, final double z, final StringBuilder builder){
builder.append(x + ", " + y + ", " + z);
}
@ -156,7 +149,7 @@ public class DebugUtil {
* @return
*/
public static void addFormattedMove(final Location from, final Location to, final Location loc, final StringBuilder builder){
if (loc != null && !isSamePos(from, loc)){
if (loc != null && !TrigUtil.isSamePos(from, loc)){
builder.append("(");
addFormattedLocation(loc, builder);
builder.append(") ");
@ -171,7 +164,7 @@ public class DebugUtil {
* @param builder
*/
public static void addMove(final Location from, final Location to, final Location loc, final StringBuilder builder){
if (loc != null && !isSamePos(from, loc)){
if (loc != null && !TrigUtil.isSamePos(from, loc)){
builder.append("Location: ");
addLocation(loc, builder);
builder.append("\n");

View File

@ -494,7 +494,7 @@ public class TrigUtil {
}
/**
* Test if the location is on the same block as the given coordinates.
* Test if the coordinates represent the same position.
* @param loc
* @param x
* @param y
@ -508,6 +508,20 @@ public class TrigUtil {
return loc.getX() == x && loc.getZ() == z && loc.getY() == y;
}
/**
* Test if the coordinates represent the same position.
* @param x1
* @param y1
* @param z1
* @param x2
* @param y2
* @param z2
* @return
*/
public static boolean isSamePos(final double x1, final double y1, final double z1, final double x2, final double y2, final double z2){
return x1 == x2 && y1 == y2 && z1 == z2;
}
/**
* Test if the given double-coordinates are on the same block as specified by the int-coordinates.
* @param loc