Use manhattan method for WrongBlock (not a change for the logic).

This commit is contained in:
asofold 2014-02-16 19:26:12 +01:00
parent 3f78497fde
commit a198133cfa

View File

@ -7,6 +7,7 @@ import fr.neatmonster.nocheatplus.checks.Check;
import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.combined.Improbable; import fr.neatmonster.nocheatplus.checks.combined.Improbable;
import fr.neatmonster.nocheatplus.permissions.Permissions; import fr.neatmonster.nocheatplus.permissions.Permissions;
import fr.neatmonster.nocheatplus.utilities.TrigUtil;
public class WrongBlock extends Check { public class WrongBlock extends Check {
@ -30,7 +31,7 @@ public class WrongBlock extends Check {
boolean cancel = false; boolean cancel = false;
final boolean wrongTime = data.fastBreakfirstDamage < data.fastBreakBreakTime; final boolean wrongTime = data.fastBreakfirstDamage < data.fastBreakBreakTime;
final int dist = Math.abs(data.clickedX - block.getX()) + Math.abs(data.clickedY - block.getY()) + Math.abs(data.clickedZ - block.getZ()); final int dist = TrigUtil.manhattan(data.clickedX, data.clickedY, data.clickedZ, block);
final boolean wrongBlock; final boolean wrongBlock;
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
if (dist == 0){ if (dist == 0){
@ -54,9 +55,9 @@ public class WrongBlock extends Check {
if (wrongBlock){ if (wrongBlock){
// Manhattan distance. // Manhattan distance.
if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){ if ((cc.fastBreakDebug || cc.debug) && player.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
player.sendMessage("WrongBlock failure with dist: " + dist); player.sendMessage("WrongBlock failure with dist: " + dist);
} }
data.wrongBlockVL.add(now, (float) (dist + 1) / 2f); data.wrongBlockVL.add(now, (float) (dist + 1) / 2f);
final float score = data.wrongBlockVL.score(0.9f); final float score = data.wrongBlockVL.score(0.9f);
if (score > cc.wrongBLockLevel){ if (score > cc.wrongBLockLevel){