diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java index 8ea4d9af..086a6c6a 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java @@ -63,16 +63,18 @@ public class Critical extends Check { boolean cancel = false; final double mcFallDistance = (double) player.getFallDistance(); - final MovingConfig mCc = pData.getGenericInstance(MovingConfig.class); - - if (pData.isDebugActive(type)) { - debug(player, "y=" + loc.getY() + " mcfalldist=" + mcFallDistance); - } // Check if the hit was a critical hit (very small fall-distance, not on ladder, // not in liquid, not in vehicle, and without blindness effect). - if (mcFallDistance > 0.0 && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)) { + if (mcFallDistance > 0.0 && !player.isInsideVehicle() + && !player.hasPotionEffect(PotionEffectType.BLINDNESS)) { + + if (pData.isDebugActive(type)) { + debug(player, "y=" + loc.getY() + " mcfalldist=" + mcFallDistance); + } + // Might be a violation. + final MovingConfig mcc = pData.getGenericInstance(MovingConfig.class); final MovingData dataM = pData.getGenericInstance(MovingData.class); /* * TODO: NoFall data max y. (past moves too perhaps - low jump, @@ -82,12 +84,11 @@ public class Critical extends Check { // TODO: Skip near the highest jump height (needs check if head collided with something solid, which also detects low jump). if (!dataM.isVelocityJumpPhase() && (dataM.sfLowJump && !dataM.sfNoLowJump && dataM.liftOffEnvelope == LiftOffEnvelope.NORMAL - || mcFallDistance < cc.criticalFallDistance && !BlockProperties.isResetCond(player, loc, mCc.yOnGround))) { - final MovingConfig ccM = pData.getGenericInstance(MovingConfig.class); + || mcFallDistance < cc.criticalFallDistance && !BlockProperties.isResetCond(player, loc, mcc.yOnGround))) { // TODO: Use past move tracking to check for SurvivalFly and the like? final PlayerMoveInfo moveInfo = auxMoving.usePlayerMoveInfo(); - moveInfo.set(player, loc, null, ccM.yOnGround); - if (MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, dataM, ccM, pData)) { + moveInfo.set(player, loc, null, mcc.yOnGround); + if (MovingUtil.shouldCheckSurvivalFly(player, moveInfo.from, dataM, mcc, pData)) { data.criticalVL += 1.0; // Execute whatever actions are associated with this check and // the violation level and find out if we should cancel the event.