From 36b834df9945fb8c0cbdfde12b5f6607a43a5ef8 Mon Sep 17 00:00:00 2001 From: asofold <asofold@web.de> Date: Wed, 19 Sep 2012 13:33:48 +0200 Subject: [PATCH] Adjust how first damage time for block break is updated. --- .../checks/blockbreak/BlockBreakData.java | 3 +++ .../checks/blockbreak/BlockBreakListener.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java index 45862222..15dd3d31 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakData.java @@ -78,6 +78,9 @@ public class BlockBreakData extends ACheckData { public int clickedX; public int clickedY; public int clickedZ; + public int clickedTick; + + // TODO: use tick here too ? public long wasInstaBreak; public final Stats stats; diff --git a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java index 81df8522..f4be982d 100644 --- a/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java +++ b/src/fr/neatmonster/nocheatplus/checks/blockbreak/BlockBreakListener.java @@ -12,6 +12,8 @@ import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerInteractEvent; +import fr.neatmonster.nocheatplus.utilities.TickTask; + /* * M#"""""""'M dP dP M#"""""""'M dP * ## mmmm. `M 88 88 ## mmmm. `M 88 @@ -219,10 +221,11 @@ public class BlockBreakListener implements Listener { if (block == null) return; - // Skip if already set to the same block without breaking. - // TODO: should probably always set or depending on configuration. - if (data.fastBreakBreakTime < data.fastBreakfirstDamage && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()) - return; + final int tick = TickTask.getTick(); + // Skip if already set to the same block without breaking within one tick difference. + if (data.fastBreakBreakTime < data.fastBreakfirstDamage && data.clickedX == block.getX() && data.clickedZ == block.getZ() && data.clickedY == block.getY()){ + if (tick - data.clickedTick <= 1 ) return; + } // (Always set, the interact event only fires once: the first time.) // Only record first damage: @@ -231,6 +234,7 @@ public class BlockBreakListener implements Listener { data.clickedX = block.getX(); data.clickedY = block.getY(); data.clickedZ = block.getZ(); + data.clickedTick = tick; } }