From 9accfc3831acf8104a0981dc442984769bddc4f9 Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 17 Jul 2013 00:58:47 +0200 Subject: [PATCH] Allow using up horizontal velocity for sprintback. --- .../checks/moving/SurvivalFly.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index 91392211..e721c0a2 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -167,8 +167,24 @@ public class SurvivalFly extends Check { double hAllowedDistance = getAllowedhDist(player, from, to, sprinting, downStream, hDistance, walkSpeed, data, cc, false); // Judge if horizontal speed is above limit. -// double hDistanceAboveLimit = hDistance - hAllowedDistance - data.horizontalFreedom; double hDistanceAboveLimit = hDistance - hAllowedDistance; + + // Prevent players from sprinting if they're moving backwards. + if (sprinting) { + // TODO: Find more ways to confine conditions. + final float yaw = from.getYaw(); + if (xDistance < 0D && zDistance > 0D && yaw > 180F && yaw < 270F + || xDistance < 0D && zDistance < 0D && yaw > 270F && yaw < 360F + || xDistance > 0D && zDistance < 0D && yaw > 0F && yaw < 90F + || xDistance > 0D && zDistance > 0D && yaw > 90F && yaw < 180F) { + // (Might have to account for speeding permissions.) + if (!player.hasPermission(Permissions.MOVING_SURVIVALFLY_SPRINTING)) { + hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance); + tags.add("sprintback"); // Might add it anyway. + } + } + } + double hFreedom = 0; // Horizontal velocity used (!). if (hDistanceAboveLimit > 0){ // Check extra buffer (!). @@ -234,22 +250,6 @@ public class SurvivalFly extends Check { tags.add("waterwalk"); } - // Prevent players from sprinting if they're moving backwards. -// if (hDistanceAboveLimit <= 0D && sprinting && data.horizontalFreedom <= 0.001D) { - if (hDistanceAboveLimit <= 0D && hDistance > walkSpeed && sprinting && data.hVelActive.isEmpty()) { - final float yaw = from.getYaw(); - if (xDistance < 0D && zDistance > 0D && yaw > 180F && yaw < 270F || xDistance < 0D && zDistance < 0D - && yaw > 270F && yaw < 360F || xDistance > 0D && zDistance < 0D && yaw > 0F && yaw < 90F - || xDistance > 0D && zDistance > 0D && yaw > 90F && yaw < 180F){ - // Assumes permission check to be the heaviest (might be mistaken). - if (!player.hasPermission(Permissions.MOVING_SURVIVALFLY_SPRINTING)){ - // TODO: This should actually trigger use of horizontal velocity and extra buffers (even better: per axis per direction). - hDistanceAboveLimit = Math.max(hDistanceAboveLimit, hDistance); - tags.add("sprintback"); // Might add it anyway. - } - } - } - data.bunnyhopDelay--; // "Bunny-hop". if (hDistanceAboveLimit > 0 && sprinting){