From 19ddaefb4cc67f07afad0464fc50320ffcaf35f6 Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 21 Apr 2013 21:23:51 +0200 Subject: [PATCH] Fix crop trampling being disabled by anticriticals. --- .../nocheatplus/checks/fight/Critical.java | 48 +++++++++---------- .../nocheatplus/checks/moving/NoFall.java | 23 +++++---- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java index c48bad7c..2ab7e7a2 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/fight/Critical.java @@ -64,32 +64,30 @@ public class Critical extends Check { // Check if the hit was a critical hit (positive fall distance, entity in the air, not on ladder, not in liquid // and without blindness effect). - if (mcFallDistance > 0f && !BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround) && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){ - // It was a critical hit, now check if the player has jumped or has sent a packet to mislead the server. - if (player.getFallDistance() < cc.criticalFallDistance) { // removed velocity - final MovingConfig ccM = MovingConfig.getConfig(player); - final MovingData dataM = MovingData.getData(player); - if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){ - final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance()) - / cc.criticalFallDistance; - final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY())) - / cc.criticalVelocity; - final double delta = deltaFallDistance > 0D ? deltaFallDistance - : 0D + deltaVelocity > 0D ? deltaVelocity : 0D; + + // TODO: Skip the on-ground check somehow? + // TODO: Implement low jump penalty. + if (mcFallDistance > 0f && player.getFallDistance() < cc.criticalFallDistance &&!BlockProperties.isOnGroundOrResetCond(player, loc, mCc.yOnGround) && !player.hasPotionEffect(PotionEffectType.BLINDNESS)){ + final MovingConfig ccM = MovingConfig.getConfig(player); + final MovingData dataM = MovingData.getData(player); + if (MovingListener.shouldCheckSurvivalFly(player, dataM, ccM)){ + final double deltaFallDistance = (cc.criticalFallDistance - player.getFallDistance()) + / cc.criticalFallDistance; + final double deltaVelocity = (cc.criticalVelocity - Math.abs(player.getVelocity().getY())) + / cc.criticalVelocity; + final double delta = deltaFallDistance > 0D ? deltaFallDistance + : 0D + deltaVelocity > 0D ? deltaVelocity : 0D; - // Player failed the check, but this is influenced by lag so don't do it if there was lag. - if (TickTask.getLag(1000) < 1.5){ - // TODO: 1.5 is a fantasy value. - // Increment the violation level. - data.criticalVL += delta; - } - - - // Execute whatever actions are associated with this check and the violation level and find out if we - // should cancel the event. - cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions); - } - + // Player failed the check, but this is influenced by lag so don't do it if there was lag. + if (TickTask.getLag(1000) < 1.5){ + // TODO: 1.5 is a fantasy value. + // Increment the violation level. + data.criticalVL += delta; + } + + // Execute whatever actions are associated with this check and the violation level and find out if we + // should cancel the event. + cancel = executeActions(player, data.criticalVL, delta, cc.criticalActions); } } diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java index 32e16927..e85f0898 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/checks/moving/NoFall.java @@ -164,17 +164,24 @@ public class NoFall extends Check { if (!toReset && !toOnGround && yDiff < 0){ data.noFallFallDistance -= yDiff; } - else if (cc.noFallDealDamage && cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){ - // TODO: Only use this if dealdamage is true ? - if (data.noFallFallDistance > 0){ - data.noFallFallDistance = 0; + else if (cc.noFallAntiCriticals && (toReset || toOnGround || (fromReset || fromOnGround || data.noFallAssumeGround) && yDiff >= 0)){ + final double max = Math.max(data.noFallFallDistance, mcFallDistance); + if (max > 0.0 && max < 0.75){ // (Ensure this does not conflict with deal-damage set to false.) + if (cc.debug){ + System.out.println(player.getName() + " NoFall: Reset fall distance (anticriticals): mc=" + StringUtil.fdec3.format(mcFallDistance) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) ); + } + if (data.noFallFallDistance > 0){ + data.noFallFallDistance = 0; + } + if (mcFallDistance > 0){ + player.setFallDistance(0); + } } - if (mcFallDistance > 0){ - player.setFallDistance(0); - } } - if (cc.debug) System.out.println(player.getName() + " NoFall: mc=" + StringUtil.fdec3.format(player.getFallDistance()) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) + (oldNFDist < data.noFallFallDistance ? " (+" + StringUtil.fdec3.format(data.noFallFallDistance - oldNFDist) + ")" : "")); + if (cc.debug){ + System.out.println(player.getName() + " NoFall: mc=" + StringUtil.fdec3.format(mcFallDistance) +" / nf=" + StringUtil.fdec3.format(data.noFallFallDistance) + (oldNFDist < data.noFallFallDistance ? " (+" + StringUtil.fdec3.format(data.noFallFallDistance - oldNFDist) + ")" : "")); + } }