From b531091e7fc2ad99a41cd9879574c4b31921d7dc Mon Sep 17 00:00:00 2001 From: asofold Date: Thu, 8 Nov 2012 18:33:28 +0100 Subject: [PATCH] Add method for reset condition to PlayerLocation. --- src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java | 4 ++-- .../nocheatplus/checks/moving/SurvivalFly.java | 4 ++-- .../nocheatplus/utilities/PlayerLocation.java | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java b/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java index 2f90c077..3967ea3a 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/NoFall.java @@ -99,9 +99,9 @@ public class NoFall extends Check { // TODO: Distinguish water depth vs. fall distance! final boolean fromOnGround = from.isOnGround(); - final boolean fromReset = from.isInLiquid() || from.isInWeb() || from.isOnLadder(); + final boolean fromReset = from.isResetCond(); final boolean toOnGround = to.isOnGround(); - final boolean toReset = to.isInLiquid() || to.isInWeb() || to.isOnLadder(); + final boolean toReset = to.isResetCond(); final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle(); diff --git a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java index 029a20ca..f4a04fed 100644 --- a/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java +++ b/src/fr/neatmonster/nocheatplus/checks/moving/SurvivalFly.java @@ -122,7 +122,7 @@ public class SurvivalFly extends Check { final boolean resetFrom; // "Lost ground" workaround. - if (fromOnGround || from.isInLiquid() || from.isOnLadder() || from.isInWeb()) resetFrom = true; + if (fromOnGround || from.isResetCond()) resetFrom = true; else if (lostGround(player, mcPlayer, from, to, yDistance, data, cc)){ resetFrom = true; // TODO: Consider && !resetTo ? @@ -189,7 +189,7 @@ public class SurvivalFly extends Check { } - final boolean resetTo = toOnGround || to.isInLiquid() || to.isOnLadder() || to.isInWeb(); + final boolean resetTo = toOnGround || to.isResetCond(); if (cc.survivalFlyAccountingH && !resetFrom && !resetTo) { // Currently only for "air" phases. diff --git a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java index 77794098..f783e89d 100644 --- a/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java +++ b/src/fr/neatmonster/nocheatplus/utilities/PlayerLocation.java @@ -358,6 +358,15 @@ public class PlayerLocation { } return onGround; } + + /** + * Reset condition for flying checks (sf + nofall): fluids, web, ladder (not on-ground, though). + * @return + */ + public boolean isResetCond(){ + // NOTE: if optimizing, setYOnGround has to be kept in mind. + return isInLiquid() || isOnLadder() || isInWeb(); + } public double getyOnGround() { return yOnGround;