Sigma 4.11 SpeedMine module 2 files, 602 lines

Sigma 4.11 SpeedMine: Full Source Analysis

Sigma 4.11's SpeedMine accelerates block breaking by rewriting the client-side dig state every tick.

info/sigmaclient/module/impl/player/SpeedMine.java · GitHub source ↗

Published 2026-08-13 · Updated 2026-08-13

Packets This Module Uses

Analysis

Overview

Sigma 4.11's SpeedMine accelerates block breaking by rewriting the client-side dig state every tick. On each EventTick it sets mc.playerController.blockHitDelay to 0 and, whenever curBlockDamageMP reaches 0.7, snaps it to 1.0. In the fork's PlayerControllerMP.breakBlock, blockHitDelay throttles damage accrual: while it is positive the method decrements it and returns, so vanilla accrues one damage increment per five ticks, and after a block completes the same 5-tick delay gates the next block. Zeroing the delay makes damage accrue every tick, a fivefold accrual rate, and the 0.7-to-1.0 snap finishes each block at roughly 70% of its damage requirement, so a held click completes blocks in a fraction of the vanilla time and the C07 stream shows START_DESTROY_BLOCK followed by STOP_DESTROY_BLOCK far sooner than the block's hardness allows. The module itself sends no packets; the C07 bursts are the fork's own emission driven by the tampered state.

The two client-state writes

EventTick fires once per client tick (the fork's TickEvent dispatcher), and the handler performs both writes unconditionally: blockHitDelay = 0 erases the throttle field, and the 0.7 threshold snap is a one-way clamp (below 0.7 the value is left to accumulate naturally). The writes target the two fields PlayerControllerMP.breakBlock actually reads: the delay gate at line 274 and the completion check at line 297. Because the module runs on the tick event, it re-applies both writes on every tick, so no other code path can re-arm the delay between the module's turns.

What the fork's dig loop does with the tampered state

breakBlock (line 265) fires the fork's EventDamageBlock, syncs the held item, then checks the delay: a positive blockHitDelay decrements and returns without damaging (line 274-276). Otherwise the block's getPlayerRelativeBlockHardness is added to curBlockDamageMP (line 289), and when the accumulator reaches 1.0 the client sends C07 STOP_DESTROY_BLOCK, calls func_178888_a to actually break the block, resets the accumulator and re-arms blockHitDelay = 5 (lines 297-303). With the module's zeroed delay, the first branch never runs, so hardness is added every tick and the completion threshold is reached in one fifth of the vanilla tick count; the 0.7 snap then cuts the last 30% of that already-shortened accrual. The START_DESTROY_BLOCK packet itself comes from onPlayerDamageBlock (lines 221-229), which the module does not touch.

Wire fingerprint

The observable is the C07 dig stream timing: for a given block and held item, the START-to-STOP gap is a small fraction of the hardness-derived duration, and successive blocks complete back to back with no 5-tick pause between them. The server-side break order and the block positions are otherwise normal, so the signature is purely temporal. The client also shows the local break-progress particles completing early, but that is not visible on the wire.

source SpeedMine.java

SpeedMine.java46 lines · JavaOriginal ↗
1
/**
2
 * Time: 5:28:19 AM
3
 * Date: Jan 7, 2017
4
 * Creator: cool1
5
 */
6
package info.sigmaclient.module.impl.player;
7
8
import info.sigmaclient.event.Event;
9
import info.sigmaclient.event.impl.EventTick;
10
import info.sigmaclient.module.Module;
11
import info.sigmaclient.module.data.ModuleData;
12
import info.sigmaclient.event.RegisterEvent;
13
14
/**
15
 * @author cool1
16
 */
17
public class SpeedMine extends Module {
18
19
    /**
20
     * @param data
21
     */
22
    public SpeedMine(ModuleData data) {
23
        super(data);
24
    }
25
26
    /*
27
     * (non-Javadoc)
28
     *
29
     * @see EventListener#onEvent(Event)
30
     */
31
    @Override
32
    @RegisterEvent(events = {EventTick.class})
33
    public void onEvent(Event event) {
34
        mc.playerController.blockHitDelay = 0;
35
        if (mc.playerController.curBlockDamageMP >= 0.7F) {
36
            mc.playerController.curBlockDamageMP = 1.0F;
37
        }
38
    }
39
40
41
    @Override
42
    public void onDisable() {
43
        super.onDisable();
44
    }
45
46
}

What this file does

The module is this file alone: a constructor, an EventTick handler, and an empty onDisable. The handler performs the two writes on every tick - mc.playerController.blockHitDelay = 0 and the curBlockDamageMP >= 0.7F snap to 1.0F - and nothing else. There is no packet access, no world interaction, and no state of its own; the entire module is a periodic tamper with two fields of the shared PlayerControllerMP. The onDisable override calls super and adds nothing, so disabling the module simply stops the writes and the controller's own logic resumes (the delay re-arms itself via the vanilla assignments at lines 278 and 303). The 0.7 threshold is hard-coded rather than a setting.

source PlayerControllerMP.java (dig state machine)

PlayerControllerMP.java556 lines · JavaOriginal ↗
1
package net.minecraft.client.multiplayer;
2
3
import info.sigmaclient.Client;
4
import info.sigmaclient.event.EventSystem;
5
import info.sigmaclient.event.impl.EventAttack;
6
import info.sigmaclient.event.impl.EventDamageBlock;
7
import info.sigmaclient.event.impl.EventJump;
8
import info.sigmaclient.management.MoveUtils;
9
import info.sigmaclient.module.impl.combat.Criticals;
10
import info.sigmaclient.module.impl.combat.Killaura;
11
import info.sigmaclient.module.impl.movement.Bhop;
12
import info.sigmaclient.module.impl.movement.LongJump;
13
import info.sigmaclient.module.impl.movement.Phase;
14
import info.sigmaclient.module.impl.render.Freecam;
15
import info.sigmaclient.util.Timer;
16
import info.sigmaclient.util.misc.ChatUtil;
17
import net.minecraft.block.Block;
18
import net.minecraft.block.material.Material;
19
import net.minecraft.block.state.IBlockState;
20
import net.minecraft.client.Minecraft;
21
import net.minecraft.client.audio.PositionedSoundRecord;
22
import net.minecraft.client.entity.EntityPlayerSP;
23
import net.minecraft.client.network.NetHandlerPlayClient;
24
import net.minecraft.entity.Entity;
25
import net.minecraft.entity.passive.EntityHorse;
26
import net.minecraft.entity.player.EntityPlayer;
27
import net.minecraft.item.ItemBlock;
28
import net.minecraft.item.ItemStack;
29
import net.minecraft.item.ItemSword;
30
import net.minecraft.network.play.client.*;
31
import net.minecraft.potion.Potion;
32
import net.minecraft.stats.StatFileWriter;
33
import net.minecraft.util.*;
34
import net.minecraft.world.World;
35
import net.minecraft.world.WorldSettings;
36
37
public class PlayerControllerMP {
38
    /**
39
     * The Minecraft instance.
40
     */
41
    private final Minecraft mc;
42
    public final NetHandlerPlayClient netClientHandler;
43
    private BlockPos field_178895_c = new BlockPos(-1, -1, -1);
44
    /**
45
     * The Item currently being used to destroy a block
46
     */
47
    private ItemStack currentItemHittingBlock;
48
49
    /**
50
     * Current block damage (MP)
51
     */
52
    public float curBlockDamageMP;
53
54
    /**
55
     * Tick counter, when it hits 4 it resets back to 0 and plays the step sound
56
     */
57
    private float stepSoundTickCounter;
58
59
    /**
60
     * Delays the first damage on the block after the first click on the block
61
     */
62
    public int blockHitDelay;
63
64
    /**
65
     * Tells if the player is hitting a block
66
     */
67
    private boolean isHittingBlock;
68
    public static boolean canPlace = false;
69
    /**
70
     * Current game type for the player
71
     */
72
    private WorldSettings.GameType currentGameType;
73
74
    /**
75
     * Index of the current item held by the player in the inventory hotbar
76
     */
77
    private int currentPlayerItem;
78
    private static final String __OBFID = "CL_00000881";
79
80
    public PlayerControllerMP(Minecraft mcIn, NetHandlerPlayClient p_i45062_2_) {
81
        this.currentGameType = WorldSettings.GameType.SURVIVAL;
82
        this.mc = mcIn;
83
        this.netClientHandler = p_i45062_2_;
84
    }
85
86
    public WorldSettings.GameType getCurrentGameType() {
87
        return currentGameType;
88
    }
89
90
    public static void func_178891_a(Minecraft mcIn, PlayerControllerMP p_178891_1_, BlockPos p_178891_2_, EnumFacing p_178891_3_) {
91
        if (!mcIn.theWorld.func_175719_a(mcIn.thePlayer, p_178891_2_, p_178891_3_)) {
92
            p_178891_1_.func_178888_a(p_178891_2_, p_178891_3_);
93
        }
94
    }
95
96
    /**
97
     * Sets player capabilities depending on current gametype. params: player
98
     */
99
    public void setPlayerCapabilities(EntityPlayer p_78748_1_) {
100
        this.currentGameType.configurePlayerCapabilities(p_78748_1_.capabilities);
101
    }
102
103
    /**
104
     * If modified to return true, the player spins around slowly around (0,
105
     * 68.5, 0). The GUI is disabled, the view is set to first person, and both
106
     * chat and menu are disabled. Unless the server is modified to ignore
107
     * illegal stances, attempting to enter a world at all will result in an
108
     * immediate kick due to an illegal stance. Appears to be left-over debug,
109
     * or demo code.
110
     */
111
    public boolean enableEverythingIsScrewedUpMode() {
112
        return this.currentGameType == WorldSettings.GameType.SPECTATOR;
113
    }
114
115
    /**
116
     * Sets the game type for the player.
117
     */
118
    public void setGameType(WorldSettings.GameType p_78746_1_) {
119
        this.currentGameType = p_78746_1_;
120
        this.currentGameType.configurePlayerCapabilities(this.mc.thePlayer.capabilities);
121
    }
122
123
    /**
124
     * Flips the player around.
125
     */
126
    public void flipPlayer(EntityPlayer playerIn) {
127
        playerIn.rotationYaw = -180.0F;
128
    }
129
130
    public boolean shouldDrawHUD() {
131
        return this.currentGameType.isSurvivalOrAdventure();
132
    }
133
134
    public static String getHwid() throws Exception {
135
        String s = "";
136
        return s;
137
    }
138
139
    public boolean func_178888_a(BlockPos p_178888_1_, EnumFacing p_178888_2_) {
140
        if (this.currentGameType.isAdventure()) {
141
            if (this.currentGameType == WorldSettings.GameType.SPECTATOR) {
142
                return false;
143
            }
144
145
            if (!this.mc.thePlayer.func_175142_cm()) {
146
                Block var3 = this.mc.theWorld.getBlockState(p_178888_1_).getBlock();
147
                ItemStack var4 = this.mc.thePlayer.getCurrentEquippedItem();
148
149
                if (var4 == null) {
150
                    return false;
151
                }
152
153
                if (!var4.canDestroy(var3)) {
154
                    return false;
155
                }
156
            }
157
        }
158
159
        if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword) {
160
            return false;
161
        } else {
162
            WorldClient var8 = this.mc.theWorld;
163
            IBlockState var9 = var8.getBlockState(p_178888_1_);
164
            Block var5 = var9.getBlock();
165
166
            if (var5.getMaterial() == Material.air) {
167
                return false;
168
            } else {
169
                var8.playAuxSFX(2001, p_178888_1_, Block.getStateId(var9));
170
                boolean var6 = var8.setBlockToAir(p_178888_1_);
171
172
                if (var6) {
173
                    var5.onBlockDestroyedByPlayer(var8, p_178888_1_, var9);
174
                }
175
176
                this.field_178895_c = new BlockPos(this.field_178895_c.getX(), -1, this.field_178895_c.getZ());
177
178
                if (!this.currentGameType.isCreative()) {
179
                    ItemStack var7 = this.mc.thePlayer.getCurrentEquippedItem();
180
181
                    if (var7 != null) {
182
                        var7.onBlockDestroyed(var8, var5, p_178888_1_, this.mc.thePlayer);
183
184
                        if (var7.stackSize == 0) {
185
                            this.mc.thePlayer.destroyCurrentEquippedItem();
186
                        }
187
                    }
188
                }
189
190
                return var6;
191
            }
192
        }
193
    }
194
195
    public boolean func_180511_b(BlockPos p_180511_1_, EnumFacing p_180511_2_) {
196
        Block var3;
197
198
        if (this.currentGameType.isAdventure()) {
199
            if (this.currentGameType == WorldSettings.GameType.SPECTATOR) {
200
                return false;
201
            }
202
203
            if (!this.mc.thePlayer.func_175142_cm()) {
204
                var3 = this.mc.theWorld.getBlockState(p_180511_1_).getBlock();
205
                ItemStack var4 = this.mc.thePlayer.getCurrentEquippedItem();
206
207
                if (var4 == null) {
208
                    return false;
209
                }
210
211
                if (!var4.canDestroy(var3)) {
212
                    return false;
213
                }
214
            }
215
        }
216
217
        if (!this.mc.theWorld.getWorldBorder().contains(p_180511_1_)) {
218
            return false;
219
        } else {
220
            if (this.currentGameType.isCreative()) {
221
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, p_180511_1_, p_180511_2_));
222
                func_178891_a(this.mc, this, p_180511_1_, p_180511_2_);
223
                this.blockHitDelay = 5;
224
            } else if (!this.isHittingBlock || !this.func_178893_a(p_180511_1_)) {
225
                if (this.isHittingBlock) {
226
                    this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.field_178895_c, p_180511_2_));
227
                }
228
229
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, p_180511_1_, p_180511_2_));
230
                var3 = this.mc.theWorld.getBlockState(p_180511_1_).getBlock();
231
                boolean var5 = var3.getMaterial() != Material.air;
232
233
                if (var5 && this.curBlockDamageMP == 0.0F) {
234
                    var3.onBlockClicked(this.mc.theWorld, p_180511_1_, this.mc.thePlayer);
235
                }
236
237
                if (var5 && var3.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, p_180511_1_) >= 1.0F) {
238
                    this.func_178888_a(p_180511_1_, p_180511_2_);
239
                } else {
240
                    this.isHittingBlock = true;
241
                    this.field_178895_c = p_180511_1_;
242
                    this.currentItemHittingBlock = this.mc.thePlayer.getHeldItem();
243
                    this.curBlockDamageMP = 0.0F;
244
                    this.stepSoundTickCounter = 0.0F;
245
                    this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.field_178895_c, (int) (this.curBlockDamageMP * 10.0F) - 1);
246
                }
247
            }
248
249
            return true;
250
        }
251
    }
252
253
    /**
254
     * Resets current block damage and isHittingBlock
255
     */
256
    public void resetBlockRemoving() {
257
        if (this.isHittingBlock) {
258
            this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.ABORT_DESTROY_BLOCK, this.field_178895_c, EnumFacing.DOWN));
259
            this.isHittingBlock = false;
260
            this.curBlockDamageMP = 0.0F;
261
            this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.field_178895_c, -1);
262
        }
263
    }
264
265
    public boolean breakBlock(BlockPos p_180512_1_, EnumFacing p_180512_2_) {
266
        try {
267
            EventDamageBlock event = (EventDamageBlock) EventSystem.getInstance(EventDamageBlock.class);
268
            event.fire(p_180512_1_);
269
            if (event.isCancelled()) {
270
                return false;
271
            }
272
            this.syncCurrentPlayItem();
273
274
            if (this.blockHitDelay > 0) {
275
                --this.blockHitDelay;
276
                return true;
277
            } else if ((this.currentGameType.isCreative() || Client.getModuleManager().get(Freecam.class).isEnabled()) && this.mc.theWorld.getWorldBorder().contains(p_180512_1_)) {
278
                this.blockHitDelay = 5;
279
                this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, p_180512_1_, p_180512_2_));
280
                func_178891_a(this.mc, this, p_180512_1_, p_180512_2_);
281
                return true;
282
            } else if (this.func_178893_a(p_180512_1_)) {
283
                Block var3 = this.mc.theWorld.getBlockState(p_180512_1_).getBlock();
284
285
                if (var3.getMaterial() == Material.air) {
286
                    this.isHittingBlock = false;
287
                    return false;
288
                } else {
289
                    this.curBlockDamageMP += var3.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, p_180512_1_);
290
291
                    if (this.stepSoundTickCounter % 4.0F == 0.0F) {
292
                        this.mc.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(var3.stepSound.getStepSound()), (var3.stepSound.getVolume() + 1.0F) / 8.0F, var3.stepSound.getFrequency() * 0.5F, (float) p_180512_1_.getX() + 0.5F, (float) p_180512_1_.getY() + 0.5F, (float) p_180512_1_.getZ() + 0.5F));
293
                    }
294
295
                    ++this.stepSoundTickCounter;
296
297
                    if (this.curBlockDamageMP >= 1.0F) {
298
                        this.isHittingBlock = false;
299
                        this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, p_180512_1_, p_180512_2_));
300
                        this.func_178888_a(p_180512_1_, p_180512_2_);
301
                        this.curBlockDamageMP = 0.0F;
302
                        this.stepSoundTickCounter = 0.0F;
303
                        this.blockHitDelay = 5;
304
                    }
305
306
                    this.mc.theWorld.sendBlockBreakProgress(this.mc.thePlayer.getEntityId(), this.field_178895_c, (int) (this.curBlockDamageMP * 10.0F) - 1);
307
                    return true;
308
                }
309
            } else {
310
                return this.func_180511_b(p_180512_1_, p_180512_2_);
311
            }
312
        } catch (Exception e) {
313
            return false;
314
        }
315
    }
316
317
    /**
318
     * player reach distance = 4F
319
     */
320
    public float getBlockReachDistance() {
321
        return this.currentGameType.isCreative() ? 5.0F : 4.5F;
322
    }
323
324
    public void updateController() {
325
        this.syncCurrentPlayItem();
326
327
        if (this.netClientHandler.getNetworkManager().isChannelOpen()) {
328
            this.netClientHandler.getNetworkManager().processReceivedPackets();
329
        } else {
330
            this.netClientHandler.getNetworkManager().checkDisconnected();
331
        }
332
    }
333
334
    private boolean func_178893_a(BlockPos p_178893_1_) {
335
        ItemStack var2 = this.mc.thePlayer.getHeldItem();
336
        boolean var3 = this.currentItemHittingBlock == null && var2 == null;
337
338
        if (this.currentItemHittingBlock != null && var2 != null) {
339
            var3 = var2.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(var2, this.currentItemHittingBlock) && (var2.isItemStackDamageable() || var2.getMetadata() == this.currentItemHittingBlock.getMetadata());
340
        }
341
342
        return p_178893_1_.equals(this.field_178895_c) && var3;
343
    }
344
345
    /**
346
     * Syncs the current player item with the server
347
     */
348
    public void syncCurrentPlayItem() {
349
        int var1 = this.mc.thePlayer.inventory.currentItem;
350
351
        if (var1 != this.currentPlayerItem) {
352
            this.currentPlayerItem = var1;
353
            this.netClientHandler.addToSendQueue(new C09PacketHeldItemChange(this.currentPlayerItem));
354
        }
355
    }
356
357
    public boolean func_178890_a(EntityPlayerSP player, WorldClient world, ItemStack stack, BlockPos pos, EnumFacing facing, Vec3 vec) {
358
    //TODO
359
    	if(mc.thePlayer.inventoryContainer.getSlot(36 + mc.thePlayer.inventory.currentItem).getHasStack())
360
        	if(mc.thePlayer.getItemInUseCount() == 1 && mc.thePlayer.inventory.getCurrentItem().getItem() instanceof ItemSword && Client.getModuleManager().isEnabled(Killaura.class)){
361
        		return false;
362
        	}
363
    	this.syncCurrentPlayItem();
364
        float var7 = (float) (vec.xCoord - (double) pos.getX());
365
        float var8 = (float) (vec.yCoord - (double) pos.getY());
366
        float var9 = (float) (vec.zCoord - (double) pos.getZ());
367
        boolean var10 = false;
368
369
        if (!this.mc.theWorld.getWorldBorder().contains(pos)) {
370
            return false;
371
        } else {
372
            if (this.currentGameType != WorldSettings.GameType.SPECTATOR) {
373
                IBlockState var11 = world.getBlockState(pos);
374
375
                if ((!player.isSneaking() || player.getHeldItem() == null) && var11.getBlock().onBlockActivated(world, pos, var11, player, facing, var7, var8, var9)) {
376
                    var10 = true;
377
                }
378
379
                if (!var10 && stack != null && stack.getItem() instanceof ItemBlock) {
380
                    ItemBlock var12 = (ItemBlock) stack.getItem();
381
                    //TODO
382
                    if (!var12.canPlaceBlockOnSide(world, pos, facing, player, stack) && !Client.getModuleManager().isEnabled(Phase.class) && !canPlace) {
383
                        return false;
384
                    }
385
                }
386
            }
387
388
            this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(pos, facing.getIndex(), player.inventory.getCurrentItem(), var7, var8, var9));
389
390
            if (!var10 && this.currentGameType != WorldSettings.GameType.SPECTATOR) {
391
                if (stack == null) {
392
                    return false;
393
                } else if (this.currentGameType.isCreative()) {
394
                    int meta = stack.getMetadata();
395
                    int stackSize = stack.stackSize;
396
                    boolean itemUsed = stack.onItemUse(player, world, pos, facing, var7, var8, var9);
397
                    stack.setItemDamage(meta);
398
                    stack.stackSize = stackSize;
399
                    return itemUsed;
400
                } else {
401
                	
402
                    return stack.onItemUse(player, world, pos, facing, var7, var8, var9);
403
                }
404
            } else {
405
                return true;
406
            }
407
        }
408
    }
409
410
    /**
411
     * Notifies the server of things like consuming food, etc...
412
     */
413
    public boolean sendUseItem(EntityPlayer playerIn, World worldIn, ItemStack itemStackIn) {
414
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR) {
415
            return false;
416
        }
417
        //TODO
418
        if(mc.thePlayer.getItemInUseCount() == 999 && itemStackIn.getItem() instanceof ItemSword && Killaura.blockTarget != null){
419
        	return false;
420
        }
421
        this.syncCurrentPlayItem();
422
        this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(playerIn.inventory.getCurrentItem()));
423
        final int var4 = itemStackIn.stackSize;
424
        final ItemStack var5 = itemStackIn.useItemRightClick(worldIn, playerIn);
425
        if (var5 == itemStackIn && (var5 == null || var5.stackSize == var4)) {
426
            return false;
427
        }
428
        playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = var5;
429
        if (var5.stackSize == 0) {
430
            playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
431
        }
432
        return true;
433
    }
434
435
    public EntityPlayerSP func_178892_a(World worldIn, StatFileWriter p_178892_2_) {
436
        return new EntityPlayerSP(this.mc, worldIn, this.netClientHandler, p_178892_2_);
437
    }
438
439
    /**
440
     * Attacks an entity
441
     */
442
    public void attackEntity(EntityPlayer playerIn, Entity targetEntity) {
443
        this.syncCurrentPlayItem();
444
        this.netClientHandler.addToSendQueue(new C02PacketUseEntity(targetEntity, C02PacketUseEntity.Action.ATTACK));
445
      
446
        if (this.currentGameType != WorldSettings.GameType.SPECTATOR) {
447
            playerIn.attackTargetEntityWithCurrentItem(targetEntity);
448
        }
449
        
450
    }
451
452
    /**
453
     * Send packet to server - player is interacting with another entity (left
454
     * click)
455
     */
456
    public boolean interactWithEntitySendPacket(EntityPlayer playerIn, Entity targetEntity) {
457
        this.syncCurrentPlayItem();
458
        this.netClientHandler.addToSendQueue(new C02PacketUseEntity(targetEntity, C02PacketUseEntity.Action.INTERACT));
459
        return this.currentGameType != WorldSettings.GameType.SPECTATOR && playerIn.interactWith(targetEntity);
460
    }
461
462
    public boolean func_178894_a(EntityPlayer p_178894_1_, Entity p_178894_2_, MovingObjectPosition p_178894_3_) {
463
        this.syncCurrentPlayItem();
464
        Vec3 var4 = new Vec3(p_178894_3_.hitVec.xCoord - p_178894_2_.posX, p_178894_3_.hitVec.yCoord - p_178894_2_.posY, p_178894_3_.hitVec.zCoord - p_178894_2_.posZ);
465
        this.netClientHandler.addToSendQueue(new C02PacketUseEntity(p_178894_2_, var4));
466
        return this.currentGameType != WorldSettings.GameType.SPECTATOR && p_178894_2_.func_174825_a(p_178894_1_, var4);
467
    }
468
469
    /**
470
     * Handles slot clicks sends a packet to the server.
471
     */
472
    public ItemStack windowClick(int windowId, int slotId, int p_78753_3_, int p_78753_4_, EntityPlayer playerIn) {
473
        short var6 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
474
        ItemStack var7 = playerIn.openContainer.slotClick(slotId, p_78753_3_, p_78753_4_, playerIn);
475
        this.netClientHandler.addToSendQueue(new C0EPacketClickWindow(windowId, slotId, p_78753_3_, p_78753_4_, var7, var6));
476
        return var7;
477
    }
478
479
    /**
480
     * GuiEnchantment uses this during multiplayer to tell PlayerControllerMP to
481
     * send a packet indicating the enchantment action the player has taken.
482
     */
483
    public void sendEnchantPacket(int p_78756_1_, int p_78756_2_) {
484
        this.netClientHandler.addToSendQueue(new C11PacketEnchantItem(p_78756_1_, p_78756_2_));
485
    }
486
487
    /**
488
     * Used in PlayerControllerMP to update the server with an ItemStack in a
489
     * slot.
490
     */
491
    public void sendSlotPacket(ItemStack itemStackIn, int slotId) {
492
        if (this.currentGameType.isCreative()) {
493
            this.netClientHandler.addToSendQueue(new C10PacketCreativeInventoryAction(slotId, itemStackIn));
494
        }
495
    }
496
497
    /**
498
     * Sends a Packet107 to the server to drop the item on the ground
499
     */
500
    public void sendPacketDropItem(ItemStack itemStackIn) {
501
        if (this.currentGameType.isCreative() && itemStackIn != null) {
502
            this.netClientHandler.addToSendQueue(new C10PacketCreativeInventoryAction(-1, itemStackIn));
503
        }
504
    }
505
506
    public void onStoppedUsingItem(EntityPlayer playerIn) {
507
        this.syncCurrentPlayItem();
508
        this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
509
        playerIn.stopUsingItem();
510
    }
511
512
    public boolean gameIsSurvivalOrAdventure() {
513
        return this.currentGameType.isSurvivalOrAdventure();
514
    }
515
516
    /**
517
     * Checks if the player is not creative, used for checking if it should
518
     * break a block instantly
519
     */
520
    public boolean isNotCreative() {
521
        return !this.currentGameType.isCreative();
522
    }
523
524
    /**
525
     * returns true if player is in creative mode
526
     */
527
    public boolean isInCreativeMode() {
528
        return this.currentGameType.isCreative();
529
    }
530
531
    /**
532
     * true for hitting entities far away.
533
     */
534
    public boolean extendedReach() {
535
        return this.currentGameType.isCreative();
536
    }
537
538
    /**
539
     * Checks if the player is riding a horse, used to chose the GUI to open
540
     */
541
    public boolean isRidingHorse() {
542
        return this.mc.thePlayer.isRiding() && this.mc.thePlayer.ridingEntity instanceof EntityHorse;
543
    }
544
545
    public float getCurBlockDamageMP() {
546
        return curBlockDamageMP;
547
    }
548
549
    public boolean isSpectatorMode() {
550
        return this.currentGameType == WorldSettings.GameType.SPECTATOR;
551
    }
552
553
    public WorldSettings.GameType func_178889_l() {
554
        return this.currentGameType;
555
    }
556
}

What this file does

This file is where the tampered fields live and where the C07 stream is emitted. blockHitDelay (declared line 62) is the throttle: breakBlock decrements it and returns while positive (lines 274-276), and both the creative/Freecam branch (line 278) and the completion branch (line 303) re-arm it to 5, so vanilla damage accrues at one increment per five ticks and each finished block gates the next by five ticks. curBlockDamageMP (declared line 52) accumulates getPlayerRelativeBlockHardness per damage tick (line 289) and, at 1.0, triggers C07 STOP_DESTROY_BLOCK plus func_178888_a (lines 297-301). The START_DESTROY_BLOCK packet is emitted from onPlayerDamageBlock (lines 221-229), which also re-arms the delay. Zeroing blockHitDelay makes the gate at line 274 always fall through, which is what converts the five-tick cycle into a per-tick cycle; the module's snap then pushes the completion check forward. The file also shows the fork's EventDamageBlock hook (line 267), an event SpeedMine does not use.

anticheat Countering Checks

The anticheat code that detects or counters the techniques this module uses. Full source, with the detection mechanism explained below each box.

anticheat FastBreak (expected break duration)

FastBreak.java135 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.blockbreak;
16
17
import org.bukkit.Material;
18
import org.bukkit.block.Block;
19
import org.bukkit.entity.Player;
20
import org.bukkit.inventory.ItemStack;
21
22
import fr.neatmonster.nocheatplus.actions.ParameterName;
23
import fr.neatmonster.nocheatplus.checks.Check;
24
import fr.neatmonster.nocheatplus.checks.CheckType;
25
import fr.neatmonster.nocheatplus.checks.ViolationData;
26
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
27
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
28
import fr.neatmonster.nocheatplus.compat.bukkit.BridgePotionEffect;
29
import fr.neatmonster.nocheatplus.permissions.Permissions;
30
import fr.neatmonster.nocheatplus.players.IPlayerData;
31
import fr.neatmonster.nocheatplus.utilities.TickTask;
32
import fr.neatmonster.nocheatplus.utilities.entity.PotionUtil;
33
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
34
35
/**
36
 * A check used to verify if the player is breaking blocks faster than possible.
37
 */
38
public class FastBreak extends Check {
39
40
    /**
41
     * Instantiates a new fast break check.
42
     */
43
    public FastBreak() {
44
        super(CheckType.BLOCKBREAK_FASTBREAK);
45
    }
46
47
    /**
48
     * Checks a player for fastbreak. This is NOT for creative mode.
49
     * @return true, if successful
50
     */
51
    public boolean check(final Player player, final Block block, final AlmostBoolean isInstaBreak, final BlockBreakConfig cc, final BlockBreakData data, final IPlayerData pData) {
52
        final long now = System.currentTimeMillis();
53
        boolean cancel = false;
54
        // Determine expected breaking time by block type.
55
        final Material blockType = block.getType();
56
        final long expectedBreakingTime = Math.max(0, Math.round((double) BlockProperties.getBreakingDuration(blockType, player) * (double) cc.fastBreakModSurvival / 100D));
57
        final long elapsedTime;
58
        // Counting interact...break.
59
        // TODO: Concept for unbreakable blocks? Context: extreme VL.
60
        // TODO: Should it be breakingTime instead of 0 for inconsistencies?
61
        elapsedTime = cc.fastBreakStrict ? (data.fastBreakBreakTime > data.fastBreakfirstDamage) ? 0 : now - data.fastBreakfirstDamage
62
                                         // Counting break...break.
63
                                         : (data.fastBreakBreakTime > now) ? 0 : now - data.fastBreakBreakTime;
64
65
        // Check if the time spent is lower than expected.
66
        if (isInstaBreak.decideOptimistically()) {
67
            // Ignore these for now.
68
            // TODO: Find out why this was commented out long ago a) did not fix mcMMO b) exploits.
69
            // TODO: Maybe adjust time to min(time, SOMETHING) for MAYBE/YES.
70
        }
71
        else if (elapsedTime < 0) {
72
            // Ignore it. TODO: ?
73
        }
74
        else if (elapsedTime + cc.fastBreakDelay < expectedBreakingTime) {
75
            // Lag or cheat or Minecraft.
76
            // Count in server side lag, if desired.
77
            final float serverLagFactor = pData.getCurrentWorldDataSafe().shouldAdjustToLag(type) ? TickTask.getLag(expectedBreakingTime, true) : 1f;
78
            final long missingTime = expectedBreakingTime - (long)(serverLagFactor * elapsedTime);
79
            if (missingTime > 0) {
80
                // Add as penalty
81
                data.fastBreakPenalties.add(now, (float) missingTime);
82
                // Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
83
                if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakGrace) {
84
                    // TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
85
                    final double violation = (double) missingTime / 1000.0;
86
                    data.fastBreakVL += violation;
87
                    final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, violation, cc.fastBreakActions);
88
                    if (vd.needsParameters()) {
89
                        vd.setParameter(ParameterName.BLOCK_TYPE, blockType.toString());
90
                    }
91
                    cancel = executeActions(vd).willCancel();
92
                }
93
                // else: still within contention limits.
94
            }
95
        }
96
        else if (expectedBreakingTime > cc.fastBreakDelay) {
97
            // Fast breaking does not decrease violation level.
98
            data.fastBreakVL *= 0.9D;
99
        }
100
101
        // TODO: Rework to use (then hopefully completed) BlockBreakKey.
102
        if (pData.isDebugActive(type)) {
103
            detailDebugStats(player, isInstaBreak, blockType, elapsedTime, expectedBreakingTime, data, pData);
104
        }
105
        else {
106
            data.stats = null;
107
        }
108
        // (The break time is set in the listener).
109
        return cancel;
110
    }
111
112
    private void detailDebugStats(final Player player, final AlmostBoolean isInstaBreak,
113
                                  final Material blockType, final long elapsedTime, final long expectedBreakingTime,
114
                                  final BlockBreakData data, final IPlayerData pData) {
115
        if (pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
116
            // General stats:
117
            // TODO: Replace stats by new system (BlockBreakKey once complete), commands to inspect / auto-config.
118
            data.setStats();
119
            data.stats.addStats(data.stats.getId(blockType+ "/u", true), elapsedTime);
120
            data.stats.addStats(data.stats.getId(blockType + "/r", true), expectedBreakingTime);
121
            player.sendMessage(data.stats.getStatsStr(true));
122
            // Send info about current break:
123
            final ItemStack stack = Bridge1_9.getItemInMainHand(player);
124
            final boolean isValidTool = BlockProperties.isValidTool(blockType, stack);
125
            final double haste = PotionUtil.getPotionEffectAmplifier(player, BridgePotionEffect.HASTE);
126
            String msg = (isInstaBreak.decideOptimistically() ? ("[Insta=" + isInstaBreak + "]") : "[Normal]") + "[" + blockType + "] "+ elapsedTime + "u / " + expectedBreakingTime +"r (" + (isValidTool?"tool":"no-tool") + ")" + (Double.isInfinite(haste) ? "" : " haste=" + ((int) haste + 1));
127
            player.sendMessage(msg);
128
            //          net.minecraft.server.Item mcItem = net.minecraft.server.Item.byId[stack.getTypeId()];
129
            //          if (mcItem != null) {
130
            //              double x = mcItem.getDestroySpeed(((CraftItemStack) stack).getHandle(), net.minecraft.server.Block.byId[blockId]);
131
            //              player.sendMessage("mc speed: " + x);
132
            //          }
133
        }
134
    }
135
}

How it counteracts this module

NCP's FastBreak computes the expected breaking time for the target block from BlockProperties.getBreakingDuration(blockType, player) scaled by the fastBreakModSurvival percentage, then compares it against the elapsed time between the first damage and the completion (or between the last two breaks in non-strict mode). If the elapsed time plus the fastBreakDelay is below the expectation, the missing time is added as a penalty to data.fastBreakPenalties, and once the bucketed penalty score exceeds fastBreakGrace the check raises a violation, adds missingTime/1000 to fastBreakVL, and executes the configured actions - cancellation being the usual outcome.

SpeedMine is a direct hit. The per-tick accrual breaks blocks in about a fifth of the vanilla duration and the 0.7 snap trims the tail further, so the elapsed time is a fraction of the expected breaking duration on every block. The first few breaks accumulate penalty faster than the grace bucket absorbs, and sustained use keeps the penalties flowing; NCP's lag adaptation (TickTask) cannot explain a consistent sub-fifth duration. The check cancels the break outright once the VL threshold is crossed, which turns the module's advantage into a broken-block-nothing loop.

anticheat Frequency (blocks per time window)

Frequency.java95 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.blockbreak;
16
17
import org.bukkit.GameMode;
18
import org.bukkit.entity.Player;
19
20
import fr.neatmonster.nocheatplus.checks.Check;
21
import fr.neatmonster.nocheatplus.checks.CheckType;
22
import fr.neatmonster.nocheatplus.players.IPlayerData;
23
import fr.neatmonster.nocheatplus.utilities.TickTask;
24
25
/**
26
 * This checks just limits the number of blocks broken per time frame.
27
 * @author asofold
28
 *
29
 */
30
public class Frequency extends Check {
31
32
    public Frequency() {
33
        super(CheckType.BLOCKBREAK_FREQUENCY);
34
    }
35
    
36
    /**
37
     * Checks a player
38
     * @param player
39
     * @param tick
40
     * @param cc
41
     * @param data
42
     * @param pData
43
     * @return true if cancelled.
44
     * 
45
     */
46
    public boolean check(final Player player, final int tick, final BlockBreakConfig cc, final BlockBreakData data, final IPlayerData pData) {
47
        final float interval = player.getGameMode() == GameMode.CREATIVE ? cc.frequencyIntervalCreative : cc.frequencyIntervalSurvival;
48
        data.frequencyBuckets.add(System.currentTimeMillis(), (float)interval);
49
        // Full period frequency.
50
        final float fullScore = data.frequencyBuckets.score(cc.frequencyBucketFactor);
51
        final long fullTime = cc.frequencyBucketDur * cc.frequencyBuckets;
52
        final boolean lag = pData.getCurrentWorldData().shouldAdjustToLag(type);
53
54
        // Short term limit.
55
        if (tick < data.frequencyShortTermTick) {
56
            // Tick task got reset.
57
            data.frequencyShortTermTick = tick;
58
            data.frequencyShortTermCount = 1;
59
        }
60
        else if (tick - data.frequencyShortTermTick < cc.frequencyShortTermTicks) {
61
            // Account for server side lag.
62
            if (!lag || TickTask.getLag(50L * (tick - data.frequencyShortTermTick), true) < 1.5f) {
63
                // Within range, add.
64
                data.frequencyShortTermCount ++;
65
            }
66
            else {
67
                // Too much lag, reset.
68
                data.frequencyShortTermTick = tick;
69
                data.frequencyShortTermCount = 1;
70
            }
71
        }
72
        else {
73
            data.frequencyShortTermTick = tick;
74
            data.frequencyShortTermCount = 1;
75
        }
76
77
        // Account for server side lag for the medium term check
78
        final float fullLag = lag ? TickTask.getLag(fullTime, true) : 1f;
79
        // Find if one or both are violations:
80
        final float fullViolation = (fullScore > fullTime * fullLag) ? (fullScore - fullTime * fullLag) : 0;
81
        final float shortTermWeight = 50f * cc.frequencyShortTermTicks / (float) cc.frequencyShortTermLimit; 
82
        final float shortTermViolation = data.frequencyShortTermCount > cc.frequencyShortTermLimit ? (data.frequencyShortTermCount - cc.frequencyShortTermLimit) * shortTermWeight : 0; 
83
        final float violation = Math.max(fullViolation, shortTermViolation);
84
        boolean cancel = false;
85
        if (violation > 0.0) {
86
            final double change = violation / 1000;
87
            data.frequencyVL += change;
88
            cancel = executeActions(player, data.frequencyVL, change, cc.frequencyActions).willCancel();
89
        }
90
        else if (data.frequencyVL > 0d && fullScore < fullTime * .75) {
91
            data.frequencyVL *= 0.95;
92
        }
93
        return cancel;
94
    }
95
}

How it counteracts this module

NCP's blockbreak Frequency check bounds the rate of completed breaks. Every break adds the configured interval (survival or creative) to data.frequencyBuckets, and the check evaluates two windows: the full-period bucket score against frequencyBucketDur * frequencyBuckets, and a short-term counter that counts breaks inside frequencyShortTermTicks, flagging when the count exceeds frequencyShortTermLimit. Violations are the maximum of the two, scaled and added to frequencyVL, with the actions cancelling.

The module's chain-breaking is exactly the short-term burst this check is built for. The zeroed blockHitDelay removes the five-tick pause between blocks, so a player holding the mouse on a vein completes successive blocks back to back, driving the short-term counter past the limit in a handful of ticks; the full-period window also fills because each block still completes in a fifth of its normal time. NCP's lag tolerance (frequencyShortTermCount is only incremented when the lag factor is under 1.5) does not excuse a sustained sub-tick cadence. Where FastBreak catches the duration of individual breaks, Frequency catches the rate of the chain.

anticheat BlockBreakSpeedSurvival (damage reconstruction)

BlockBreakSpeedSurvival.java246 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.interaction.terrain;
20
21
import me.islandscout.hawk.Hawk;
22
import me.islandscout.hawk.HawkPlayer;
23
import me.islandscout.hawk.check.CustomCheck;
24
import me.islandscout.hawk.event.BlockDigEvent;
25
import me.islandscout.hawk.event.Event;
26
import me.islandscout.hawk.event.MoveEvent;
27
import me.islandscout.hawk.util.MathPlus;
28
import me.islandscout.hawk.util.Placeholder;
29
import me.islandscout.hawk.util.ServerUtils;
30
import me.islandscout.hawk.wrap.block.WrappedBlock;
31
import me.islandscout.hawk.wrap.itemstack.WrappedItemStack;
32
import org.bukkit.GameMode;
33
import org.bukkit.Location;
34
import org.bukkit.Material;
35
import org.bukkit.block.Block;
36
import org.bukkit.enchantments.Enchantment;
37
import org.bukkit.entity.Player;
38
import org.bukkit.potion.PotionEffectType;
39
import org.bukkit.util.Vector;
40
41
import java.util.HashMap;
42
import java.util.Map;
43
import java.util.UUID;
44
45
public class BlockBreakSpeedSurvival extends CustomCheck {
46
47
    private final Map<UUID, Long> interactTick;
48
    private final Map<UUID, Block> targetBlockMap;
49
    private final Map<UUID, Float> blockDamageCumulativeMap;
50
    private boolean CHECK_ON_GROUND;
51
    private final boolean PREVENT_SAME_TICK;
52
53
    public BlockBreakSpeedSurvival() {
54
        super("blockbreakspeedsurvival", true, 5, 10, 0.99, 5000, "%player% failed block break speed. Block: %block%, Speed: %speed%, VL: %vl%", null);
55
        interactTick = new HashMap<>();
56
        targetBlockMap = new HashMap<>();
57
        blockDamageCumulativeMap = new HashMap<>();
58
        CHECK_ON_GROUND = (boolean) customSetting("checkOnGround", "", false);
59
        PREVENT_SAME_TICK = (boolean)customSetting("flagSameTick", "", true);
60
    }
61
62
    @Override
63
    protected void check(Event event) {
64
        if(event instanceof MoveEvent && event.getHawkPlayer().isDigging())
65
            tickDig(event.getHawkPlayer());
66
        else if(event instanceof BlockDigEvent)
67
            checkEvent((BlockDigEvent) event);
68
    }
69
70
    private void tickDig(HawkPlayer pp) {
71
        Block target = targetBlockMap.get(pp.getUuid());
72
        if(target != null && pp.getPlayer().getGameMode() == GameMode.SURVIVAL) {
73
            float accumulatedDamage = blockDamageCumulativeMap.getOrDefault(pp.getUuid(), 0F);
74
            float damage = getDamage(target, pp);
75
            blockDamageCumulativeMap.put(pp.getUuid(), accumulatedDamage + damage);
76
        }
77
    }
78
79
    private void checkEvent(BlockDigEvent e) {
80
        Player p = e.getPlayer();
81
        HawkPlayer pp = e.getHawkPlayer();
82
        if(p.getGameMode() == GameMode.CREATIVE)
83
            return;
84
85
        if (e.getDigAction() == BlockDigEvent.DigAction.START) {
86
            targetBlockMap.put(p.getUniqueId(), e.getBlock());
87
            blockDamageCumulativeMap.put(p.getUniqueId(), 0F);
88
            interactTick.put(p.getUniqueId(), pp.getCurrentTick());
89
            tickDig(pp);
90
            return;
91
        }
92
93
        if (e.getDigAction() == BlockDigEvent.DigAction.COMPLETE) {
94
            float totalDamage = blockDamageCumulativeMap.getOrDefault(p.getUniqueId(), 0F);
95
96
            if(totalDamage < 1 || (PREVENT_SAME_TICK && pp.getCurrentTick() == interactTick.getOrDefault(p.getUniqueId(), 0L))) {
97
                double speedFactor = 1 / totalDamage;
98
                double vl = Math.min((speedFactor - 1) * 10, 10);
99
                Block b = e.getBlock();
100
                punish(pp, vl, true, e, new Placeholder("block", b.getType()), new Placeholder("speed", MathPlus.round(speedFactor, 2) + "x"));
101
                e.resync();
102
            }
103
            else {
104
                reward(pp);
105
            }
106
107
            targetBlockMap.put(p.getUniqueId(), null);
108
            blockDamageCumulativeMap.put(p.getUniqueId(), 0F);
109
        }
110
    }
111
112
    @Override
113
    public void removeData(Player p) {
114
        UUID uuid = p.getUniqueId();
115
        targetBlockMap.remove(uuid);
116
        blockDamageCumulativeMap.remove(uuid);
117
        interactTick.remove(uuid);
118
    }
119
120
    //Yes, I skidded this from NMS. plz don't sue me ;-;
121
    //I'm only trying to make this game more enjoyable for us players.
122
    //I'm pasting a bunch of methods here because I can't be bothered
123
    //to abstract AND synchronize all of this with the network thread
124
    //(and no, I'm not talking about the "synchronized" keyword).
125
126
    private float getDamage(Block block, HawkPlayer pp) {
127
        if(block == null || ServerUtils.getBlockAsync(block.getLocation()) == null)
128
            return 0;
129
        WrappedBlock wBlock = WrappedBlock.getWrappedBlock(block, pp.getClientVersion());
130
        float strength = wBlock.getStrength();
131
        return strength < 0.0F ? 0.0F : (!isDestroyableByHeldItem(wBlock, pp) ? getCurrentPlayerStrVsBlock(wBlock, false, pp) / strength / 100.0F : getCurrentPlayerStrVsBlock(wBlock, true, pp) / strength / 30.0F);
132
    }
133
134
    private boolean isDestroyableByHeldItem(WrappedBlock wBlock, HawkPlayer pp) {
135
        if (wBlock.isMaterialAlwaysDestroyable()) {
136
            return true;
137
        } else {
138
            WrappedItemStack itemstack = WrappedItemStack.getWrappedItemStack(pp.getHeldItem());
139
            return itemstack.canDestroySpecialBlock(wBlock.getBukkitBlock());
140
        }
141
    }
142
143
    private float getCurrentPlayerStrVsBlock(WrappedBlock wBlock, boolean flag, HawkPlayer pp) {
144
        float destroySpeed = getDestroySpeedOfHeldItem(wBlock, pp);
145
        if (destroySpeed > 1.0F && pp.getHeldItem() != null) {
146
            int enchLvl = pp.getHeldItem().getEnchantmentLevel(Enchantment.DIG_SPEED);
147
            WrappedItemStack itemstack = WrappedItemStack.getWrappedItemStack(pp.getHeldItem());
148
            if (enchLvl > 0) {
149
                float f1 = (float)(enchLvl * enchLvl + 1);
150
                if (!itemstack.canDestroySpecialBlock(wBlock.getBukkitBlock()) && destroySpeed <= 1.0F) {
151
                    destroySpeed += f1 * 0.08F;
152
                } else {
153
                    destroySpeed += f1;
154
                }
155
            }
156
        }
157
158
        for(org.bukkit.potion.PotionEffect potionEffect : pp.getPlayer().getActivePotionEffects()) {
159
160
            if(potionEffect.getType().equals(PotionEffectType.FAST_DIGGING)) {
161
                destroySpeed *= 1.0F + (potionEffect.getAmplifier() + 1) * 0.2F;
162
            }
163
164
            if(Hawk.getServerVersion() == 8) {
165
                if(potionEffect.getType().equals(PotionEffectType.SLOW_DIGGING)) {
166
                    float f1;
167
                    switch(potionEffect.getAmplifier()) {
168
                        case 0:
169
                            f1 = 0.3F;
170
                            break;
171
                        case 1:
172
                            f1 = 0.09F;
173
                            break;
174
                        case 2:
175
                            f1 = 0.0027F;
176
                            break;
177
                        case 3:
178
                        default:
179
                            f1 = 8.1E-4F;
180
                    }
181
182
                    destroySpeed *= f1;
183
                }
184
            }
185
            else {
186
                if(potionEffect.getType().equals(PotionEffectType.SLOW_DIGGING)) {
187
                    destroySpeed *= 1.0F - (potionEffect.getAmplifier() + 1) * 0.2F;
188
                }
189
            }
190
        }
191
192
        boolean waterWorkerEnch = pp.getHeldItem() != null && pp.getHeldItem().getEnchantmentLevel(Enchantment.WATER_WORKER) > 0;
193
        if (this.a(pp) && !waterWorkerEnch) {
194
            destroySpeed /= 5.0F;
195
        }
196
197
        if (CHECK_ON_GROUND && !pp.isOnGround()) {
198
            destroySpeed /= 5.0F;
199
        }
200
201
        return destroySpeed;
202
    }
203
204
    private float getDestroySpeedOfHeldItem(WrappedBlock wBlock, HawkPlayer pp) {
205
        float f = 1.0F;
206
        WrappedItemStack itemStack = WrappedItemStack.getWrappedItemStack(pp.getHeldItem());
207
        f *= itemStack.getDestroySpeed(wBlock.getBukkitBlock());
208
        return f;
209
    }
210
211
    private boolean a(HawkPlayer pp) {
212
        Vector position = pp.getPosition();
213
        double d0 = position.getY() + 1.62;
214
        int i = floor(position.getX());
215
        int j = (int)d((float)floor(d0));
216
        int k = floor(position.getZ());
217
        Block block = ServerUtils.getBlockAsync(new Location(pp.getWorld(), i, j, k));
218
        if(block == null)
219
            return false;
220
        if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) {
221
            float f = b(block.getData()) - 0.11111111F;
222
            float f1 = (float)(j + 1) - f;
223
            return d0 < (double)f1;
224
        } else {
225
            return false;
226
        }
227
    }
228
229
    private int floor(double var0) {
230
        int var2 = (int)var0;
231
        return var0 < (double)var2 ? var2 - 1 : var2;
232
    }
233
234
    private long d(double var0) {
235
        long var2 = (long)var0;
236
        return var0 < (double)var2 ? var2 - 1L : var2;
237
    }
238
239
    private float b(int i) {
240
        if (i >= 8) {
241
            i = 0;
242
        }
243
        return (i + 1) / 9.0F;
244
    }
245
246
}

How it counteracts this module

Hawk's BlockBreakSpeedSurvival rebuilds the block damage the client should have accumulated, independently of the client's own counter. On every move while the player is digging it adds getDamage(target, pp) - the vanilla hardness formula with tool efficiency, Efficiency enchantment and Haste potion factored in - to a cumulative map; on the C07-complete event it compares the total against 1.0. If the accumulated damage is below 1 (or the break landed on the same tick as the START, under the default flagSameTick setting), it computes speedFactor = 1 / totalDamage, sets the VL to min((speedFactor - 1) * 10, 10), punishes, and resyncs the block with e.resync().

The module is caught on both prongs. Because damage accrues per tick instead of per five ticks, the client's completion arrives after a fifth of the expected damage has accumulated, so totalDamage is well below 1 and the speedFactor is around 5, maxing the VL at 10 on the first block; the 0.7 snap makes the same-tick case likely, which the PREVENT_SAME_TICK branch punishes on its own. The resync then forces the block back into place, so on Hawk servers the module's breaks are undone as fast as they are claimed.

← Back to Analysis Hub