Fixed WaterWalk false positive with carpets, fixed 1.17-related Speed false positive

This commit is contained in:
Rammelkast committed 2021-10-24 11:12:30 +02:00
1 parent 5c596f5e2f
commit 6af50e5a33
3 files changed
+38 -16

No files matched your search

@@ -36,6 +36,7 @@ import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
import com.rammelkast.anticheatreloaded.util.VelocityTracker;
import com.rammelkast.anticheatreloaded.util.VersionUtil;
import com.rammelkast.anticheatreloaded.util.XMaterial;
/**
* @author Rammelkast TODO soulsand speed TODO buffer system
@@ -384,6 +385,11 @@ public final class SpeedCheck {
maxMotionY *= 1.0525D;
}
// Adjust for powdered snow
if (distance.getFrom().getBlock().getType() == XMaterial.POWDER_SNOW.parseMaterial()) {
maxMotionY += 0.17D;
}
// Adjust for velocity
maxMotionY += velocityTracker.getVertical();
@@ -43,11 +43,11 @@ public final class WaterWalkCheck {
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
final MovementManager movementManager = user.getMovementManager();
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player)
|| movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player)
|| player.getLocation().getBlock().getType().name().endsWith("CARPET"))
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player) || Utilities.isOnCarpet(player)
|| movementManager.riptideTicks > 0 || VersionUtil.isSwimming(player) || VersionUtil.isFlying(player)) {
return PASS;
}
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
final Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
@@ -55,30 +55,30 @@ public final class WaterWalkCheck {
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
|| movementManager.motionY == Utilities.JUMP_MOTION_Y)
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false))
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false)) {
return new CheckResult(Result.FAILED, "Walk",
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
}
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player) && movementManager.onGround
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
&& !Utilities.couldBeOnBoat(player, 0.3, false))
&& !Utilities.couldBeOnBoat(player, 0.3, false)) {
return new CheckResult(Result.FAILED, "Hop",
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
}
double minAbsMotionY = 0.12D;
if (player.hasPotionEffect(PotionEffectType.SPEED))
minAbsMotionY += VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
final double minAbsMotionY = 0.12D + (VersionUtil.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D);
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
&& Utilities.isSurroundedByWater(player)
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
&& movementManager.lastMotionY > -0.25
&& !Utilities.couldBeOnBoat(player, 0.3, false))
&& !Utilities.couldBeOnBoat(player, 0.3, false)) {
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
}
return PASS;
}
@@ -464,14 +464,29 @@ public final class Utilities {
* @param player player to check
* @return true if on lily pad
*/
public static boolean isOnLilyPad(Player player) {
Block block = player.getLocation().getBlock();
public static boolean isOnLilyPad(final Player player) {
final Block block = player.getLocation().getBlock();
return block.getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.NORTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.SOUTH).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.EAST).getType() == XMaterial.LILY_PAD.parseMaterial()
|| block.getRelative(BlockFace.WEST).getType() == XMaterial.LILY_PAD.parseMaterial();
}
/**
* Determine whether a player is standing on a carpet
*
* @param player player to check
* @return true if on carpet
*/
public static boolean isOnCarpet(final Player player) {
final Block block = player.getLocation().getBlock();
return block.getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.NORTH).getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.SOUTH).getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.EAST).getType().name().endsWith("CARPET")
|| block.getRelative(BlockFace.WEST).getType().name().endsWith("CARPET");
}
/**
* Determine whether a player is fully submersed in liquid
@@ -479,7 +494,7 @@ public final class Utilities {
* @param player player to check
* @return true if submersed
*/
public static boolean isSubmersed(Player player) {
public static boolean isSubmersed(final Player player) {
return player.getLocation().getBlock().isLiquid()
&& player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
}
@@ -638,7 +653,7 @@ public final class Utilities {
* @param block block to check
* @return true if climbable
*/
public static boolean isClimbableBlock(Block block) {
public static boolean isClimbableBlock(final Block block) {
return CLIMBABLE.contains(block.getType());
}
@@ -648,7 +663,7 @@ public final class Utilities {
* @param player to check
* @return true if on vine
*/
public static boolean isOnVine(Player player) {
public static boolean isOnVine(final Player player) {
return player.getLocation().getBlock().getType() == XMaterial.VINE.parseMaterial();
}
@@ -1034,6 +1049,7 @@ public final class Utilities {
CLIMBABLE.add(XMaterial.CAVE_VINES.parseMaterial());
CLIMBABLE.add(XMaterial.CAVE_VINES_PLANT.parseMaterial());
CLIMBABLE.add(XMaterial.GLOW_BERRIES.parseMaterial());
CLIMBABLE.add(XMaterial.POWDER_SNOW.parseMaterial());
}
// End 1.17 objects
// End climbable