mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 06:28:52 +00:00
Drop 1.8 support, improve IllegalInteract, drop rules engine for java 16, more refactoring
This commit is contained in:
1 parent
71a9c9a9c7
commit
a1f7a0cf7f
24 files changed
+632
-622
No files matched your search
@@ -69,6 +69,7 @@ public final class SpeedCheck {
|
||||
if (movementManager.airTicks >= 115) {
|
||||
predict = Math.max(0.08, predict);
|
||||
}
|
||||
|
||||
double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
|
||||
// Adjust for ice
|
||||
if (movementManager.iceInfluenceTicks > 0) {
|
||||
@@ -77,20 +78,25 @@ public final class SpeedCheck {
|
||||
if (iceIncrement > 0.18D) {
|
||||
iceIncrement = 0.18D;
|
||||
}
|
||||
|
||||
// Boxed in ice increment
|
||||
if (boxedIn) {
|
||||
iceIncrement += 0.45D;
|
||||
}
|
||||
|
||||
// Ice increment moving off ice
|
||||
if (!Utilities.couldBeOnIce(movingTowards)) {
|
||||
iceIncrement *= 2.5D;
|
||||
}
|
||||
|
||||
predict += iceIncrement;
|
||||
}
|
||||
|
||||
// Leniency when boxed in
|
||||
if (boxedIn && movementManager.airTicks < 3) {
|
||||
predict *= 1.2D;
|
||||
}
|
||||
|
||||
// Adjust for slime
|
||||
if (movementManager.slimeInfluenceTicks > 0) {
|
||||
double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
|
||||
@@ -98,23 +104,29 @@ public final class SpeedCheck {
|
||||
if (slimeIncrement > 0.12D) {
|
||||
slimeIncrement = 0.12D;
|
||||
}
|
||||
|
||||
predict += slimeIncrement;
|
||||
}
|
||||
|
||||
// Adjust for speed effects
|
||||
if (movementManager.hasSpeedEffect) {
|
||||
predict += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects ending
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) {
|
||||
limit *= 1.2D;
|
||||
}
|
||||
|
||||
// Adjust for jump boost effects
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
predict += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
|
||||
}
|
||||
|
||||
// Adjust for custom walking speed
|
||||
final double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "walkSpeedMultiplier"); // Default 1.4
|
||||
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||
|
||||
// Slabs sometimes allow for a slight boost after jump
|
||||
if (movementManager.halfMovementHistoryCounter > 0) {
|
||||
predict *= 2.125D;
|
||||
@@ -122,10 +134,12 @@ public final class SpeedCheck {
|
||||
if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0) {
|
||||
predict *= 1.25D;
|
||||
}
|
||||
|
||||
// Boats sometimes give a false positive
|
||||
if (Utilities.couldBeOnBoat(player, 0.5, true)) {
|
||||
predict *= 1.25D;
|
||||
}
|
||||
|
||||
// Strafing in air when nearing terminal velocity gives false positives
|
||||
// This fixes the issue but gives hackers some leniency which means we need
|
||||
// another check for this
|
||||
@@ -134,10 +148,12 @@ public final class SpeedCheck {
|
||||
&& (movingTowards.getBlockY() - player.getWorld().getHighestBlockYAt(movingTowards)) <= 1.5) {
|
||||
predict *= (movementManager.airTicks > 60 ? 4.0D : (movementManager.airTicks > 30 ? 3.0D : 2.0D));
|
||||
}
|
||||
|
||||
// Players can move faster in air with slow falling
|
||||
if (VersionUtil.isSlowFalling(player)) {
|
||||
predict *= 1.25D;
|
||||
}
|
||||
|
||||
// Prevent NoSlow
|
||||
if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2) {
|
||||
predict *= 0.8D;
|
||||
@@ -145,6 +161,7 @@ public final class SpeedCheck {
|
||||
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2) {
|
||||
predict *= 0.5D;
|
||||
}
|
||||
|
||||
// Fixes false positive when coming out of water
|
||||
if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14
|
||||
&& movementManager.motionY < -0.18 && movementManager.motionY > -0.182) {
|
||||
@@ -164,24 +181,33 @@ public final class SpeedCheck {
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airAcceleration") && movementManager.airTicks > 1
|
||||
&& movementManager.iceInfluenceTicks <= 0 && movementManager.slimeInfluenceTicks <= 0
|
||||
&& movementManager.elytraEffectTicks <= 0) {
|
||||
double initialAcceleration = movementManager.acceleration;
|
||||
final double initialAcceleration = movementManager.acceleration;
|
||||
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
|
||||
// Slight increase when boxed in
|
||||
if (boxedIn)
|
||||
if (boxedIn) {
|
||||
limit *= 1.08D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
|
||||
}
|
||||
|
||||
// Adjust for slabs
|
||||
if (movementManager.halfMovementHistoryCounter > 15)
|
||||
if (movementManager.halfMovementHistoryCounter > 15) {
|
||||
limit *= 2.05D;
|
||||
}
|
||||
|
||||
// Adjust for custom walking speed
|
||||
double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration",
|
||||
final double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration",
|
||||
"walkSpeedMultiplier"); // Default 1.4
|
||||
limit += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||
|
||||
// Boats sometimes give a false positive
|
||||
if (Utilities.couldBeOnBoat(player))
|
||||
if (Utilities.couldBeOnBoat(player)) {
|
||||
limit *= 1.25D;
|
||||
}
|
||||
|
||||
if (initialAcceleration > limit) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration",
|
||||
"exceeded acceleration limits (acceleration=" + initialAcceleration + ", max=" + limit + ")");
|
||||
@@ -195,8 +221,7 @@ public final class SpeedCheck {
|
||||
&& !Utilities.isNearHalfblock(movingTowards.clone().subtract(0, 0.51, 0)) && !Utilities.couldBeOnBoat(player, 0.8d, false)) {
|
||||
// This happens naturally
|
||||
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
||||
double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
|
||||
|
||||
final double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
|
||||
if (distanceXZ >= minimumDistXZ || movementManager.lastDistanceXZ >= minimumDistXZ) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
|
||||
"had unexpected jumping behaviour (dXZ=" + Utilities.roundDouble(distanceXZ, 4) + ", lXZ="
|
||||
@@ -207,60 +232,84 @@ public final class SpeedCheck {
|
||||
|
||||
// GroundSpeed
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1) {
|
||||
double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default
|
||||
// 0.34
|
||||
final double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default 0.34
|
||||
double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks);
|
||||
// Leniency when moving back on ground
|
||||
if (movementManager.groundTicks < 5)
|
||||
if (movementManager.groundTicks < 5) {
|
||||
limit += 0.1D;
|
||||
}
|
||||
|
||||
// Slab leniency
|
||||
if (movementManager.halfMovementHistoryCounter > 8)
|
||||
if (movementManager.halfMovementHistoryCounter > 8) {
|
||||
limit += 0.2D;
|
||||
}
|
||||
|
||||
// LivingEntities can give players a small push boost
|
||||
if (!movingTowards.getWorld().getNearbyEntities(movingTowards, 0.3, 0.3, 0.3).isEmpty())
|
||||
if (!movingTowards.getWorld().getNearbyEntities(movingTowards, 0.3, 0.3, 0.3).isEmpty()) {
|
||||
limit += 0.2D;
|
||||
}
|
||||
|
||||
// Leniency when boxed in
|
||||
if (boxedIn)
|
||||
if (boxedIn) {
|
||||
limit *= 1.1D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects
|
||||
if (movementManager.hasSpeedEffect)
|
||||
if (movementManager.hasSpeedEffect) {
|
||||
limit += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
|
||||
if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3)
|
||||
}
|
||||
if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3) {
|
||||
limit *= 1.4D;
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect)
|
||||
}
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) {
|
||||
limit *= 1.2D;
|
||||
}
|
||||
|
||||
// Ice adjustments
|
||||
if (movementManager.iceInfluenceTicks >= 50) {
|
||||
// When moving off ice
|
||||
if (!Utilities.couldBeOnIce(movingTowards))
|
||||
if (!Utilities.couldBeOnIce(movingTowards)) {
|
||||
limit *= 2.5D;
|
||||
else {
|
||||
} else {
|
||||
// When boxed in and spamming space for boost
|
||||
if (movementManager.topSolid && movementManager.bottomSolid)
|
||||
if (movementManager.topSolid && movementManager.bottomSolid) {
|
||||
limit *= 3.0D;
|
||||
else
|
||||
} else {
|
||||
limit *= 1.25D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Increased speed when stepping on/off half blocks
|
||||
if (Utilities.isNearBed(movingTowards) || Utilities.couldBeOnHalfblock(movingTowards)
|
||||
|| Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0)))
|
||||
|| Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0))) {
|
||||
limit *= 2.0D;
|
||||
}
|
||||
|
||||
// Increased speed when stepping on/off boat
|
||||
if (Utilities.couldBeOnBoat(player))
|
||||
if (Utilities.couldBeOnBoat(player)) {
|
||||
limit += 0.2D;
|
||||
}
|
||||
|
||||
// Adjust for custom walk speed
|
||||
limit += (player.getWalkSpeed() - 0.2) * 2.0D;
|
||||
|
||||
// Prevent NoSlow
|
||||
if (player.isBlocking() && movementManager.groundTicks > 2)
|
||||
if (player.isBlocking() && movementManager.groundTicks > 2) {
|
||||
limit *= 0.45D;
|
||||
}
|
||||
|
||||
// Prevent NoWeb
|
||||
// TODO config
|
||||
if (Utilities.isInWeb(player))
|
||||
if (Utilities.isInWeb(player)) {
|
||||
limit *= 0.65D;
|
||||
}
|
||||
|
||||
// Sneak speed check
|
||||
// TODO config
|
||||
if (movementManager.sneakingTicks > 1)
|
||||
if (movementManager.sneakingTicks > 1) {
|
||||
limit *= 0.68D;
|
||||
}
|
||||
|
||||
if (distanceXZ - limit > 0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed",
|
||||
@@ -272,28 +321,35 @@ public final class SpeedCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkVerticalSpeed(Player player, Distance distance) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
public static CheckResult checkVerticalSpeed(final Player player, final Distance distance) {
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|
||||
|| Utilities.isNearWater(player))
|
||||
|| Utilities.isNearWater(player)) {
|
||||
return PASS;
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
}
|
||||
|
||||
final MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getMovementManager();
|
||||
// Riptiding exemption
|
||||
if (movementManager.riptideTicks > 0)
|
||||
if (movementManager.riptideTicks > 0) {
|
||||
return PASS;
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed"))
|
||||
}
|
||||
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed")) {
|
||||
return PASS;
|
||||
|
||||
}
|
||||
|
||||
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
|
||||
Utilities.couldBeOnBoat(player),
|
||||
Utilities.isClimbableBlock(distance.getFrom().getBlock())
|
||||
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)),
|
||||
movementManager.halfMovement, checksConfig);
|
||||
// Fix false positive with soulsand boost
|
||||
if (movementManager.nearLiquidTicks > 6)
|
||||
if (movementManager.nearLiquidTicks > 6) {
|
||||
maxMotionY *= 1.0525D;
|
||||
}
|
||||
|
||||
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed",
|
||||
"exceeded vertical speed limit (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
||||
@@ -301,18 +357,20 @@ public final class SpeedCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static double getMaxAcceptableMotionY(Player player, boolean nearBed, boolean couldBeOnBoat,
|
||||
boolean fromClimbable, boolean halfMovement, Checks checksConfig) {
|
||||
private static double getMaxAcceptableMotionY(final Player player, final boolean nearBed, final boolean couldBeOnBoat,
|
||||
final boolean fromClimbable, final boolean halfMovement, final Checks checksConfig) {
|
||||
// TODO config for these values
|
||||
// TODO something funky vanilla stuff going on with 0.42, like 0.445.., check
|
||||
// this..
|
||||
double base = couldBeOnBoat ? 0.600000025
|
||||
: (nearBed ? 0.5625 : ((halfMovement || VersionUtil.isBountifulUpdate()) ? 0.6 : 0.42));
|
||||
if (fromClimbable)
|
||||
: (nearBed ? 0.5625 : ((halfMovement) ? 0.6 : 0.42));
|
||||
if (fromClimbable) {
|
||||
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
|
||||
}
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
base += VersionUtil.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user