Memeware 7.3 Stealer module 2 files, 708 lines

Memeware 7.3 Stealer: Full Source Analysis

Memeware 7.3's Stealer empties chests with one shift-click per delay period: while a GuiChest is open it walks the container slots and window-clicks the first slot holding a stack every Delay ticks…

me/memewaredevs/client/module/player/Stealer.java · GitHub source ↗

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

Analysis

Overview

Memeware 7.3's Stealer empties chests with one shift-click per delay period: while a GuiChest is open it walks the container slots and window-clicks the first slot holding a stack every Delay ticks (default 4, so 5 clicks per second), emits C0D through the fork's closeScreen when the chest looks empty, and in Nearby mode scans a 7x7x7 box for chests, swings with C0A and right-clicks them open with C08. The per-tick gating is the modulo of the player's tick counter against the rounded Delay setting, which also means a Delay of 0 divides by zero and crashes the client the first tick the handler runs. The emptied-chest list is cleared on every S08 teleport and on enable, so the module re-opens chests after a respawn or teleport.

Steal loop

The first consumer handles the open-chest case. When mc.currentScreen is a GuiChest, the module checks the container for items by scanning the first 27 or 54 slots depending on the slot count (90 slots means a double chest), and while anything remains it iterates the slot list and shift-clicks the first occupied slot through mc.playerController.windowClick with mode 1, one click per handler run. The click fires only when ticksExisted modulo the rounded Delay equals zero, so the pacing is a fixed 20 divided by Delay clicks per second, not a timer. When the container is empty, the Close setting (on by default) or Nearby mode closes the screen with mc.displayGuiScreen(null), which the fork's EntityPlayerSP.closeScreen turns into a C0DPacketCloseWindow with the open window id.

Nearby mode

Nearby mode is the second behavior: with no screen open, every Delay ticks it scans a 7x7x7 block box around the player, and for each BlockChest within a distance-squared of 16 that is not in the emptiedChests list it adds the position, sends a C0APacketAnimation swing through PacketUtil, and calls onPlayerRightClick with the DOWN facing, which makes the fork's PlayerControllerMP emit the C08 use-item packet that opens the chest. The emptied list is cleared by the second consumer on every S08PacketPlayerPosLook after terrain load and on every enable, so chests are only opened once per position per teleport. The scan order is y from 3 down to -3, then x and z ascending, so nearer chests win ties.

Wire behavior

The fork's PlayerControllerMP.windowClick builds only C0EPacketClickWindow (slot id, button, mode, the clicked stack and the container's next transaction id) and never calls syncCurrentPlayItem, so the shift-clicks emit pure C0E with no C09 held-item sync, and the module never changes the held item anyway. The close path emits C0D, and the Nearby open path emits C0A plus C08. The Delay modulo gating means the packet rate is deterministic: Delay 4 is 5 C0E per second, Delay 2 is 10, Delay 1 is 20, and Delay 0 is a client crash, because ticksExisted modulo zero throws. The S08 consumer runs on the receive side and only clears the list, so a teleport mid-steal resets the open-set without touching the open chest.

source Stealer.java (module)

Stealer.java103 lines · JavaOriginal ↗
1
package me.memewaredevs.client.module.player;
2
3
import me.hippo.api.lwjeb.annotation.Handler;
4
import me.memewaredevs.client.event.events.PacketInEvent;
5
import me.memewaredevs.client.event.events.UpdateEvent;
6
import me.memewaredevs.client.module.Module;
7
import me.memewaredevs.client.util.packet.PacketUtil;
8
import me.memewaredevs.client.util.blocks.position.Vec3d;
9
import net.minecraft.block.Block;
10
import net.minecraft.block.BlockChest;
11
import net.minecraft.client.gui.inventory.GuiChest;
12
import net.minecraft.inventory.Container;
13
import net.minecraft.inventory.Slot;
14
import net.minecraft.network.play.client.C0APacketAnimation;
15
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
16
import net.minecraft.util.BlockPos;
17
import net.minecraft.util.EnumFacing;
18
19
import java.util.ArrayList;
20
import java.util.List;
21
import java.util.function.Consumer;
22
23
import static org.lwjgl.input.Keyboard.KEY_K;
24
25
public class Stealer extends Module {
26
    public Stealer() {
27
        super("Stealer", KEY_K, Category.PLAYER);
28
        this.addModes("Normal", "Nearby");
29
        this.addBoolean("Close", true);
30
        this.addDouble("Delay", 4, 0, 12);
31
    }
32
    private final List<BlockPos> emptiedChests = new ArrayList();
33
34
    @Handler
35
    public Consumer<UpdateEvent> eventConsumer0 = event -> {
36
        if (mc.currentScreen instanceof GuiChest) {
37
            if (!isEmpty(mc.thePlayer.openContainer)) {
38
                for (Slot slot : (List<Slot>) mc.thePlayer.openContainer.inventorySlots) {
39
                    if (slot != null && slot.getStack() != null && mc.thePlayer.ticksExisted % Math.round(this.getDouble("Delay")) == 0) {
40
                        mc.playerController.windowClick(mc.thePlayer.openContainer.windowId, slot.slotNumber, 0, 1, mc.thePlayer);
41
                        return;
42
                    }
43
                }
44
            } else {
45
                if (this.getBool("Close") || isMode("Nearby")) {
46
                    mc.displayGuiScreen(null);
47
                }
48
            }
49
            return;
50
        }
51
        if (isMode("Nearby")) {
52
            int maxDist = 3;
53
            if (mc.currentScreen == null) {
54
                if (mc.thePlayer.ticksExisted % Math.round(this.getDouble("Delay")) == 0) {
55
                    for (int y = maxDist; y >= -maxDist; y--) {
56
                        for (int x = -maxDist; x < maxDist; x++) {
57
                            for (int z = -maxDist; z < maxDist; z++) {
58
                                int posX = ((int) Math.floor(mc.thePlayer.posX) + x);
59
                                int posY = ((int) Math.floor(mc.thePlayer.posY) + y);
60
                                int posZ = ((int) Math.floor(mc.thePlayer.posZ) + z);
61
                                if (mc.thePlayer.getDistanceSq(mc.thePlayer.posX + x, mc.thePlayer.posY + y, mc.thePlayer.posZ + z) <= 16.0) {
62
                                    Block block = mc.theWorld.getBlockState(new BlockPos(posX, posY, posZ)).getBlock();
63
                                    if (block instanceof BlockChest) {
64
                                        BlockPos pos = new BlockPos(posX, posY, posZ);
65
                                        if (!this.emptiedChests.contains(pos)) {
66
                                            this.emptiedChests.add(pos);
67
                                            PacketUtil.sendPacket(new C0APacketAnimation());
68
                                            mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem(), new BlockPos(posX, posY, posZ), EnumFacing.DOWN, new Vec3d(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ));
69
                                        }
70
                                    }
71
                                }
72
                            }
73
                        }
74
                    }
75
                }
76
            }
77
        }
78
    };
79
80
    @Handler
81
    public Consumer<PacketInEvent> eventConsumer1 = event -> {
82
        if (event.getPacket() instanceof S08PacketPlayerPosLook && mc.getNetHandler() != null && mc.getNetHandler().doneLoadingTerrain) {
83
            emptiedChests.clear();
84
        }
85
    };
86
87
    @Override
88
    public void onEnable() {
89
        this.emptiedChests.clear();
90
    }
91
92
    public boolean isEmpty(final Container container) {
93
        boolean isEmpty = true;
94
        int maxSlot = (container.inventorySlots.size() == 90) ? 54 : 27;
95
        for (int i = 0; i < maxSlot; ++i) {
96
            if (container.getSlot(i).getHasStack()) {
97
                isEmpty = false;
98
            }
99
        }
100
        return isEmpty;
101
    }
102
103
}

What this file does

The module is two registered consumers plus a small container helper. eventConsumer0 is the steal loop: the open-chest branch shift-clicks the first occupied slot when the tick modulo passes, and the Nearby branch scans for chests, swings with C0A and right-clicks them open. eventConsumer1 clears the emptied-chest list on S08 teleports, and isEmpty counts occupied slots among the first 27 or 54 to decide when the drain is done. The Delay setting gates everything through the tick modulo, which is the module's rate control and its crash edge at zero.\n\nThe Close boolean and the mode string are the only other settings, and the class never touches timers or packet buffers; every effect on the wire is one of the three fork paths described above. The import of the lwjeb @Handler registration is the client's event wiring, and the module binds itself to the UpdateEvent and PacketInEvent buses through it.

source PlayerControllerMP.java (fork window protocol)

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

The fork's PlayerControllerMP defines every packet the module puts on the wire. windowClick computes the container's next transaction id, runs slotClick locally to get the clicked stack, and queues a single C0EPacketClickWindow; notably it never calls syncCurrentPlayItem, so window clicks carry no C09 held-item sync, a fork fingerprint that the module inherits. onPlayerRightClick is the chest-open path: for an activated block it queues the C08PacketPlayerBlockPlacement with the position, facing and held stack that the Nearby mode triggers, and onStoppedUsingItem and the other sync sites show where C09 would come from in vanilla.\n\nThe module calls only windowClick and onPlayerRightClick, so this one file accounts for the entire C0E and C08 footprint. The C0D close comes from the fork's EntityPlayerSP.closeScreen rather than this class, and the C0A swing is sent directly by the module. Reading the fork file is what proves the no-C09 claim instead of assuming vanilla behavior.

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 FastClick (window click rate)

FastClick.java243 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.inventory;
16
17
import java.util.ArrayList;
18
import java.util.List;
19
20
import org.bukkit.Material;
21
import org.bukkit.entity.Player;
22
import org.bukkit.event.inventory.InventoryClickEvent;
23
import org.bukkit.event.inventory.InventoryType;
24
import org.bukkit.inventory.InventoryView;
25
import org.bukkit.inventory.ItemStack;
26
27
import fr.neatmonster.nocheatplus.actions.ParameterName;
28
import fr.neatmonster.nocheatplus.checks.Check;
29
import fr.neatmonster.nocheatplus.checks.CheckType;
30
import fr.neatmonster.nocheatplus.checks.ViolationData;
31
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
32
import fr.neatmonster.nocheatplus.permissions.Permissions;
33
import fr.neatmonster.nocheatplus.players.IPlayerData;
34
import fr.neatmonster.nocheatplus.utilities.entity.InventoryUtil;
35
import fr.neatmonster.nocheatplus.utilities.StringUtil;
36
import fr.neatmonster.nocheatplus.utilities.TickTask;
37
38
39
/**
40
 * FastClick checks for players clicking in inventories too quickly (nerfs autosteal cheats and the like).
41
 */
42
public class FastClick extends Check {
43
44
45
    final List<String> tags = new ArrayList<String>();
46
47
48
    /**
49
     * Instantiates a new fast click check.
50
     */
51
    public FastClick() {
52
        super(CheckType.INVENTORY_FASTCLICK);
53
    }
54
55
56
   /**
57
    * Checks a player.
58
    * 
59
    * @param player
60
    * @param now Millisec
61
    * @param view
62
    * @param slot
63
    * @param cursor
64
    * @param clicked
65
    * @param isShiftClick
66
    * @param inventoryAction
67
    * @param data
68
    * @param cc 
69
    * @param pData
70
    * @return true, if successful
71
    */
72
    public boolean check(final Player player, final long now, 
73
                         final InventoryClickEvent event, final int slot, final ItemStack cursor, 
74
                         final ItemStack clicked, final boolean isShiftClick, 
75
                         final String inventoryAction, final InventoryData data, final InventoryConfig cc, 
76
                         final IPlayerData pData) {
77
78
        final float amount;
79
        final Material clickedMat = clicked == null ? Material.AIR : clicked.getType();
80
        final Material cursorMat;
81
        final int cursorAmount;
82
        boolean cancel = false;
83
        tags.clear();
84
85
        if (cursor != null) {
86
            cursorMat = cursor.getType();
87
            cursorAmount = Math.max(1, cursor.getAmount());
88
        }
89
        else {
90
            cursorMat = null;
91
            cursorAmount = 0;
92
        }
93
94
        if (inventoryAction != null) {
95
            amount = getAmountWithAction(event, slot, clicked, clickedMat, cursorMat, cursorAmount, isShiftClick, inventoryAction, data, cc);
96
        }
97
        else if (cursor != null) {
98
            // Detect shift-click features indirectly.
99
            amount = detectTweaks1_5(event, slot, clicked, clickedMat, cursorMat, cursorAmount, isShiftClick, data, cc);
100
        }
101
        else amount = 1f;
102
103
        if (isShiftClick && inventoryAction.equals("MOVE_TO_OTHER_INVENTORY") 
104
            && (cursorMat != null && cursorMat != Material.AIR) 
105
            && clickedMat != Material.AIR) {
106
            return false;
107
        }
108
        
109
        // Count clicks
110
        data.fastClickFreq.add(now, amount);
111
        
112
        // Shor-term VL
113
        float shortTerm = data.fastClickFreq.bucketScore(0);
114
        if (shortTerm > cc.fastClickShortTermLimit) {
115
            // Check for lag.
116
            shortTerm /= (float) TickTask.getLag(data.fastClickFreq.bucketDuration(), true);
117
        }
118
        shortTerm -= cc.fastClickShortTermLimit;
119
        
120
        // Normal VL
121
        float normal = data.fastClickFreq.score(1f);
122
        if (normal > cc.fastClickNormalLimit) {
123
            // Check for lag.
124
            normal /= (float) TickTask.getLag(data.fastClickFreq.bucketDuration() * data.fastClickFreq.numberOfBuckets(), true);
125
        }
126
        normal -= cc.fastClickNormalLimit;
127
        
128
        // Process Violations.
129
        final double violation = Math.max(shortTerm, normal);
130
        if (violation > 0.0) {
131
            tags.add("clickspeed");
132
            data.fastClickVL += violation;
133
            final ViolationData vd = new ViolationData(this, player, data.fastClickVL, violation, cc.fastClickActions);
134
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
135
            cancel = executeActions(vd).willCancel();
136
        }
137
        else data.fastClickVL *= 0.99;
138
139
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
140
            player.sendMessage("FastClick: " + data.fastClickFreq.bucketScore(0) + " | " + data.fastClickFreq.score(1f) + " | cursor=" + cursor 
141
                                + " | clicked=" + clicked + " | action=" + inventoryAction);
142
        }
143
        
144
        // Adjust data
145
        data.fastClickLastClicked = clickedMat;
146
        data.fastClickLastSlot = slot;
147
        data.fastClickLastCursor = cursorMat;
148
        data.fastClickLastCursorAmount = cursorAmount;
149
150
        // Lastly, always feed the improbable.
151
        if (cc.fastClickImprobableWeight > 0.0f) {
152
            Improbable.feed(player, cc.fastClickImprobableWeight * amount, now);
153
        }
154
        return cancel;
155
    }
156
    
157
158
   /**
159
    * Enforce sane timings for interacting with the container and clicking in it.
160
    * 
161
    * @param player
162
    * @param data
163
    * @param cc
164
    */
165
    public boolean checkContainerInteraction(final Player player, final InventoryData data, final InventoryConfig cc) {
166
        boolean cancel = false;
167
        tags.clear();
168
        if (InventoryUtil.isContainerInteractionRecent(player, cc.chestOpenLimit)) {
169
            // Interaction was too quick, violation.
170
            tags.add("interact_time");
171
            long duration = Math.max(data.lastClickTime - data.containerInteractTime, 20);
172
            double violation = (cc.chestOpenLimit / duration) * 100D; // Normalize.
173
            data.fastClickVL += violation;
174
            final ViolationData vd = new ViolationData(this, player, data.fastClickVL, violation, cc.fastClickActions);
175
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
176
            cancel = executeActions(vd).willCancel();  
177
        }
178
       return cancel;
179
    }
180
    
181
182
   /**
183
    * Detect the inventory tweaks that were introduced in MC 1.5
184
    * 
185
    * @param view
186
    * @param slot
187
    * @param clicked
188
    * @param clickedMat
189
    * @param cursorAmount
190
    * @param isShiftClick
191
    * @param data
192
    * @param cc
193
    */
194
    private float detectTweaks1_5(final InventoryClickEvent event, final int slot, final ItemStack clicked, 
195
                                  final Material clickedMat, final Material cursorMat, 
196
                                  final int cursorAmount, final boolean isShiftClick, 
197
                                  final InventoryData data, final InventoryConfig cc) {
198
199
        if (cursorMat != data.fastClickLastCursor 
200
            && (!isShiftClick || clickedMat == Material.AIR || clickedMat != data.fastClickLastClicked) 
201
            || cursorMat == Material.AIR || cursorAmount != data.fastClickLastCursorAmount) {
202
            return 1f;
203
        }
204
        else if (clickedMat == Material.AIR || clickedMat == cursorMat 
205
                || isShiftClick && clickedMat == data.fastClickLastClicked ) {
206
            return Math.min(cc.fastClickNormalLimit , cc.fastClickShortTermLimit) 
207
                    / (float) (isShiftClick && clickedMat != Material.AIR ? (1.0 + Math.max(cursorAmount, InventoryUtil.getStackCount(event, clicked))) : cursorAmount)  * 0.75f;
208
        }
209
        return 1f;
210
    }
211
212
213
    private float getAmountWithAction(final InventoryClickEvent event, final int slot, final ItemStack clicked, 
214
                                      final Material clickedMat, final Material cursorMat, 
215
                                      final int cursorAmount, final boolean isShiftClick, 
216
                                      final String inventoryAction, 
217
                                      final InventoryData data, final InventoryConfig cc) {
218
219
        // Continuous drop feature with open inventories.
220
        if (inventoryAction.equals("DROP_ONE_SLOT")
221
            && slot == data.fastClickLastSlot 
222
            && clickedMat == data.fastClickLastClicked
223
            && event.getInventory().getType() == InventoryType.CRAFTING
224
            // && InventoryUtil.couldHaveInventoryOpen(player)
225
            // TODO: Distinguish if the inventory is really open.
226
            ) {
227
            return 0.6f;
228
        }
229
230
        // Collect to cursor.
231
        if (inventoryAction.equals("COLLECT_TO_CURSOR")) {
232
            final int stackCount = InventoryUtil.getStackCount(event, clicked);
233
            return stackCount <= 0 ? 1f : Math.min(cc.fastClickNormalLimit , cc.fastClickShortTermLimit) / stackCount * 0.75f;
234
        }
235
236
        // Shift click features.
237
        if ((inventoryAction.equals("MOVE_TO_OTHER_INVENTORY")) && cursorMat != Material.AIR) {
238
            // Let the legacy method do the side condition checks and counting for now.
239
            return detectTweaks1_5(event, slot, clicked, clickedMat, cursorMat, cursorAmount, isShiftClick, data, cc);
240
        }
241
        return 1f;
242
    }
243
}

How it counteracts this module

NoCheatPlus FastClick scores InventoryClickEvent traffic into an ActionFrequency with five 200ms buckets: the newest bucket is compared against the short-term limit of 4 and the full window against the normal limit of 15, with TickTask lag division before the comparison. A plain shift-click with an empty cursor counts 1.0 via getAmountWithAction. The check also carries the container-interaction path: any click landing within the 155ms min-interaction-duration default after the container opened adds a violation of (155 / duration) * 100, and slot -999 throws are excluded entirely.\n\nThe stock configuration is the honest gap: Delay 4 is exactly 5 clicks per second, one per 200ms bucket and 5 across the window, safely under both limits, so a default drain passes the rate paths. The pressure comes from the dial and the open: Delay 1 raises the rate to 20 per second, blowing the 15 window (about 5 VL per click, cancel at vl>150 within about 1.5 seconds), and the first click always lands within a frame of the chest opening because there is no first-delay setting, so the interact_time path scores close to 100 VL on every drain regardless of the delay. The module's tick-modulo pacing is rigid, which is exactly what a bucket check is built to fingerprint.

anticheat Open (inventory close on movement)

Open.java171 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.inventory;
16
17
import java.util.UUID;
18
19
import org.bukkit.GameMode;
20
import org.bukkit.Input;
21
import org.bukkit.entity.Player;
22
import org.bukkit.event.inventory.InventoryType;
23
import org.bukkit.event.inventory.InventoryType.SlotType;
24
25
import fr.neatmonster.nocheatplus.NCPAPIProvider;
26
import fr.neatmonster.nocheatplus.checks.Check;
27
import fr.neatmonster.nocheatplus.checks.CheckType;
28
import fr.neatmonster.nocheatplus.checks.combined.Improbable;
29
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
30
import fr.neatmonster.nocheatplus.checks.moving.model.PlayerMoveData;
31
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
32
import fr.neatmonster.nocheatplus.compat.registry.BukkitAPIAccessFactory;
33
import fr.neatmonster.nocheatplus.compat.versions.ClientVersion;
34
import fr.neatmonster.nocheatplus.components.registry.event.IHandle;
35
import fr.neatmonster.nocheatplus.components.registry.feature.IDisableListener;
36
import fr.neatmonster.nocheatplus.hooks.ExemptionSettings;
37
import fr.neatmonster.nocheatplus.players.DataManager;
38
import fr.neatmonster.nocheatplus.players.IPlayerData;
39
import fr.neatmonster.nocheatplus.utilities.collision.CollisionUtil;
40
import fr.neatmonster.nocheatplus.utilities.entity.InventoryUtil;
41
42
/**
43
 * Watch over open inventories - check with "combined" static access, put here because it has too much to do with inventories.
44
 * @author asofold
45
 */
46
public class Open extends Check implements IDisableListener {
47
48
    private static Open instance = null;
49
50
    private UUID nestedPlayer = null;
51
52
    private final IHandle<ExemptionSettings> exeSet = NCPAPIProvider.getNoCheatPlusAPI().getGenericInstanceHandle(ExemptionSettings.class);
53
    
54
    // TODO: Add specific contexts (allow different settings for fight / blockbreak etc.).
55
56
    /**
57
     * Static access check, if there is a cancel-action flag the caller should have stored that locally already and use the result to know if to cancel or not.
58
     * 
59
     * @param player
60
     * @return If cancelling some event is opportune (open inventory and cancel flag set).
61
     */
62
    public static boolean checkClose(Player player) {
63
        return instance.check(player);
64
    }
65
66
    public Open() {
67
        super(CheckType.INVENTORY_OPEN);
68
        instance = this;
69
    }
70
71
    @Override
72
    public void onDisable() {
73
        instance = null;
74
        nestedPlayer = null;
75
    }
76
77
    /**
78
     * Enforce a closed inventory on this generic event/action (without checking for any specific side condition) <br>
79
     * This check contains the isEnabled checking (!). Inventory is closed if set in the config. <br>
80
     * Also resets inventory opening time and interaction time.
81
     * 
82
     * @param player
83
     * @return True, if the inventory has been successfully closed. This will also reset the inventory open time and interaction time.
84
     */
85
    public boolean check(final Player player) {
86
        final boolean isShulkerBox = BukkitAPIAccessFactory.getBukkitAccess().getTopInventory(player).getType().toString().equals("SHULKER_BOX");
87
        if (
88
            // TODO: POC: Item duplication with teleporting NPCS, having their inventory open.
89
            exeSet.getHandle().isRegardedAsNpc(player)
90
            || !isEnabled(player) 
91
            || !InventoryUtil.hasInventoryOpen(player)
92
            // Workaround, Open would disallow players from opening the container if standing on top
93
            // of the shulker. Reason for this is unknown
94
            || isShulkerBox) {
95
            return false;
96
        }
97
        final IPlayerData pData = DataManager.getPlayerData(player);
98
        final InventoryConfig cc = pData.getGenericInstance(InventoryConfig.class);
99
        if (cc.openClose) {
100
            // NOTE about UUID stuff: https://github.com/NoCheatPlus/NoCheatPlus/commit/a41ff38c997bcca780da32681e92216880e9e1b0
101
            final UUID id = player.getUniqueId();
102
            if ((this.nestedPlayer == null || !id.equals(this.nestedPlayer))) {
103
                // (The second condition represents an error, but we don't handle alternating things just yet.)
104
                this.nestedPlayer = id;
105
                player.closeInventory();
106
                pData.getGenericInstance(InventoryData.class).inventoryOpenTime = 0;
107
                pData.getGenericInstance(InventoryData.class).containerInteractTime = 0;
108
                this.nestedPlayer = null;
109
                return true;
110
            }
111
        }
112
        return false;
113
    }
114
115
    /**
116
     * To be called on {@link org.bukkit.event.player.PlayerMoveEvent}; pre-requisite is {@link InventoryUtil#hasInventoryOpen(Player)} having returned true. <br>
117
     * (Against InventoryMove cheats and similar)<br>
118
     * 
119
     * @param player
120
     * @param pData
121
     * @return True, if the open inventory needs to be closed during this movement.
122
     */
123
    public boolean checkOnMove(final Player player, final IPlayerData pData) {
124
        if (BridgeMisc.isWASDImpulseKnown(player)) {
125
            // Use WASD input directly if available (1.21.1+).
126
            Input input = player.getCurrentInput();
127
            boolean moving = input.isLeft() || input.isRight() || input.isForward() || input.isBackward() || input.isJump();
128
            if (moving) {
129
                final InventoryConfig cc = pData.getGenericInstance(InventoryConfig.class);
130
                if (cc.openImprobableWeight > 0.0) {
131
                    Improbable.feed(player, cc.openImprobableWeight, System.currentTimeMillis());
132
                }
133
                return true;
134
            }
135
            return false;
136
        }
137
        
138
        final MovingData mData = pData.getGenericInstance(MovingData.class);
139
        final InventoryConfig cc = pData.getGenericInstance(InventoryConfig.class);
140
        final InventoryData data = pData.getGenericInstance(InventoryData.class);
141
        final boolean creative = player.getGameMode() == GameMode.CREATIVE && ((data.clickedSlotType == SlotType.QUICKBAR) || cc.openDisableCreative);
142
        final boolean isMerchant = BukkitAPIAccessFactory.getBukkitAccess().getTopInventory(player).getType() == InventoryType.MERCHANT;
143
        final PlayerMoveData thisMove = mData.playerMoves.getCurrentMove();
144
        // Skipping conditions first.
145
        if (
146
            // Ignore duplicate packets
147
            mData.lastMoveNoMove
148
            // Can't check vehicles
149
            || player.isInsideVehicle()
150
            // In creative or middle click
151
            || creative 
152
            // Ignore merchant inventories.
153
            || isMerchant 
154
            // Velocity is ignored altogether. TODO: Should be horizontal too. Maybe this still work fine, most the time appear together
155
            || !mData.getOrUseVerticalVelocity(thisMove.yDistance).isEmpty()
156
            //|| mData.useHorizontalVelocity(thisMove.hDistance - mData.getHorizontalFreedom()) >= thisMove.hDistance - mData.getHorizontalFreedom()
157
            // Ignore entity pushing.
158
            || pData.getClientVersion().isAtLeast(ClientVersion.V_1_9) && CollisionUtil.isCollidingWithEntities(player, 0.5, 0.1, 0.5, true)) {
159
            return false;
160
        }
161
            
162
        // Actual detection: do assume player to be actively moving even if we don't actually know the direction (MAYBE, needs testing)
163
        if (thisMove.hasImpulse.decide()) {
164
            if (cc.openImprobableWeight > 0.0) {
165
                Improbable.feed(player, cc.openImprobableWeight, System.currentTimeMillis());
166
            }
167
            return true;
168
        }
169
        return false;
170
    }
171
}

How it counteracts this module

NCP's Open check watches PlayerMoveEvent traffic while an inventory window is open. checkOnMove skips duplicate packets, vehicles, creative quickbar clicks, merchants and velocity-affected moves, then decides whether the move carries an impulse: with modern input it reads the WASD/jump bits directly, otherwise it falls back to the movement model's hasImpulse decision. An impulse while open feeds Improbable and returns true, and the caller force-closes the inventory, resetting inventoryOpenTime and containerInteractTime.\n\nThe module suppresses nothing, so any strafing or stepping during a drain is visible to the check and a single impulse move mid-steal closes the chest and aborts the session. The practical tension is the same as every stealer: a still player never trips it, so the check is a soft counter that converts a movement mistake into a lost window and resets the open-time baseline FastClick's interact_time path reads. The Nearby mode's walking between chests happens with no window open and is invisible to it.

anticheat InventoryActions (window state mismatch)

InventoryActions.java60 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.inventory;
20
21
/*
22
 * InventoryActions check originally written by Havesta; modified, split apart, and implemented into Hawk by Islandscout
23
 *
24
 * InventoryActions checks if a player is
25
 * - interacting with entities/blocks while inventory is opened
26
 */
27
28
import me.islandscout.hawk.HawkPlayer;
29
import me.islandscout.hawk.check.CustomCheck;
30
import me.islandscout.hawk.event.*;
31
32
public class InventoryActions extends CustomCheck {
33
34
    public InventoryActions() {
35
        super("inventoryactions", true, 3, 5, 0.999, 5000, "%player% failed inventory-actions, VL: %vl%", null);
36
    }
37
38
    @Override
39
    protected void check(Event e) {
40
        HawkPlayer pp = e.getHawkPlayer();
41
42
        //player tried to interact with entities/world while an inventory window is open
43
        if(pp.hasInventoryOpen() != 0 && (e instanceof InteractEntityEvent || e instanceof BlockDigEvent ||
44
                e instanceof ArmSwingEvent || e instanceof InteractWorldEvent)) {
45
            punish(pp, true, e);
46
            e.resync();
47
            //TODO After failing several times, there's a chance that they could be legit, but the inventory state is glitched. Close the player's inventory.
48
        }
49
50
        //player tried to interact with inventory while it is closed
51
        else if(pp.hasInventoryOpen() == 0 && e instanceof ClickInventoryEvent) {
52
            //TODO also check that window ID makes sense with the window type (eg. ID 0 must mean hasInventoryOpen() == 0)
53
            punish(pp, true, e);
54
            e.resync();
55
        }
56
        else {
57
            reward(pp);
58
        }
59
    }
60
}

How it counteracts this module

Hawk's InventoryActions punishes world interaction while a window is open and, more importantly for stealers, punishes ClickInventoryEvent packets when HawkPlayer.hasInventoryOpen() is zero. Hawk derives the open state from the S2D window-open, C16 inventory command and close packets, so it tracks the server's window lifecycle, not the client's GUI state, and every punish calls e.resync().\n\nThe module's close-then-reopen cadence is the race surface. The empty-chest branch calls mc.displayGuiScreen(null), which queues C0D, and in Nearby mode the next delay tick can immediately right-click another chest and swing; if Hawk has not yet processed the C0D, the C0A swing and C08 open arrive while hasInventoryOpen is still non-zero and are punished and resynced. The reverse edge is equally live: a click that lands after the server-side close processed arrives with the window flag at zero and is punished as a click on a closed window. The emptiedChests list gives no cover because the check is content-blind and window-id aware.

anticheat FastConsume (eat-duration; silent for stealers)

FastConsume.java28 lines · Java
1
package me.vrekt.arc.check.inventory;
2
3
import me.vrekt.arc.Arc;
4
import me.vrekt.arc.check.Check;
5
import me.vrekt.arc.check.CheckType;
6
import me.vrekt.arc.data.inventory.InventoryData;
7
import org.bukkit.entity.Player;
8
9
public class FastConsume extends Check {
10
11
    private int consumeTime = 0;
12
13
    public FastConsume() {
14
        super(CheckType.FASTCONSUME);
15
16
        consumeTime = Arc.getCheckManager().getValueInt(CheckType.FASTCONSUME, "consume-time");
17
    }
18
19
    public boolean check(Player player, InventoryData data) {
20
21
        long now = System.currentTimeMillis();
22
        long last = data.getConsumeTime();
23
        long total = now - last;
24
25
        // check if the time it took to consume the item is less than allowed.
26
        return total < consumeTime && checkViolation(player, "consume time less than allowed.");
27
    }
28
}

How it counteracts this module

Arc v2's FastConsume guards the item-use path of the inventory family. The inventory listener stamps a consume time on the right-click of an edible or potion, and the check compares it against the consume-time limit (1280ms default) when PlayerItemConsumeEvent fires, flagging any consume that completes faster than a real eat could. The mechanism only engages when a consume event actually lands, which requires the full vanilla use duration to elapse.\n\nFor this module the check is silent by design: shift-click C0E traffic, the C0D close and the Nearby C08 opens never produce a consume event, so FastConsume stays quiet through an entire drain. The entry belongs in the set because the same C0E corpus pools the eat-rate checks with the click-rate checks, and it documents the boundary honestly: the real pressure on this module is FastClick's click ledger, while FastConsume is the guard for the instant-consume sibling modules, which would trip it on any server that processes eats immediately.

← Back to Analysis Hub