mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +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))
|
||||
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) {
|
||||
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
|
||||
@@ -132,7 +132,7 @@ public final class FlightCheck {
|
||||
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))
|
||||
&& velocityTracker.getVertical() == 0.0) {
|
||||
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
|
||||
@@ -151,9 +151,10 @@ public final class FlightCheck {
|
||||
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
|
||||
&& movementManager.motionY > 0.15))
|
||||
&& 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",
|
||||
"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
|
||||
&& movementManager.airTicks > 2 && !velocityTracker.isVelocitized()
|
||||
@@ -163,7 +164,7 @@ public final class FlightCheck {
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
|
||||
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
|
||||
@@ -173,7 +174,7 @@ public final class FlightCheck {
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& !(Math.round(movementManager.motionY * 1000) == 396) && movementManager.airTicks == 15) {
|
||||
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
|
||||
@@ -183,14 +184,15 @@ public final class FlightCheck {
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
|
||||
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
|
||||
&& !velocityTracker.isVelocitized() && movementManager.slimeInfluenceTicks <= 0
|
||||
&& movementManager.elytraEffectTicks <= 25
|
||||
&& (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
|
||||
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
||||
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||
@@ -209,7 +211,7 @@ public final class FlightCheck {
|
||||
: 0.42;
|
||||
if (movementManager.motionY > maxMotionY) {
|
||||
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
|
||||
@@ -220,7 +222,7 @@ public final class FlightCheck {
|
||||
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock())) {
|
||||
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
|
||||
|
||||
@@ -246,7 +248,7 @@ public final class FlightCheck {
|
||||
if (vl >= vlBeforeFlag) {
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
|
||||
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 {
|
||||
if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) {
|
||||
|
||||
@@ -63,7 +63,6 @@ public final class SpeedCheck {
|
||||
* 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
|
||||
*
|
||||
* TODO fix falses with jumping under blocks
|
||||
* TODO fix falses with entity collisions
|
||||
*/
|
||||
public static CheckResult checkPredict(final Player player, final Location movingTowards) {
|
||||
@@ -84,6 +83,7 @@ public final class SpeedCheck {
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
|
||||
final double motion = movementManager.distanceXZ;
|
||||
final boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||
final boolean sprinting = true; // TODO do this using packets
|
||||
|
||||
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);
|
||||
if (!movementManager.onGround && movementManager.motionY >= 0.42f && sprinting) {
|
||||
if (!movementManager.onGround && (movementManager.motionY >= 0.42f || (boxedIn && movementManager.motionY > 0.0f)) && sprinting) {
|
||||
movementSpeed += 0.2f;
|
||||
}
|
||||
} else {
|
||||
@@ -105,7 +105,9 @@ public final class SpeedCheck {
|
||||
movementSpeed += velocityTracker.getHorizontal();
|
||||
|
||||
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) {
|
||||
buffer /= 2;
|
||||
PREDICT_BUFFER.put(uuid, buffer);
|
||||
|
||||
@@ -438,13 +438,12 @@ public final class Utilities {
|
||||
return player.getLocation().getBlock().isLiquid()
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN).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().getRelative(BlockFace.UP)
|
||||
.getType() == XMaterial.KELP_PLANT.parseMaterial()
|
||||
|| player.getLocation().getBlock().getRelative(BlockFace.DOWN)
|
||||
.getType() == XMaterial.KELP_PLANT.parseMaterial())
|
||||
&& isNearWater(player));
|
||||
.getType() == XMaterial.KELP_PLANT.parseMaterial());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -547,6 +546,17 @@ public final class Utilities {
|
||||
public static boolean isNearClimbable(final Location location) {
|
||||
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
|
||||
@@ -780,10 +790,14 @@ public final class Utilities {
|
||||
}
|
||||
|
||||
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<>();
|
||||
for (double x = -0.3; x <= 0.3; x += 0.3) {
|
||||
for (double y = -0.3; y <= 0.3; y += 0.3) {
|
||||
for (double z = -0.3; z <= 0.3; z += 0.3) {
|
||||
for (double x = -expand; x <= expand; x += expand) {
|
||||
for (double y = -expand; y <= expand; y += expand) {
|
||||
for (double z = -expand; z <= expand; z += expand) {
|
||||
final Material material = location.clone().add(x, y, z).getBlock().getType();
|
||||
if (material != null) {
|
||||
materials.add(material);
|
||||
@@ -976,6 +990,13 @@ public final class Utilities {
|
||||
CLIMBABLE.add(XMaterial.VINE.parseMaterial());
|
||||
CLIMBABLE.add(XMaterial.LADDER.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
|
||||
if (currentVersion.isAtLeast(MinecraftVersion.VILLAGE_UPDATE)) {
|
||||
CLIMBABLE.add(XMaterial.SCAFFOLDING.parseMaterial());
|
||||
|
||||
Reference in new issue
Block a user