mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Fix #215
This commit is contained in:
1 parent
ffb7ea1ad4
commit
4d5b357c36
3 files changed
+45
-20
No files matched your search
@@ -116,7 +116,7 @@ public final class FlightCheck {
|
|||||||
&& (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
|
&& (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
|
||||||
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) {
|
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
|
return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
|
||||||
"tried to fly on the Y-axis (mY=" + movementManager.motionY + ", max=" + maxMotionY + ")");
|
"tried to fly on the Y-axis (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", max=" + Utilities.roundDouble(maxMotionY, 4) + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO falses when falling large distances
|
// TODO falses when falling large distances
|
||||||
@@ -132,7 +132,7 @@ public final class FlightCheck {
|
|||||||
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))
|
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))
|
||||||
&& velocityTracker.getVertical() == 0.0) {
|
&& velocityTracker.getVertical() == 0.0) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
|
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
|
||||||
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
|
+ Utilities.roundDouble(Math.abs(movementManager.motionY - movementManager.lastMotionY), 4) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End AirFlight
|
// End AirFlight
|
||||||
@@ -151,9 +151,10 @@ public final class FlightCheck {
|
|||||||
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
|
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
|
||||||
&& movementManager.motionY > 0.15))
|
&& movementManager.motionY > 0.15))
|
||||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25
|
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25
|
||||||
&& !Utilities.couldBeOnBoat(player, 0.8, false))
|
&& !Utilities.couldBeOnBoat(player, 0.8, false)) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||||
"tried to climb air (mY=" + movementManager.motionY + ")");
|
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
|
||||||
&& movementManager.airTicks > 2 && !velocityTracker.isVelocitized()
|
&& movementManager.airTicks > 2 && !velocityTracker.isVelocitized()
|
||||||
@@ -163,7 +164,7 @@ public final class FlightCheck {
|
|||||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
|
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
||||||
@@ -173,7 +174,7 @@ public final class FlightCheck {
|
|||||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||||
&& !(Math.round(movementManager.motionY * 1000) == 396) && movementManager.airTicks == 15) {
|
&& !(Math.round(movementManager.motionY * 1000) == 396) && movementManager.airTicks == 15) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0.0
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0.0
|
||||||
@@ -183,14 +184,15 @@ public final class FlightCheck {
|
|||||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
|
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
||||||
&& !velocityTracker.isVelocitized() && movementManager.slimeInfluenceTicks <= 0
|
&& !velocityTracker.isVelocitized() && movementManager.slimeInfluenceTicks <= 0
|
||||||
&& movementManager.elytraEffectTicks <= 25
|
&& movementManager.elytraEffectTicks <= 25
|
||||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
|
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||||
|
&& !Utilities.isNearClimbable(distance.getFrom(), 0.8)) {
|
||||||
// Config default base is 1200ms
|
// Config default base is 1200ms
|
||||||
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
||||||
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||||
@@ -209,7 +211,7 @@ public final class FlightCheck {
|
|||||||
: 0.42;
|
: 0.42;
|
||||||
if (movementManager.motionY > maxMotionY) {
|
if (movementManager.motionY > maxMotionY) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// End AirClimb
|
// End AirClimb
|
||||||
@@ -220,7 +222,7 @@ public final class FlightCheck {
|
|||||||
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
||||||
&& Utilities.cantStandAt(distance.getTo().getBlock())) {
|
&& Utilities.cantStandAt(distance.getTo().getBlock())) {
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
|
return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
|
||||||
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
|
"faked ground to fly (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", gt=" + movementManager.groundTicks + ")");
|
||||||
}
|
}
|
||||||
// End GroundFlight
|
// End GroundFlight
|
||||||
|
|
||||||
@@ -246,7 +248,7 @@ public final class FlightCheck {
|
|||||||
if (vl >= vlBeforeFlag) {
|
if (vl >= vlBeforeFlag) {
|
||||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
|
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "Gravity",
|
return new CheckResult(CheckResult.Result.FAILED, "Gravity",
|
||||||
"ignored gravity (offset=" + offset + ", at=" + movementManager.airTicks + ")");
|
"ignored gravity (offset=" + Utilities.roundDouble(offset, 4) + ", at=" + movementManager.airTicks + ")");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) {
|
if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) {
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public final class SpeedCheck {
|
|||||||
* Largely based on Elevated's Frequency speed check
|
* Largely based on Elevated's Frequency speed check
|
||||||
* @see https://github.com/ElevatedDev/Frequency/blob/master/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java
|
* @see https://github.com/ElevatedDev/Frequency/blob/master/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java
|
||||||
*
|
*
|
||||||
* TODO fix falses with jumping under blocks
|
|
||||||
* TODO fix falses with entity collisions
|
* TODO fix falses with entity collisions
|
||||||
*/
|
*/
|
||||||
public static CheckResult checkPredict(final Player player, final Location movingTowards) {
|
public static CheckResult checkPredict(final Player player, final Location movingTowards) {
|
||||||
@@ -84,6 +83,7 @@ public final class SpeedCheck {
|
|||||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||||
|
|
||||||
final double motion = movementManager.distanceXZ;
|
final double motion = movementManager.distanceXZ;
|
||||||
|
final boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||||
final boolean sprinting = true; // TODO do this using packets
|
final boolean sprinting = true; // TODO do this using packets
|
||||||
|
|
||||||
double buffer = PREDICT_BUFFER.getOrDefault(uuid, 0.0);
|
double buffer = PREDICT_BUFFER.getOrDefault(uuid, 0.0);
|
||||||
@@ -94,7 +94,7 @@ public final class SpeedCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
movementSpeed *= 0.16277136 / Math.pow((movementManager.friction *= 0.91f), 3);
|
movementSpeed *= 0.16277136 / Math.pow((movementManager.friction *= 0.91f), 3);
|
||||||
if (!movementManager.onGround && movementManager.motionY >= 0.42f && sprinting) {
|
if (!movementManager.onGround && (movementManager.motionY >= 0.42f || (boxedIn && movementManager.motionY > 0.0f)) && sprinting) {
|
||||||
movementSpeed += 0.2f;
|
movementSpeed += 0.2f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -105,7 +105,9 @@ public final class SpeedCheck {
|
|||||||
movementSpeed += velocityTracker.getHorizontal();
|
movementSpeed += velocityTracker.getHorizontal();
|
||||||
|
|
||||||
final double factor = (motion - movementManager.adjusted) / movementSpeed;
|
final double factor = (motion - movementManager.adjusted) / movementSpeed;
|
||||||
if (factor > 1.001) {
|
final boolean exempted = Utilities.isCollisionPoint(movingTowards,
|
||||||
|
material -> material == XMaterial.HONEY_BLOCK.parseMaterial());
|
||||||
|
if (factor > 1.001 && !exempted) {
|
||||||
if (buffer++ > 2.5) {
|
if (buffer++ > 2.5) {
|
||||||
buffer /= 2;
|
buffer /= 2;
|
||||||
PREDICT_BUFFER.put(uuid, buffer);
|
PREDICT_BUFFER.put(uuid, buffer);
|
||||||
|
|||||||
@@ -438,13 +438,12 @@ public final class Utilities {
|
|||||||
return player.getLocation().getBlock().isLiquid()
|
return player.getLocation().getBlock().isLiquid()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|
|| player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid()
|
||||||
|| (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)
|
|| MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)
|
||||||
&& (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial()
|
&& (player.getLocation().getBlock().getType() == XMaterial.KELP_PLANT.parseMaterial()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.UP)
|
|| player.getLocation().getBlock().getRelative(BlockFace.UP)
|
||||||
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|
||||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN)
|
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN)
|
||||||
.getType() == XMaterial.KELP_PLANT.parseMaterial())
|
.getType() == XMaterial.KELP_PLANT.parseMaterial());
|
||||||
&& isNearWater(player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -547,6 +546,17 @@ public final class Utilities {
|
|||||||
public static boolean isNearClimbable(final Location location) {
|
public static boolean isNearClimbable(final Location location) {
|
||||||
return isCollisionPoint(location, material -> CLIMBABLE.contains(material));
|
return isCollisionPoint(location, material -> CLIMBABLE.contains(material));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a location is near a climbable block
|
||||||
|
*
|
||||||
|
* @param location location to check
|
||||||
|
* @param expand expansion factor
|
||||||
|
* @return true if near climbable block
|
||||||
|
*/
|
||||||
|
public static boolean isNearClimbable(final Location location, final double expand) {
|
||||||
|
return isCollisionPoint(location, expand, material -> CLIMBABLE.contains(material));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a block is climbable
|
* Determine whether a block is climbable
|
||||||
@@ -780,10 +790,14 @@ public final class Utilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCollisionPoint(final Location location, final Predicate<Material> predicate) {
|
public static boolean isCollisionPoint(final Location location, final Predicate<Material> predicate) {
|
||||||
|
return isCollisionPoint(location, 0.3, predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCollisionPoint(final Location location, final double expand, final Predicate<Material> predicate) {
|
||||||
final ArrayList<Material> materials = new ArrayList<>();
|
final ArrayList<Material> materials = new ArrayList<>();
|
||||||
for (double x = -0.3; x <= 0.3; x += 0.3) {
|
for (double x = -expand; x <= expand; x += expand) {
|
||||||
for (double y = -0.3; y <= 0.3; y += 0.3) {
|
for (double y = -expand; y <= expand; y += expand) {
|
||||||
for (double z = -0.3; z <= 0.3; z += 0.3) {
|
for (double z = -expand; z <= expand; z += expand) {
|
||||||
final Material material = location.clone().add(x, y, z).getBlock().getType();
|
final Material material = location.clone().add(x, y, z).getBlock().getType();
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
materials.add(material);
|
materials.add(material);
|
||||||
@@ -976,6 +990,13 @@ public final class Utilities {
|
|||||||
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
|
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
|
||||||
CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
|
CLIMBABLE.add(XMaterial.LADDER.parseMaterial());
|
||||||
CLIMBABLE.add(XMaterial.WATER.parseMaterial());
|
CLIMBABLE.add(XMaterial.WATER.parseMaterial());
|
||||||
|
// Start 1.13 objects
|
||||||
|
if (currentVersion.isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||||
|
CLIMBABLE.add(XMaterial.KELP.parseMaterial());
|
||||||
|
CLIMBABLE.add(XMaterial.KELP_PLANT.parseMaterial());
|
||||||
|
}
|
||||||
|
// End 1.13 objects
|
||||||
|
|
||||||
// Start 1.14 objects
|
// Start 1.14 objects
|
||||||
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||||
CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial());
|
CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial());
|
||||||
|
|||||||
Reference in new issue
Block a user