Memeware 7.3 FastBreak module 2 files, 627 lines

Memeware 7.3 FastBreak: Full Source Analysis

Memeware's FastBreak accelerates block breaking by mutating the client-side damage controller.

me/memewaredevs/client/module/misc/FastBreak.java · GitHub source ↗

Published 2026-08-12 · Updated 2026-08-12

Packets This Module Uses

Analysis

Overview

Memeware's FastBreak accelerates block breaking by mutating the client-side damage controller. Every update event it zeroes mc.playerController.blockHitDelay, and once the accumulated curBlockDamageMP passes the Break setting (default 0.7) it snaps the accumulator to 1.0, completing the break up to one damage tick early. Removing the 5-tick post-break delay is the larger win: consecutive blocks chain with no gap, which is the wire signature the block-break anticheat checks measure.

Damage accumulation shortcut

PlayerControllerMP.onPlayerDamageBlock decrements blockHitDelay and skips damage while it is positive, adds the block's relative hardness to curBlockDamageMP each damage tick, and breaks the block when the accumulator reaches 1.0, then sets blockHitDelay to 5 (PlayerControllerMP lines 263-267, 279, 292-299). The module writes blockHitDelay to 0 every update, so the 5-tick gate never applies, and promotes curBlockDamageMP to 1.0 as soon as it crosses the Break threshold, so the block finishes on the tick the accumulator first passes 0.7 instead of waiting for 1.0.

Wire fingerprint

The C07 sequence for a block is START_DIGGING on the first damage tick and STOP_DIGGING on the break, and the server breaks the block on receipt without re-validating the elapsed time. The module shortens the per-block window by up to one damage tick (about 50ms at 20 ticks per second) and, with blockHitDelay zeroed, the next block's START_DIGGING lands in the same tick as the previous STOP_DIGGING. Sustained use therefore produces back-to-back break events with no 250ms inter-block gap.

Detection surface

The counters split across the two effects. NCP blockbreak FastBreak and Grim FastBreak compare the measured break time against the expected time derived from the block's hardness and the player's tool, and Grim also scores the inter-break delay, which is the direct counter to the zeroed blockHitDelay. NCP blockbreak Frequency caps breaks per time frame and bites in creative-mode chains. Vrekt-Arc's Nuker is creative-gated and its v2 build dropped the block package, so the Arc lineage offers no survival-mode block-break counter.

source FastBreak.java

FastBreak.java22 lines · JavaOriginal ↗
1
package me.memewaredevs.client.module.misc;
2
3
import me.hippo.api.lwjeb.annotation.Handler;
4
import me.memewaredevs.client.event.events.UpdateEvent;
5
import me.memewaredevs.client.module.Module;
6
7
import java.util.function.Consumer;
8
9
public class FastBreak extends Module {
10
11
    public FastBreak() {
12
        super("Fast Break", 0, Category.MISC);
13
        this.addDouble("Break", 0.7, 0, 1);
14
    }
15
16
    @Handler
17
    public Consumer<UpdateEvent> eventConsumer0 = (event) -> {
18
        mc.playerController.blockHitDelay = 0;
19
        if (mc.playerController.curBlockDamageMP >= this.getDouble("Break"))
20
            mc.playerController.curBlockDamageMP = 1F;
21
    };
22
}

What this file does

The module is two field writes on the player controller. The Break setting defaults to 0.7 with a range of 0 to 1, and the handler runs on every update event, so the writes are re-asserted each tick regardless of what the controller does. Setting blockHitDelay to 0 removes the post-break pause, and promoting curBlockDamageMP to 1.0 once it passes the threshold triggers the controller's break path early.

The two writes compose: the delay removal chains blocks, and the threshold snap shortens each block's tail. The module does not send packets itself; it changes the controller state that drives the vanilla C07 emission, which is why the wire difference is visible only in the timing of the dig sequence.

source PlayerControllerMP.java (damage controller)

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

What this file does

This is the vanilla class the module mutates. The relevant state is curBlockDamageMP (line 49) and blockHitDelay (line 59). onPlayerDamageBlock decrements blockHitDelay and returns without damaging while it is positive (lines 263-265), sets it to 5 when a block is first targeted (line 267), accumulates getPlayerRelativeBlockHardness into curBlockDamageMP (line 279), and when the accumulator reaches 1.0 sends the break (lines 292-299), resetting the accumulator and the delay.

Embedding the controller makes the module's two writes legible: blockHitDelay = 0 keeps the damage path open every tick, and curBlockDamageMP = 1F inside the >= Break guard forces the line-292 break branch to fire early. The 605-line file is embedded in full so the break path and its packet sends are visible in context.

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 (break-time differential)

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 blockbreak FastBreak validates the measured break time against the block's expected breaking time. The expected value is round(getBreakingDuration(blockType, player) * fastBreakModSurvival / 100) (line 56; the survival modifier defaults to 100, DefaultConfig line 126), and the elapsed time is now minus the first damage time in strict mode (lines 61-63; strict defaults to true, DefaultConfig line 124). When elapsed plus the fastBreakDelay (default 10ms) falls short of the expected time, the missing time is added as a penalty to a bucket (lines 74-81) and a violation fires once the bucket score exceeds the grace (default 2000, DefaultConfig line 128), with the violation level scaled by the missing time in seconds (lines 85-87).

The module's 0.7 snap cuts each block's measured window short by up to one damage tick, so every block adds roughly 50ms of missing time to the penalty bucket. The catch is the grace: 2000ms of accumulated shortfall means roughly 40 blocks of continuous fast breaking before the first violation at default settings, so the check punishes sustained use rather than a single accelerated block. Insta-break blocks are skipped entirely (line 66). The honest reading is that this is a slow accumulator that rewards short bursts, which is exactly the pattern a casual module user produces.

anticheat Frequency (break-rate cap)

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 limits breaks per time frame with two windows: a full-window bucket score (2 buckets of 1000ms each, BlockBreakConfig lines 81-82) where each break adds the interval modifier (45 in survival, 95 in creative, DefaultConfig lines 132-133) and a violation fires when the score passes the window duration, plus a short-term counter that flags when more than 7 breaks land inside 5 ticks (frequencyShortTermTicks 5, frequencyShortTermLimit 7, DefaultConfig lines 134-135; check lines 55-75). The default actions cancel at vl > 5.

The thresholds are tuned for instant-break chains. In survival, a block takes hundreds of milliseconds even with the module, so the chained rate of roughly 3 breaks per second stays far below the 7-in-5-ticks short-term limit and the 45-per-break full-window score needs over 40 breaks in two seconds to exceed the 2000ms window. The check therefore does not fire on the survival module at defaults. In creative mode the story flips: insta-breaks chained by the zeroed blockHitDelay flood both windows, and the 7-in-5-ticks limit trips within a few ticks. This entry is the honest version of the task's blockbreak Speed label: there is no Speed check in the NCP blockbreak package, and Frequency is the rate-side sibling that only bites the module's creative-mode use.

anticheat FastBreak (predicted-time and delay balances)

FastBreak.java141 lines · Java
1
package ac.grim.grimac.checks.impl.breaking;
2
3
import ac.grim.grimac.api.storage.verbose.Verbose;
4
import ac.grim.grimac.checks.Check;
5
import ac.grim.grimac.checks.CheckData;
6
import ac.grim.grimac.checks.impl.verbose.VerboseCodecs;
7
import ac.grim.grimac.checks.type.BlockBreakListener;
8
import ac.grim.grimac.checks.type.PreViaPacketReceiveListener;
9
import ac.grim.grimac.player.GrimPlayer;
10
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
11
import ac.grim.grimac.utils.math.GrimMath;
12
import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed;
13
import ac.grim.grimac.utils.viaversion.ViaVersionUtil;
14
import com.github.retrooper.packetevents.PacketEvents;
15
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
16
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
17
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
18
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
19
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
20
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
21
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
22
import com.github.retrooper.packetevents.util.Vector3i;
23
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
24
25
import java.util.Set;
26
27
// Based loosely off of Hawk BlockBreakSpeedSurvival
28
// Also based loosely off of NoCheatPlus FastBreak
29
// Also based off minecraft wiki: https://minecraft.wiki/w/Breaking#Instant_breaking
30
@CheckData(name = "FastBreak", stableKey = "grim.breaking.fast_break", description = "Breaking blocks too quickly")
31
public class FastBreak extends Check implements BlockBreakListener, PreViaPacketReceiveListener {
32
    private static final Verbose V =
33
            Verbose.of("[delay={ulong}ms|diff={f64:%.1f}ms, balance={f64:%.1f}ms], type={block}");
34
35
    // For some reason these states flag and I don't know why.
36
    // Better to just exempt to not annoy legit players.
37
    private static final Set<StateType> EXEMPT_STATES = Set.of();
38
    private final boolean clientOlderThanServer = PacketEvents.getAPI().getServerManager().getVersion().getProtocolVersion() > player.getClientVersion().getProtocolVersion();
39
40
    public FastBreak(GrimPlayer player) {
41
        super(player);
42
    }
43
44
    // The block the player is currently breaking
45
    Vector3i targetBlockPosition = null;
46
    // The maximum amount of damage the player deals to the block
47
    //
48
    double maximumBlockDamage = 0;
49
    // The last time a finish digging packet was sent, to enforce 0.3-second delay after non-instabreak
50
    long lastFinishBreak = 0;
51
    // The time the player started to break the block, to know how long the player waited until they finished breaking the block
52
    long startBreak = 0;
53
54
    // The buffer to this check
55
    double blockBreakBalance = 0;
56
    double blockDelayBalance = 0;
57
58
    @Override
59
    public void onBlockBreak(BlockBreak blockBreak) {
60
        if (blockBreak.action == DiggingAction.START_DIGGING) {
61
            if (!ViaVersionUtil.isAvailable) {
62
                // Exempt all blocks that do not exist in the player version
63
                final WrappedBlockState defaultState = WrappedBlockState.getDefaultState(player.getClientVersion(), blockBreak.block.getType());
64
                if (defaultState.getType() == StateTypes.AIR || EXEMPT_STATES.contains(defaultState.getType())) {
65
                    return;
66
                }
67
            }
68
            // If client is older than the server, fetch block client actually sees from via
69
            // otherwise just return the server-side block (since if client is >= server version the block is guaranteed to exist in client version)
70
            // TODO this lazy loads PacketEvents mappings for older versions for clients on versions older than the servers, increasing memory usage
71
            //  * its the only thing we use non-native mappings for behind ViaVersion
72
            //  * can we translate back "up" to server version and run check against server version to avoid loading older registries?
73
            WrappedBlockState block = clientOlderThanServer ? WrappedBlockState.getByGlobalId(player.getClientVersion(), player.getViaTranslatedClientBlockID(blockBreak.block.getGlobalId())) : blockBreak.block;
74
75
            startBreak = System.currentTimeMillis() - (targetBlockPosition == null ? 50 : 0); // ???
76
            targetBlockPosition = blockBreak.position;
77
78
            // FIXME: getBlockDamage might not return the correct value if the player switched slots before this
79
            maximumBlockDamage = BlockBreakSpeed.getBlockDamage(player, block);
80
81
            double breakDelay = System.currentTimeMillis() - lastFinishBreak;
82
83
            if (breakDelay >= 275) { // Reduce buffer if "close enough"
84
                blockDelayBalance *= 0.9;
85
            } else { // Otherwise, increase buffer
86
                blockDelayBalance += 300 - breakDelay;
87
            }
88
89
            if (blockDelayBalance > 1000) { // If more than a second of advantage
90
                int type = VerboseCodecs.block(blockBreak.block.getType(), player.getClientVersion());
91
                if (flag(V.write(verbose()).bool(true).ulong((long) breakDelay).f64(0).f64(0).sint(type)) && shouldModifyPackets()) {
92
                    blockBreak.cancel();
93
                }
94
            }
95
96
            clampBalance();
97
        }
98
99
        if (blockBreak.action == DiggingAction.FINISHED_DIGGING && targetBlockPosition != null) {
100
            double predictedTime = Math.ceil(1 / maximumBlockDamage) * 50;
101
            double realTime = System.currentTimeMillis() - startBreak;
102
            double diff = predictedTime - realTime;
103
104
            clampBalance();
105
106
            if (diff < 25) {  // Reduce buffer if "close enough"
107
                blockBreakBalance *= 0.9;
108
            } else { // Otherwise, increase buffer
109
                blockBreakBalance += diff;
110
            }
111
112
            if (blockBreakBalance > 1000) { // If more than a second of advantage
113
                int type = VerboseCodecs.block(blockBreak.block.getType(), player.getClientVersion());
114
                if (flag(V.write(verbose()).bool(false).ulong(0).f64(diff).f64(blockBreakBalance).sint(type)) && shouldModifyPackets()) {
115
                    blockBreak.cancel();
116
                }
117
            }
118
119
            // also set start time because the breaking netcode is fucked on 1.14.4+
120
            lastFinishBreak = startBreak = System.currentTimeMillis();
121
        }
122
    }
123
124
    @Override
125
    public void onPreViaPacketReceive(PacketReceiveEvent event) {
126
        // Find the most optimal block damage using the animation packet, which is sent at least once a tick when breaking blocks
127
        // On 1.8 clients, via screws with this packet meaning we must fall back to the 1.8 idle flying packet
128
        //
129
        // listen for flying packets because some block breaks can happen before the next animation (somehow???), causing onGround desync
130
        boolean flying = WrapperPlayClientPlayerFlying.isFlying(event.getPacketType());
131
        if ((flying || (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) && event.getPacketType() == PacketType.Play.Client.ANIMATION)) && targetBlockPosition != null) {
132
            maximumBlockDamage = Math.max(maximumBlockDamage, BlockBreakSpeed.getBlockDamage(player, player.compensatedWorld.getBlock(targetBlockPosition)));
133
        }
134
    }
135
136
    private void clampBalance() {
137
        double balance = Math.max(1000, (player.getTransactionPing()));
138
        blockBreakBalance = GrimMath.clamp(blockBreakBalance, -balance, balance); // Clamp not Math.max in case other logic changes
139
        blockDelayBalance = GrimMath.clamp(blockDelayBalance, -balance, balance);
140
    }
141
}

How it counteracts this module

Grim's FastBreak keeps two balances. On START_DIGGING it records startBreak, reads the per-tick block damage from BlockBreakSpeed (refreshed from the animation and flying packets, lines 124-134), and scores the inter-break delay: a gap under 275ms adds 300 minus the gap to blockDelayBalance, flagging when the balance passes 1000 (lines 81-94). On FINISHED_DIGGING it computes predictedTime as ceil(1 / maximumBlockDamage) times 50ms, compares it to the measured realTime, and adds the difference to blockBreakBalance when it exceeds 25ms, flagging above 1000 (lines 99-117). Both balances decay by 0.9 when close and clamp to the transaction ping (lines 136-139).

This is the sharpest counter for the module because it scores both effects with no grace window. The zeroed blockHitDelay makes the inter-break gap about 0ms, so blockDelayBalance gains 300 per chained block and passes 1000 after roughly four consecutive breaks. The 0.7 snap makes realTime about 50ms short of predicted, adding a similar per-block charge to blockBreakBalance. The balances are clamped to the player's transaction ping (a 300ms ping raises the clamp to 1000), which gives high-ping players more headroom, and a 25ms diff threshold means a module that shaves less than half a tick per block accumulates slowly.

anticheat Nuker (creative-gated break rate)

Nuker.java198 lines · Java
1
package arc.check.block;
2
3
import arc.Arc;
4
import arc.check.PacketCheck;
5
import arc.check.result.CheckResult;
6
import arc.check.types.CheckType;
7
import arc.data.block.BlockData;
8
import arc.data.packet.PacketData;
9
import com.comphenix.protocol.PacketType;
10
import org.bukkit.GameMode;
11
import org.bukkit.entity.Player;
12
13
/**
14
 * Checks if the player is using nuker - destroying an improbable amount of blocks around them.
15
 * This check will also utilize {@code maxPacketsPerSecond} to ensure not too many events are sent.
16
 * <p>
17
 * packet-check: the check will use packets
18
 * creative-only: Player must be in creative to check.
19
 * max-breaks-per-second: The max amount of block breaks per second.
20
 * min-delta-between-breaks: The minimum time allowed between the last break.
21
 * min-delta-between-breaks-threshold: the amount of times the above ^^ has to be triggered to flag.
22
 */
23
public final class Nuker extends PacketCheck {
24
25
    /**
26
     * packet-check: the check will use packets
27
     * creative-only: Player must be in creative to check.
28
     * If packets should be checked.
29
     */
30
    private boolean packetCheck, creativeOnly, checkPackets;
31
32
    /**
33
     * max-breaks-per-second: The max amount of block breaks per second.
34
     * min-delta-between-breaks: The minimum time allowed between the last break.
35
     * min-delta-between-breaks-threshold: the amount of times the above ^^ has to be triggered to flag.
36
     */
37
    private int maxBreaksPerSecond, minDeltaBetweenBreaks, minDeltaBetweenBreaksThreshold;
38
39
    /**
40
     * Max packets and packet kick threshold
41
     */
42
    private int maxPacketsPerSecond, packetKickThreshold;
43
44
    /**
45
     * Kick if the threshold is reached
46
     */
47
    private boolean kickIfThresholdReached;
48
49
    public Nuker() {
50
        super(CheckType.NUKER);
51
52
        isEnabled(true)
53
                .cancel(true)
54
                .cancelLevel(0)
55
                .notify(true)
56
                .notifyEvery(4)
57
                .ban(true)
58
                .banLevel(1000)
59
                .kick(true)
60
                .kickLevel(500)
61
                .build();
62
63
        addConfigurationValue("packet-check", true);
64
        addConfigurationValue("creative-only", true);
65
        addConfigurationValue("max-breaks-per-second", 15);
66
        addConfigurationValue("min-delta-between-breaks", 50);
67
        addConfigurationValue("min-delta-between-breaks-threshold", 5);
68
69
        addConfigurationValue("check-packets", true);
70
        addConfigurationValue("max-break-packets-per-second", 50);
71
        addConfigurationValue("kick-if-threshold-reached", false);
72
        addConfigurationValue("packet-kick-threshold", 100);
73
74
        if (isEnabled()) load();
75
    }
76
77
    /**
78
     * Check this player for Nuker.
79
     *
80
     * @param player the player
81
     * @return the result
82
     */
83
    public boolean check(Player player) {
84
        if (!isEnabled() || exempt(player) || creativeOnly && player.getGameMode() != GameMode.CREATIVE) return false;
85
86
        final CheckResult result = new CheckResult();
87
        final long now = System.currentTimeMillis();
88
89
        // first, just check packet-stuff.
90
        // Don't use a scheduled check here, because meh.
91
        if (checkPackets) {
92
            final PacketData packetData = PacketData.get(player);
93
94
            final int count = packetData.getBreakPacketCount() + 1;
95
            packetData.setBreakPacketCount(count);
96
            final long packetDelta = now - packetData.getLastBreakPacketReset();
97
98
            // check packet counts and deltas.
99
            if (packetDelta >= 1000) {
100
                packetData.setLastBreakPacketReset(now);
101
                if (count >= maxPacketsPerSecond) {
102
                    result.setFailed("Too many break packets (or events) per second.")
103
                            .withParameter("amount", count)
104
                            .withParameter("max", maxPacketsPerSecond);
105
106
                    if (count >= packetKickThreshold && kickIfThresholdReached
107
                            && !Arc.getInstance().getPunishmentManager().hasPendingKick(player)) {
108
                        Arc.getInstance().getPunishmentManager().kickPlayer(player, this);
109
                    }
110
                } else {
111
                    packetData.setCancelBreakPackets(false);
112
                }
113
114
                packetData.setBreakPacketCount(0);
115
            }
116
117
            // cancel if we should.
118
            if (packetData.cancelBreakPackets()) {
119
                result.setFailed("Cancelling break packets because there were too many.");
120
                checkViolation(player, result);
121
                return true;
122
            }
123
124
            final boolean violation = checkViolation(player, result);
125
            packetData.setCancelBreakPackets(violation);
126
            if (violation) return true;
127
        }
128
129
        // now, block checking.
130
        final BlockData data = BlockData.get(player);
131
        final long delta = now - data.getLastBreak();
132
        data.setTotalBroke(data.getTotalBroke() + 1);
133
        data.setLastBreak(now);
134
135
        if (now - data.getTotalBrokeReset() >= 1000) {
136
            data.setTotalBrokeReset(now);
137
138
            if (data.getTotalBroke() > maxBreaksPerSecond) {
139
                result.setFailed("Breaking too many blocks per second.")
140
                        .withParameter("total", data.getTotalBroke())
141
                        .withParameter("max", maxBreaksPerSecond);
142
            }
143
144
            data.setTotalBroke(0);
145
        }
146
147
        // check delta times
148
        if (delta < minDeltaBetweenBreaks) {
149
            // "failed", increment one count.
150
            data.setLastBreakDeltaCount(data.getLastBreakDeltaCount() + 1);
151
152
            // make sure we haven't already failed, and then check against min.
153
            if (data.getLastBreakDeltaCount() >= minDeltaBetweenBreaksThreshold
154
                    && !result.failed()) {
155
                result.setFailed("Breaking blocks too fast")
156
                        .withParameter("count", data.getLastBreakDeltaCount())
157
                        .withParameter("min", minDeltaBetweenBreaksThreshold)
158
                        .withParameter("delta", delta)
159
                        .withParameter("min-delta", minDeltaBetweenBreaks);
160
            }
161
        } else {
162
            // lower since we're okay.
163
            data.setLastBreakDeltaCount(data.getLastBreakDeltaCount() - 1);
164
        }
165
166
        return checkViolation(player, result);
167
    }
168
169
    /**
170
     * @return if this check uses packets.
171
     */
172
    public boolean isPacketCheck() {
173
        return packetCheck;
174
    }
175
176
    @Override
177
    public void reloadConfig() {
178
        load();
179
    }
180
181
    @Override
182
    public void load() {
183
        packetCheck = configuration.getBoolean("packet-check");
184
        creativeOnly = configuration.getBoolean("creative-only");
185
        checkPackets = configuration.getBoolean("check-packets");
186
        maxBreaksPerSecond = configuration.getInt("max-breaks-per-second");
187
        minDeltaBetweenBreaks = configuration.getInt("min-delta-between-breaks");
188
        minDeltaBetweenBreaksThreshold = configuration.getInt("min-delta-between-breaks-threshold");
189
190
        maxPacketsPerSecond = configuration.getInt("max-break-packets-per-second");
191
        kickIfThresholdReached = configuration.getBoolean("kick-if-threshold-reached");
192
        packetKickThreshold = configuration.getInt("packet-kick-threshold");
193
194
        if (packetCheck) {
195
            registerPacketListener(PacketType.Play.Client.BLOCK_DIG, event -> event.setCancelled(check(event.getPlayer())));
196
        }
197
    }
198
}

How it counteracts this module

Arc's block-break check registers a BLOCK_DIG packet listener (line 195) and enforces a break-rate cap of 15 breaks per second, a 50ms minimum delta between breaks with a 5-occurrence threshold, and a packet-side cap of 50 break packets per second (lines 63-72, 91-127, 135-164). The gate matters most: creativeOnly defaults to true, and the check returns false immediately for any non-creative player (line 84), so in survival the entire check is dormant.

Against the survival module the check does nothing unless an admin disables the creative-only gate. With the gate off, the module's 30% early break still takes hundreds of milliseconds, so it stays inside the 50ms min-delta, and only the chained breaks from the zeroed blockHitDelay approach the delta threshold; five consecutive chains would trip it. The lineage note matters for attribution: the C07 corpus files under the Vrekt section are the v1 layout (arc.check.block), and Vrekt-Arc v2 dropped the block package entirely, its PacketListener subscribing only to FLYING, POSITION, USE_ENTITY, ARM_ANIMATION, HELD_ITEM_SLOT and BLOCK_PLACE (soup auto-heal), so the v2 build offers no block-break counter at all.

← Back to Analysis Hub