mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
1 parent
cd3184f17b
commit
8cf2702708
5 files changed
+69
-4
No files matched your search
@@ -59,7 +59,11 @@ public class CheckFailEvent extends Event {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlers() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,8 @@ public class GlideCheck {
|
||||
&& Utilities.isNotNearSlime(distance.getTo().getBlock()) && fallDistance < 1.5
|
||||
&& !Utilities.isNearClimbable(player)
|
||||
&& !player.isSneaking()
|
||||
&& !AntiCheatReloaded.getManager().getBackend().isEating(player)) {
|
||||
&& !AntiCheatReloaded.getManager().getBackend().isEating(player)
|
||||
&& !Utilities.isInWater(player)) {
|
||||
// TODO that fallDistance check is a horrible way to prevent a certain false
|
||||
// positive
|
||||
// Needs to be fixed since this only works for slight above ground movements
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class BadPacketsCheck {
|
||||
|
||||
@@ -41,6 +42,7 @@ public class BadPacketsCheck {
|
||||
return;
|
||||
}
|
||||
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
PacketContainer packet = event.getPacket();
|
||||
float pitch = packet.getFloat().read(1);
|
||||
// Check for derp
|
||||
@@ -50,7 +52,7 @@ public class BadPacketsCheck {
|
||||
}
|
||||
|
||||
// TODO more precise checking for this
|
||||
if (AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).isLagging()) {
|
||||
if (user.isLagging()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,6 +75,8 @@ public class BadPacketsCheck {
|
||||
//flag(player, event, "sent the same packet twice");
|
||||
return;
|
||||
}
|
||||
|
||||
user.checkForOptifine(yaw, pitch);
|
||||
}
|
||||
|
||||
private static void flag(Player player, PacketEvent event, String message) {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
public class MinecraftSmooth {
|
||||
|
||||
private float x = 0, y = 0, z = 0;
|
||||
|
||||
public float smooth(float toSmooth, float increment) {
|
||||
x += toSmooth;
|
||||
toSmooth = (x - y) * increment;
|
||||
z += (toSmooth - z) * 0.5f;
|
||||
|
||||
if (toSmooth > 0f && toSmooth > z || toSmooth < 0f && toSmooth < z) {
|
||||
toSmooth = z;
|
||||
}
|
||||
|
||||
y += toSmooth;
|
||||
return toSmooth;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,7 +48,9 @@ public class User {
|
||||
private Long[] messageTimes = new Long[2];
|
||||
private String[] commands = new String[2];
|
||||
private Long[] commandTimes = new Long[2];
|
||||
|
||||
private MinecraftSmooth yawSmooth = new MinecraftSmooth(), pitchSmooth = new MinecraftSmooth();
|
||||
private boolean usingOptifine = false;
|
||||
|
||||
private boolean isWaitingOnLevelSync;
|
||||
private Timestamp levelSyncTimestamp;
|
||||
|
||||
@@ -453,8 +455,36 @@ public class User {
|
||||
return Math.abs(this.ping - this.lastPing) > 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user is using optifine zoom to prevent false positives
|
||||
* @param yaw
|
||||
* @param pitch
|
||||
*/
|
||||
public void checkForOptifine(float yaw, float pitch) {
|
||||
float yawDelta = Math.abs(this.getPlayer().getLocation().getYaw() - yaw);
|
||||
float modifiedYaw = this.modifyValue(yawDelta);
|
||||
float pitchDelta = Math.abs(this.getPlayer().getLocation().getPitch() - pitch);
|
||||
float modifiedPitch = this.modifyValue(pitchDelta);
|
||||
float yawSmooth = this.yawSmooth.smooth(modifiedYaw, modifiedYaw * 0.05f);
|
||||
float pitchSmooth = this.pitchSmooth.smooth(modifiedPitch, modifiedPitch * 0.05f);
|
||||
if (Math.abs(yawSmooth - modifiedYaw) < 0.08f || Math.abs(pitchSmooth - modifiedPitch) < 0.04f) {
|
||||
this.usingOptifine = true;
|
||||
} else {
|
||||
this.usingOptifine = false;
|
||||
}
|
||||
}
|
||||
|
||||
private float modifyValue(float value) {
|
||||
return ((float) Math.cbrt((value / 0.15f) / 8f) - 0.2f) / .6f;
|
||||
}
|
||||
|
||||
public boolean isUsingOptifine() {
|
||||
return this.usingOptifine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User {name = " + getName() + ", level = " + level + "}";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user