Fix #167, vastly improved aimbot check (experimental)

This commit is contained in:
Rammelkast committed 2021-10-12 14:22:34 +02:00
1 parent e2d0fbda18
commit 78ae04a2a8
12 files changed
+110 -70

No files matched your search

@@ -59,6 +59,14 @@ public final class MovementManager {
public double lastDistanceX;
// Previous horizontal distance on z-axis of movement
public double lastDistanceZ;
// Delta pitch
public float deltaPitch;
// Delta yaw
public float deltaYaw;
// Previous delta pitch
public float lastDeltaPitch;
// Previous delta yaw
public float lastDeltaYaw;
// If the player touched the ground again this tick
public boolean touchedGroundThisTick = false;
// Last recorded distance
@@ -117,6 +125,11 @@ public final class MovementManager {
this.distanceXZ = Math.sqrt(x * x + z * z);
this.distanceX = x;
this.distanceZ = z;
this.lastDeltaPitch = this.deltaPitch;
this.lastDeltaYaw = this.deltaYaw;
this.deltaPitch = Math.abs(to.getPitch() - from.getPitch());
this.deltaYaw = Math.abs(Utilities.computeAngleDifference(to.getYaw(), from.getYaw()));
// Account for standing on boat
if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player)) {
@@ -101,11 +101,13 @@ public class UpdateManager {
public class VersionSplit implements Comparable<VersionSplit> {
private final int major, minor, build;
private boolean prerelease = false;
public VersionSplit(String version) throws Exception {
if (version.endsWith("-ALPHA")) {
version = version.substring(0, version.length() - 6);
} else if (version.endsWith("-PRE")) {
this.prerelease = true;
version = version.substring(0, version.length() - 4);
}
@@ -132,11 +134,15 @@ public class UpdateManager {
}
@Override
public int compareTo(VersionSplit other) {
public int compareTo(final VersionSplit other) {
if (other.major == this.major) {
if (other.minor == this.minor) {
if (other.build == this.build) {
return 0;
if (!this.prerelease) {
return 0;
} else {
return -1;
}
}
if (other.build > this.build) {
return -1;
@@ -840,7 +840,40 @@ public final class Utilities {
}
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
}
/**
* Computes the difference between two angles
* @param a Angle A
* @param b Angle B
* @return the difference between two angles
*/
public static float computeAngleDifference(final float a, final float b) {
float diff = Math.abs(a - b);
final float altDiff = b + 360 - a;
final float altAltDiff = a + 360 - b;
if (altDiff < diff) diff = altDiff;
if (altAltDiff < diff) diff = altAltDiff;
return diff;
}
/**
* Calculates the greatest common divider
* @param a value a
* @param b value b
* @return the greatest common divider of a and b
*/
public static double computeGcd(final double a, final double b) {
if (a < b) {
return computeGcd(b, a);
}
if (Math.abs(b) < 0.001) {
return a;
} else {
return computeGcd(b, a - Math.floor(a / b) * b);
}
}
static {
MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion();
@@ -137,7 +137,7 @@ public class VersionUtil {
}
static {
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_17_R1", "v1_16", "v1_15", "v1_14", "v1_13", "v1_12" });
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_17", "v1_16", "v1_15", "v1_14", "v1_13", "v1_12" });
CURRENT_VERSION = MinecraftVersion.getCurrentVersion();
}
}