diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java index 7ac49bb7..3a415af5 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/blockbreak/WrongBlock.java @@ -26,45 +26,49 @@ public class WrongBlock extends Check { * @param isInstaBreak * @return */ - public boolean check(final Player player, final Block block, final BlockBreakConfig cc, final BlockBreakData data, final boolean isInstaBreak){ + public boolean check(final Player player, final Block block, final BlockBreakConfig cc, final BlockBreakData data, final boolean isInstaBreak) { boolean cancel = false; final boolean wrongTime = data.fastBreakfirstDamage < data.fastBreakBreakTime; - final int dist = TrigUtil.manhattan(data.clickedX, data.clickedY, data.clickedZ, block); + final int dist = Math.min(4, data.clickedX == Integer.MAX_VALUE ? 100 : TrigUtil.manhattan(data.clickedX, data.clickedY, data.clickedZ, block)); final boolean wrongBlock; final long now = System.currentTimeMillis(); - if (dist == 0){ - if (wrongTime){ + if (dist == 0) { + if (wrongTime) { data.fastBreakBreakTime = now; data.fastBreakfirstDamage = now; // Could set to wrong block, but prefer to transform it into a quasi insta break. } wrongBlock = false; } - else if (dist == 1){ + else if (dist == 1) { // One might to a concession in case of instant breaking. - if (now - data.wasInstaBreak < 60) + if (now - data.wasInstaBreak < 60) { wrongBlock = false; - else + } + else { wrongBlock = true; + } } - else + else { + // Note that the maximally counted distance is set above. wrongBlock = true; + } - if (wrongBlock){ - // Manhattan distance. - - if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ + if (wrongBlock) { + if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)) { player.sendMessage("WrongBlock failure with dist: " + dist); } data.wrongBlockVL.add(now, (float) (dist + 1) / 2f); final float score = data.wrongBlockVL.score(0.9f); - if (score > cc.wrongBLockLevel){ - if (executeActions(player, score, 1D, cc.wrongBlockActions)) + if (score > cc.wrongBLockLevel) { + if (executeActions(player, score, 1D, cc.wrongBlockActions)) { cancel = true; - if (Improbable.check(player, 2.0f, now, "blockbreak.wrongblock")) + } + if (Improbable.check(player, 2.0f, now, "blockbreak.wrongblock")) { cancel = true; + } } }