Spicy Block Fly module 2 files, 517 lines

Spicy Block Fly: Full Source Analysis

Spicy's Block Fly is a safe-walk block placer.

info/spicyclient/modules/movement/BlockFly.java · GitHub source ↗

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

Packets This Module Uses

Analysis

Overview

Spicy's Block Fly is a safe-walk block placer. It hijacks the EventSneaking hook inside Entity.moveEntity to force the sneak edge-clamp while the player is grounded, cancels incoming S2F set-slot packets so server inventory corrections never apply, rewrites every outbound C03 look to the last placement rotation, and, whenever the cell directly below the player is air with solid ground two cells down, picks a block from the hotbar, switches to it locally and places it at the feet through the vanilla player controller. The placement look is computed by an in-module aim routine that pins pitch toward 90 degrees, and the look latch makes the server see the player looking at each placement.

The sneak clamp

EventSneaking fires from Entity.moveEntity with the vanilla gate flag = onGround && isSneaking() && instanceof EntityPlayer, and the fork lets listeners override both the sneaking state and the offset used by the edge-clamp loop. The module forces sneaking true with offset -1 whenever the moving entity is grounded and an EntityPlayer, so the clamp loop tests the bounding box shifted one block down and the player cannot walk off an edge; the clamp is released in air, where the module sets sneaking false, and the whole handler skips while the client's killaura holds a target.

Under-foot placement

The EventMotion post handler checks the block state one cell below the player. When that cell is air and the cell two below is solid, it scans hotbar slots 36-44 for an ItemBlock whose localized name does not contain chest or table, switches to it through inventory.setCurrentItem, and calls mc.playerController.onPlayerRightClick at the under-below position with facing UP and a hit vector from RotationUtils.getVectorForRotation, which produces a real C08 placement and a swing. Side placements probe a position offset along motionZ and walk the facing search through findFacingAndBlockPosForBlock, which scans the block neighbors and their neighbors for a solid anchor. The event yaw and pitch are then set from getRotationsHypixel, an atan2 aim at the block center with pitch boosted by 30 degrees and clamped to 90, and the same values latch into lastYaw and lastPitch.

Wire shape

The EventSendPacket pre handler rewrites the yaw and pitch of every outbound C03PacketPlayer to lastYaw and lastPitch, so the server-side look stream reports the placement look while the module is placing. The S2F cancel drops every incoming set-slot packet, keeping the locally switched hotbar slot free of server corrections. The placement path emits at most one C08 per tick because every branch returns after its placement, and the C09 held-item change rides the vanilla syncCurrentPlayItem call when the tracked slot diverges. Motion itself is ordinary: the edge clamp is a client-side collision change and the C03 stream carries normal walk speeds.

source BlockFly.java (module)

BlockFly.java362 lines · JavaOriginal ↗
1
package info.spicyclient.modules.movement;
2
3
import java.util.Comparator;
4
import java.util.Random;
5
6
import org.lwjgl.input.Keyboard;
7
import org.newdawn.slick.tests.xml.ItemContainer;
8
9
import info.spicyclient.SpicyClient;
10
import info.spicyclient.chatCommands.Command;
11
import info.spicyclient.events.Event;
12
import info.spicyclient.events.listeners.EventMotion;
13
import info.spicyclient.events.listeners.EventPacket;
14
import info.spicyclient.events.listeners.EventRender3D;
15
import info.spicyclient.events.listeners.EventSendPacket;
16
import info.spicyclient.events.listeners.EventSneaking;
17
import info.spicyclient.events.listeners.EventUpdate;
18
import info.spicyclient.modules.Module;
19
import info.spicyclient.settings.BooleanSetting;
20
import info.spicyclient.settings.ModeSetting;
21
import info.spicyclient.settings.NumberSetting;
22
import info.spicyclient.settings.SettingChangeEvent;
23
import info.spicyclient.settings.SettingChangeEvent.type;
24
import info.spicyclient.util.MovementUtils;
25
import info.spicyclient.util.RenderUtils;
26
import info.spicyclient.util.RotationUtils;
27
import info.spicyclient.util.Timer;
28
import net.minecraft.block.Block;
29
import net.minecraft.block.BlockAir;
30
import net.minecraft.client.Minecraft;
31
import net.minecraft.client.entity.EntityPlayerSP;
32
import net.minecraft.entity.Entity;
33
import net.minecraft.entity.player.EntityPlayer;
34
import net.minecraft.entity.player.InventoryPlayer;
35
import net.minecraft.init.Blocks;
36
import net.minecraft.init.Items;
37
import net.minecraft.item.ItemBlock;
38
import net.minecraft.item.ItemStack;
39
import net.minecraft.network.Packet;
40
import net.minecraft.network.play.client.C02PacketUseEntity;
41
import net.minecraft.network.play.client.C03PacketPlayer;
42
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
43
import net.minecraft.network.play.client.C09PacketHeldItemChange;
44
import net.minecraft.network.play.server.S2FPacketSetSlot;
45
import net.minecraft.util.BlockPos;
46
import net.minecraft.util.EnumFacing;
47
import net.minecraft.util.MathHelper;
48
import net.minecraft.util.Vec3;
49
50
public class BlockFly extends Module {
51
	
52
	public BlockFly() {
53
		super("Block Fly", Keyboard.KEY_NONE, Category.MOVEMENT);
54
	}
55
	
56
	public void onEnable() {
57
		
58
		lastYaw = mc.thePlayer.rotationYaw;
59
		lastPitch = mc.thePlayer.rotationPitch;
60
		
61
	}
62
	
63
	public void onDisable() {
64
		
65
	}
66
	
67
	public static transient float lastYaw = 0, lastPitch = 0;
68
	public static transient Timer timer = new Timer();
69
	
70
	public void onEvent(Event e) {
71
		
72
		if (e instanceof EventSneaking) {
73
			
74
			if (e.isPre()) {
75
				
76
				if (SpicyClient.config.killaura.isEnabled() && SpicyClient.config.killaura.target != null) {
77
					return;
78
				}
79
				
80
				EventSneaking sneak = (EventSneaking) e;
81
				
82
				if (sneak.entity.onGround && sneak.entity instanceof EntityPlayer) {
83
					sneak.sneaking = true;
84
				}else {
85
					sneak.sneaking = false;
86
				}
87
				sneak.offset = -1D;
88
				sneak.revertFlagAfter = true;
89
				
90
			}
91
			
92
		}
93
		
94
		if (e instanceof EventPacket && e.isPre()) {
95
			
96
			if (SpicyClient.config.killaura.isEnabled() && SpicyClient.config.killaura.target != null) {
97
				return;
98
			}
99
			
100
			if (((EventPacket)e).packet instanceof S2FPacketSetSlot) {
101
				e.setCanceled(true);
102
			}
103
			
104
		}
105
		
106
		if (e instanceof EventSendPacket & e.isPre()) {
107
			
108
			if (SpicyClient.config.killaura.isEnabled() && SpicyClient.config.killaura.target != null) {
109
				return;
110
			}
111
			
112
			if (((EventSendPacket)e).packet instanceof C03PacketPlayer) {
113
				((C03PacketPlayer)((EventSendPacket)e).packet).setYaw(lastYaw);
114
				((C03PacketPlayer)((EventSendPacket)e).packet).setPitch(lastPitch);
115
			}
116
			
117
		}
118
		
119
		if (e instanceof EventRender3D && e.isPre()) {
120
			
121
			BlockPos below = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1D, mc.thePlayer.posZ);
122
			
123
			for (int i = 0; i < 5; i++) {
124
				
125
				RenderUtils.drawLine(below.getX(), below.getY(), below.getZ(), below.getX() + 1, below.getY(), below.getZ());
126
				RenderUtils.drawLine(below.getX(), below.getY() + 1, below.getZ(), below.getX() + 1, below.getY() + 1, below.getZ());
127
				RenderUtils.drawLine(below.getX(), below.getY(), below.getZ(), below.getX(), below.getY(), below.getZ() + 1);
128
				RenderUtils.drawLine(below.getX(), below.getY() + 1, below.getZ(), below.getX(), below.getY() + 1, below.getZ() + 1);
129
				RenderUtils.drawLine(below.getX(), below.getY(), below.getZ(), below.getX(), below.getY() + 1, below.getZ());
130
				RenderUtils.drawLine(below.getX(), below.getY() + 1, below.getZ(), below.getX(), below.getY() + 1, below.getZ());
131
				RenderUtils.drawLine(below.getX() + 1, below.getY(), below.getZ(), below.getX() + 1, below.getY() + 1, below.getZ());
132
				RenderUtils.drawLine(below.getX() + 1, below.getY() + 1, below.getZ(), below.getX() + 1, below.getY() + 1, below.getZ());
133
				RenderUtils.drawLine(below.getX(), below.getY(), below.getZ() + 1, below.getX(), below.getY() + 1, below.getZ() + 1);
134
				RenderUtils.drawLine(below.getX(), below.getY() + 1, below.getZ() + 1, below.getX(), below.getY() + 1, below.getZ() + 1);
135
				RenderUtils.drawLine(below.getX() + 1, below.getY(), below.getZ() + 1, below.getX(), below.getY(), below.getZ() + 1);
136
				RenderUtils.drawLine(below.getX() + 1, below.getY() + 1, below.getZ() + 1, below.getX(), below.getY() + 1, below.getZ() + 1);
137
				RenderUtils.drawLine(below.getX() + 1, below.getY(), below.getZ() + 1, below.getX() + 1, below.getY() + 1, below.getZ() + 1);
138
				RenderUtils.drawLine(below.getX() + 1, below.getY() + 1, below.getZ(), below.getX() + 1, below.getY() + 1, below.getZ() + 1);
139
				RenderUtils.drawLine(below.getX() + 1, below.getY(), below.getZ(), below.getX() + 1, below.getY(), below.getZ() + 1);
140
				
141
			}
142
			
143
		}
144
		
145
		if (e instanceof EventUpdate && e.isPre() && MovementUtils.isOnGround(0.4)) {
146
			
147
			if (SpicyClient.config.killaura.isEnabled() && SpicyClient.config.killaura.target != null) {
148
				return;
149
			}
150
			
151
			//mc.thePlayer.onGround = false;
152
			
153
			EventUpdate update = (EventUpdate)e;
154
			
155
			double motionX = mc.thePlayer.motionX, motionZ = mc.thePlayer.motionZ;
156
			
157
			if (motionX < 0)
158
				motionX *= -1;
159
			
160
			if (motionZ < 0)
161
				motionZ *= -1;
162
			
163
			if (motionX < 0.05 && motionZ < 0.05 && MovementUtils.isOnGround(0.3) && mc.gameSettings.keyBindJump.isKeyDown()) {
164
				if (mc.gameSettings.keyBindJump.isKeyDown() && MovementUtils.isOnGround(0.25)) {
165
					
166
		            //mc.thePlayer.motionX = 0.0D;
167
		            //mc.thePlayer.motionZ = 0.0D;
168
		            //mc.thePlayer.motionY = 0.375;
169
		            if (timer.hasTimeElapsed(1500, true)) {
170
		               //mc.thePlayer.motionY = -0.28D;
171
		            }
172
					
173
				}
174
			}
175
			
176
			
177
		}
178
		
179
		if (e instanceof EventMotion && e.isPost()) {
180
			
181
			if (SpicyClient.config.killaura.isEnabled() && SpicyClient.config.killaura.target != null) {
182
				return;
183
			}
184
			
185
			EventMotion event = (EventMotion) e;
186
			
187
			//mc.thePlayer.setSprinting(false);
188
			
189
			event.setYaw(lastYaw);
190
			event.setYaw(lastPitch);
191
			
192
			ItemStack i = mc.thePlayer.getCurrentEquippedItem();
193
			BlockPos below = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1D, mc.thePlayer.posZ);
194
			
195
			if (mc.theWorld.getBlockState(below).getBlock() == Blocks.air) {
196
				
197
				for (EnumFacing facing : EnumFacing.VALUES) {
198
					
199
					switch (facing) {
200
					case UP:
201
						
202
						BlockPos underBelow = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 2D, mc.thePlayer.posZ);
203
						
204
						if (mc.theWorld.getBlockState(underBelow).getBlock() != Blocks.air) {
205
							
206
							ItemStack block = mc.thePlayer.getCurrentEquippedItem();
207
							
208
							for (int g = 0; g < 9; g++) {
209
								
210
								if (mc.thePlayer.inventoryContainer.getSlot(g + 36).getHasStack() && mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem() instanceof ItemBlock && mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().stackSize > 0 && !((ItemBlock)mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem()).getBlock().getLocalizedName().toLowerCase().contains("chest") && !((ItemBlock)mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem()).getBlock().getLocalizedName().toLowerCase().contains("table")) {
211
									
212
									InventoryPlayer inventoryplayer = mc.thePlayer.inventory;
213
									inventoryplayer.setCurrentItem(mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem(), 0, false, true);
214
									
215
								}
216
								
217
							}
218
							
219
							if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, block, underBelow, EnumFacing.UP, RotationUtils.getVectorForRotation(getRotationsHypixel(underBelow, EnumFacing.UP)[1], getRotationsHypixel(underBelow, EnumFacing.UP)[1])) || true) {
220
								
221
								mc.thePlayer.swingItem();
222
								event.setYaw(getRotationsHypixel(underBelow, facing)[0]);
223
								event.setPitch(getRotationsHypixel(underBelow, facing)[1]);
224
								lastYaw = event.yaw;
225
								lastPitch = event.pitch;
226
								return;
227
								
228
							}
229
							return;
230
							
231
						}
232
						
233
						break;
234
					case NORTH:
235
					case EAST:
236
					case SOUTH:
237
					case WEST:
238
						
239
						BlockInfo defaultPos = findFacingAndBlockPosForBlock(new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1D, mc.thePlayer.posZ + mc.thePlayer.motionZ));
240
						
241
						if (defaultPos == null)
242
							return;
243
						
244
						if (mc.theWorld.getBlockState(defaultPos.pos).getBlock() != Blocks.air) {
245
							
246
							ItemStack block = mc.thePlayer.getCurrentEquippedItem();
247
							
248
							for (int g = 0; g < 9; g++) {
249
								
250
								if (mc.thePlayer.inventoryContainer.getSlot(g + 36).getHasStack() && mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem() instanceof ItemBlock && mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().stackSize > 0 && !((ItemBlock)mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem()).getBlock().getLocalizedName().toLowerCase().contains("chest") && !((ItemBlock)mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem()).getBlock().getLocalizedName().toLowerCase().contains("table")) {
251
									
252
									InventoryPlayer inventoryplayer = mc.thePlayer.inventory;
253
									inventoryplayer.setCurrentItem(mc.thePlayer.inventoryContainer.getSlot(g + 36).getStack().getItem(), 0, false, true);
254
									
255
								}
256
								
257
							}
258
							if (mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, block, defaultPos.pos, defaultPos.facing, RotationUtils.getVectorForRotation(getRotationsHypixel(defaultPos.targetPos, defaultPos.facing)[0], getRotationsHypixel(defaultPos.targetPos, defaultPos.facing)[1])) || true) {
259
								
260
								mc.thePlayer.swingItem();
261
								event.setYaw(getRotationsHypixel(defaultPos.pos.offset(defaultPos.facing), defaultPos.facing)[0]);
262
								event.setPitch(getRotationsHypixel(defaultPos.pos.offset(defaultPos.facing), defaultPos.facing)[1]);
263
								lastYaw = event.yaw;
264
								lastPitch = event.pitch;
265
								return;
266
								
267
							}
268
							return;
269
							
270
						}
271
						
272
						break;
273
						
274
					}
275
					
276
				}
277
				
278
			}
279
			
280
		}
281
		
282
	}
283
	
284
	private BlockInfo findFacingAndBlockPosForBlock(BlockPos input) {
285
		
286
		BlockInfo output = new BlockInfo();
287
		output.pos = input;		
288
		
289
		for (EnumFacing face : EnumFacing.VALUES) {
290
			
291
			if (mc.theWorld.getBlockState(output.pos.offset(face)).getBlock() != Blocks.air) {
292
				
293
				output.pos = output.pos.offset(face);
294
				output.facing = face.getOpposite();
295
				output.targetPos = new BlockPos(mc.thePlayer.posX, mc.thePlayer.posY - 1D, mc.thePlayer.posZ);
296
				return output;
297
				
298
			}
299
			
300
		}
301
		
302
		for (EnumFacing face : EnumFacing.VALUES) {
303
			
304
			if (mc.theWorld.getBlockState(output.pos.offset(face)).getBlock() == Blocks.air) {
305
				
306
				for (EnumFacing face1 : EnumFacing.VALUES) {
307
					
308
					if (mc.theWorld.getBlockState(output.pos.offset(face).offset(face1)).getBlock() != Blocks.air) {
309
						
310
						output.pos = output.pos.offset(face).offset(face1);
311
						output.facing = face.getOpposite();
312
						output.targetPos = output.pos.offset(face);
313
						return output;
314
						
315
					}
316
					
317
				}
318
				
319
			}
320
			
321
		}
322
		
323
		return null;
324
		
325
	}
326
	
327
	public float[] getRotationsHypixel(BlockPos paramBlockPos, EnumFacing paramEnumFacing) {
328
		double offset = 0.5;
329
		offset = 1;
330
        double d1 = (double)paramBlockPos.getX() + offset - mc.thePlayer.posX + (double)paramEnumFacing.getFrontOffsetX() / 2.0D;
331
        double d2 = (double)paramBlockPos.getZ() + offset - mc.thePlayer.posZ + (double)paramEnumFacing.getFrontOffsetZ() / 2.0D;
332
        double d3 = mc.thePlayer.posY + (double)mc.thePlayer.getEyeHeight() - ((double)paramBlockPos.getY() + 0.5D);
333
        double d4 = (double)MathHelper.sqrt_double(d1 * d1 + d2 * d2);
334
        float f1 = (float)(Math.atan2(d2, d1) * 180.0D / 3.141592653589793D) - 90.0F;
335
        float f2 = (float)(Math.atan2(d3, d4) * 180.0D / 3.141592653589793D);
336
        if (f1 < 0.0F) {
337
            f1 += 360.0F;
338
        }
339
        
340
        //f1 += 180;
341
        f1 = MathHelper.wrapAngleTo180_float(f1);
342
        f2 += 30;
343
        
344
        if (f2 > 90)
345
        	f2 = 90;
346
        
347
        if (f2 < -90)
348
        	f2 = -90;
349
        
350
        //Command.sendPrivateChatMessage(f1 + " : " + f2);
351
        
352
        return new float[]{f1, f2};
353
    }
354
	
355
	private class BlockInfo {
356
		
357
		BlockPos pos, targetPos;
358
		EnumFacing facing;
359
		
360
	}
361
	
362
}

What this file does

The module is four handlers. EventSneaking pre forces the grounded sneak clamp with offset -1, EventPacket pre cancels S2F set-slot packets, EventSendPacket pre rewrites every C03 yaw and pitch to the latched placement look, and EventMotion post runs the placement machine: the air-below check, the hotbar ItemBlock scan with the chest and table name filter, the local slot switch, the playerController.onPlayerRightClick call that emits the real C08, and the getRotationsHypixel aim latch.

The placement logic is strictly gated: the EventUpdate pre branch only runs the motion probes, and the actual placement fires only when the below cell is air and the two-below cell is solid (or a side anchor is found), so the module idles on flat ground and only places while crossing a gap or edge. Every branch returns after the first placement, capping the rate at one C08 per tick.

source MovementUtils.java (ground probes)

MovementUtils.java155 lines · JavaOriginal ↗
1
package info.spicyclient.util;
2
3
import info.spicyclient.events.listeners.EventUpdate;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.client.entity.EntityPlayerSP;
6
import net.minecraft.entity.player.EntityPlayer;
7
8
public class MovementUtils {
9
	
10
	public static Minecraft mc = Minecraft.getMinecraft();
11
	
12
	
13
	public static double getBlocksPerSecond() {
14
		
15
		if (mc.thePlayer == null || mc.thePlayer.ticksExisted < 1) {
16
			return 0;
17
		}
18
		
19
		return mc.thePlayer.getDistance(mc.thePlayer.lastTickPosX, mc.thePlayer.lastTickPosY, mc.thePlayer.lastTickPosZ) * (Minecraft.getMinecraft().timer.ticksPerSecond * Minecraft.getMinecraft().timer.timerSpeed);
20
		
21
	}
22
	
23
	public static float getSpeed() {
24
        return (float) Math.sqrt(mc.thePlayer.motionX * mc.thePlayer.motionX + mc.thePlayer.motionZ * mc.thePlayer.motionZ);
25
    }
26
27
    public static void strafe() {
28
        strafe(getSpeed());
29
    }
30
31
    public static boolean isMoving() {
32
        return mc.thePlayer != null && (mc.thePlayer.movementInput.moveForward != 0F || mc.thePlayer.movementInput.moveStrafe != 0F);
33
    }
34
35
    public static boolean hasMotion() {
36
        return mc.thePlayer.motionX != 0D && mc.thePlayer.motionZ != 0D && mc.thePlayer.motionY != 0D;
37
    }
38
39
    public static void strafe(final float speed) {
40
        if(!isMoving())
41
            return;
42
43
        final double yaw = getDirection();
44
        mc.thePlayer.motionX = -Math.sin(yaw) * speed;
45
        mc.thePlayer.motionZ = Math.cos(yaw) * speed;
46
    }
47
48
    public static void forward(final double length) {
49
        final double yaw = Math.toRadians(mc.thePlayer.rotationYaw);
50
        mc.thePlayer.setPosition(mc.thePlayer.posX + (-Math.sin(yaw) * length), mc.thePlayer.posY, mc.thePlayer.posZ + (Math.cos(yaw) * length));
51
    }
52
53
    public static double getDirection() {
54
        float rotationYaw = mc.thePlayer.rotationYaw;
55
56
        if(mc.thePlayer.moveForward < 0F)
57
            rotationYaw += 180F;
58
59
        float forward = 1F;
60
        if(mc.thePlayer.moveForward < 0F)
61
            forward = -0.5F;
62
        else if(mc.thePlayer.moveForward > 0F)
63
            forward = 0.5F;
64
65
        if(mc.thePlayer.moveStrafing > 0F)
66
            rotationYaw -= 90F * forward;
67
68
        if(mc.thePlayer.moveStrafing < 0F)
69
            rotationYaw += 90F * forward;
70
71
        return Math.toRadians(rotationYaw);
72
    }
73
    
74
    // Found on github
75
    public static void setMotion(double speed) {
76
        double forward = mc.thePlayer.movementInput.moveForward;
77
        double strafe = mc.thePlayer.movementInput.moveStrafe;
78
        float yaw = mc.thePlayer.rotationYaw;
79
        if ((forward == 0.0D) && (strafe == 0.0D)) {
80
        	mc.thePlayer.motionX = 0;
81
        	mc.thePlayer.motionZ = 0;
82
        } else {
83
            if (forward != 0.0D) {
84
                if (strafe > 0.0D) {
85
                    yaw += (forward > 0.0D ? -45 : 45);
86
                } else if (strafe < 0.0D) {
87
                    yaw += (forward > 0.0D ? 45 : -45);
88
                }
89
                strafe = 0.0D;
90
                if (forward > 0.0D) {
91
                    forward = 1;
92
                } else if (forward < 0.0D) {
93
                    forward = -1;
94
                }
95
            }
96
            mc.thePlayer.motionX = forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F)); 
97
            mc.thePlayer.motionZ = forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F));
98
        }
99
    }
100
    
101
    public static void setMotion(double speed, float directionInYaw) {
102
        double forward = mc.thePlayer.movementInput.moveForward;
103
        double strafe = mc.thePlayer.movementInput.moveStrafe;
104
        float yaw = directionInYaw;
105
        if ((forward == 0.0D) && (strafe == 0.0D)) {
106
        	mc.thePlayer.motionX = 0;
107
        	mc.thePlayer.motionZ = 0;
108
        } else {
109
            if (forward != 0.0D) {
110
                if (strafe > 0.0D) {
111
                    yaw += (forward > 0.0D ? -45 : 45);
112
                } else if (strafe < 0.0D) {
113
                    yaw += (forward > 0.0D ? 45 : -45);
114
                }
115
                strafe = 0.0D;
116
                if (forward > 0.0D) {
117
                    forward = 1;
118
                } else if (forward < 0.0D) {
119
                    forward = -1;
120
                }
121
            }
122
            mc.thePlayer.motionX = forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F)); 
123
            mc.thePlayer.motionZ = forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F));
124
        }
125
    }
126
    
127
    public static boolean isOnGround(double height) {
128
        if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().offset(0.0D, -height, 0.0D)).isEmpty()) {
129
            return true;
130
        } else {
131
            return false;
132
        }
133
    }
134
    
135
    public static boolean isOnGround(double height, EntityPlayer player) {
136
        if (!mc.theWorld.getCollidingBoundingBoxes(player, player.getEntityBoundingBox().offset(0.0D, -height, 0.0D)).isEmpty()) {
137
            return true;
138
        } else {
139
            return false;
140
        }
141
    }
142
    
143
    public static boolean canStep(double height) {
144
    	
145
    	if (!mc.thePlayer.isCollidedHorizontally || !isOnGround(0.001))
146
    		return false;
147
    	
148
    	if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().expand(0.01, 0, 0.01).offset(0.0D, height - 0.01, 0.0D)).isEmpty() && mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, mc.thePlayer.getEntityBoundingBox().expand(0.1, 0, 0.01).offset(0.0D, height + 0.1, 0.0D)).isEmpty()) {
149
            return true;
150
        } else {
151
            return false;
152
        }
153
    }
154
    
155
}

What this file does

The module's placement cadence is gated by this class's isOnGround(height) probe, which tests the world collision boxes against the entity bounding box offset downward by the given height. The EventUpdate pre branch only proceeds when isOnGround(0.4) succeeds, and the inner motion test layers isOnGround(0.3) and isOnGround(0.25) probes plus a jump-key check, so the module waits for grounded stability before arming the placement logic.

The helper also carries the fork's motion conventions used across the movement modules, including setMotion with 45-degree strafe folding and the input-derived direction model, which places this module's placement gating in the same util family as the fly, longjump and sprint modules of the same client.

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 FastPlace (placement rate)

FastPlace.java103 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.blockplace;
16
17
import org.bukkit.block.Block;
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
 * A check used to verify if the player isn't placing blocks too quickly.
27
 */
28
public class FastPlace extends Check {
29
30
    /**
31
     * Instantiates a new fast place check.
32
     */
33
    public FastPlace() {
34
        super(CheckType.BLOCKPLACE_FASTPLACE);
35
    }
36
37
    /**
38
     * Checks a player.
39
     * 
40
     * @param player
41
     *            the player
42
     * @param block
43
     *            the block
44
     * @param tick
45
     * @param data
46
     * @param cc
47
     * @param pData
48
     * @return true, if successful
49
     */
50
    public boolean check(final Player player, final Block block, final int tick, final BlockPlaceData data, 
51
                         final BlockPlaceConfig cc, final IPlayerData pData) {
52
53
        data.fastPlaceBuckets.add(System.currentTimeMillis(), 1f);
54
        final boolean lag = pData.getCurrentWorldData().shouldAdjustToLag(type);
55
        // Full period frequency.
56
        final float fullScore = data.fastPlaceBuckets.score(1f);
57
58
        // Short term limit.
59
        if (tick < data.fastPlaceShortTermTick) {
60
            // TickTask got reset.
61
            data.fastPlaceShortTermTick = tick;
62
            data.fastPlaceShortTermCount = 1;
63
        }
64
        else if (tick - data.fastPlaceShortTermTick < cc.fastPlaceShortTermTicks) {
65
            // Account for server side lag.
66
            if (!lag || TickTask.getLag(50L * (tick - data.fastPlaceShortTermTick), true) < 1.2f) {
67
                // Within range, add.
68
                data.fastPlaceShortTermCount ++;
69
            }
70
            else {
71
                // Too much lag, reset.
72
                data.fastPlaceShortTermTick = tick;
73
                data.fastPlaceShortTermCount = 1;
74
            }
75
        }
76
        else { 
77
            data.fastPlaceShortTermTick = tick;
78
            data.fastPlaceShortTermCount = 1;
79
        }
80
81
        // Find out if one of both are violations:
82
        final float fullViolation;
83
        if (fullScore > cc.fastPlaceLimit) {
84
            // Account for server side lag.
85
            fullViolation = lag ? fullScore / TickTask.getLag(data.fastPlaceBuckets.bucketDuration() * data.fastPlaceBuckets.numberOfBuckets(), true) - cc.fastPlaceLimit
86
                                : fullScore - cc.fastPlaceLimit;
87
        }
88
        else fullViolation = 0;
89
        final float shortTermViolation = data.fastPlaceShortTermCount - cc.fastPlaceShortTermLimit; 
90
        final float violation = Math.max(fullViolation, shortTermViolation);
91
        boolean cancel = false;
92
93
        if (violation > 0.0) {
94
            final double change = (double) violation;
95
            data.fastPlaceVL += change;
96
            cancel = executeActions(player, data.fastPlaceVL, change, cc.fastPlaceActions).willCancel();
97
        }
98
        else if (data.fastPlaceVL > 0D && fullScore < cc.fastPlaceLimit * .75) {
99
            data.fastPlaceVL *= 0.95;
100
        }
101
        return cancel;
102
    }
103
}

How it counteracts this module

NoCheatPlus's blockplace FastPlace is invoked from the Bukkit BlockPlaceEvent path, and the module's placements are genuine: playerController.onPlayerRightClick sends a real C08 with a block position and facing, the server places the block, and the event fires. The check scores into BlockPlaceData.fastPlaceBuckets, an ActionFrequency(2, 1000) two-second window, plus a config-driven short-term tick counter, with the violation being the larger of the full-window excess and the short-term excess.

While the module crosses gaps it can place once per tick, up to 20 placements per second, which is roughly five times the vanilla 4-per-second rate, so a sustained crossing scores around five times the vanilla baseline and trips both the window and the short-term path. The honest boundary is the gate: on flat ground with solid blocks below, the module idles and the stream stops, so the check only scores the crossing phases.

anticheat Direction (placement look validation)

Direction.java52 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.blockplace;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.actions.ActionList;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.checks.generic.block.AbstractBlockDirectionCheck;
22
23
/**
24
 * The Direction check will find out if a player tried to interact with
25
 * something that's not in their field of view.
26
 */
27
public class Direction extends AbstractBlockDirectionCheck<BlockPlaceData, BlockPlaceConfig> {
28
29
    /**
30
     * Instantiates a new direction check.
31
     */
32
    public Direction() {
33
        super(CheckType.BLOCKPLACE_DIRECTION);
34
    }
35
36
    @Override
37
    protected double addVL(Player player, double distance, BlockPlaceData data, BlockPlaceConfig cc) {
38
        data.directionVL += distance;
39
        return data.directionVL;
40
    }
41
42
    @Override
43
    protected ActionList getActions(BlockPlaceConfig cc) {
44
        return cc.directionActions;
45
    }
46
47
    @Override
48
    protected void cooldown(Player player, BlockPlaceData data, BlockPlaceConfig cc) {
49
        data.directionVL *= 0.9D;
50
    }
51
52
}

How it counteracts this module

NoCheatPlus's blockplace Direction extends AbstractBlockDirectionCheck and validates the placement look against the interacted block face, requiring the player's look ray to intersect the face they claim and accumulating penalties for mismatches with a 0.9 decay. The module computes the placement look with getRotationsHypixel, an atan2 aim at the block center with the pitch boost clamped to 90, and latches the same values into every C03, so the server-side look ray is aimed at the placed face by construction.

This entry is the honest boundary: the module deliberately aligns look and placement, so Direction passes it, and a scaffold that aimed elsewhere would be exactly what the check punishes. The pitch clamp at 90 keeps the ray vertical, which still intersects the UP face of the under-below block from the player's eye height, so the validation has nothing to reject.

anticheat Reach (placement distance)

Reach.java85 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.blockplace;
16
17
import org.bukkit.GameMode;
18
import org.bukkit.Location;
19
import org.bukkit.block.Block;
20
import org.bukkit.entity.Player;
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.utilities.StringUtil;
27
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
28
29
/**
30
 * The Reach check will find out if a player places a block too far away.
31
 */
32
public class Reach extends Check {
33
34
    /** The maximum distance allowed to interact with a block in creative mode. */
35
    public static final double CREATIVE_DISTANCE = 5.6D;
36
37
    /** The maximum distance allowed to interact with a block in survival mode. */
38
    public static final double SURVIVAL_DISTANCE = 5.2D;
39
40
    /** For temporary use: LocUtil.clone before passing deeply, call setWorld(null) after use. */
41
    private final Location useLoc = new Location(null, 0, 0, 0);
42
43
    /**
44
     * Instantiates a new reach check.
45
     */
46
    public Reach() {
47
        super(CheckType.BLOCKPLACE_REACH);
48
    }
49
50
    /**
51
     * Checks a player.
52
     * 
53
     * @param player
54
     *            the player
55
     * @param eyeHeight 
56
     * @param block 
57
     * @param data
58
     * @param cc
59
     * @return true, if successful
60
     */
61
    public boolean check(final Player player, final double eyeHeight, final Block block, final BlockPlaceData data, final BlockPlaceConfig cc) {
62
    	// TODO: Ray tracing-based?
63
        boolean cancel = false;
64
        final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE;
65
        // Distance is calculated from eye location to center of targeted block.
66
        final Location eyeLoc = player.getLocation(useLoc);
67
        eyeLoc.setY(eyeLoc.getY() + eyeHeight);
68
        final double distance = TrigUtil.distance(eyeLoc, block) - distanceLimit;
69
70
        if (distance > distanceLimit) {
71
            // They failed, increment violation level.
72
            data.reachVL += distance - distanceLimit;
73
            // Execute whatever actions are associated with this check and the violation level and find out if we should
74
            // cancel the event.
75
            final ViolationData vd = new ViolationData(this, player, data.reachVL, distance, cc.reachActions);
76
            vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(distance));
77
            cancel = executeActions(vd).willCancel();
78
        } 
79
        // Player passed the check, reward them
80
        else data.reachVL *= 0.9D;
81
        // Cleanup.
82
        useLoc.setWorld(null);
83
        return cancel;
84
    }
85
}

How it counteracts this module

NoCheatPlus's blockplace Reach measures the eye-to-block distance against the survival distance default of 5.2 blocks (5.6 creative) in this tree, cancelling placements beyond the limit and reducing repeat hits inside the reachMod band. The module places at the cell two below the feet, so the eye at roughly posY plus 1.62 to a block center at posY minus 1.5 sits around 3.6 blocks away, comfortably inside the survival bound.

The entry is a boundary in the same family as Direction: the module never extends reach because it only ever targets the cell under the player, and the under-foot geometry keeps every placement legal. A variant that reached several cells out for tower building would be the shape this check exists to cancel, and the module's own geometry avoids it by design.

anticheat BlockInteractSpeed (same-tick interaction)

BlockInteractSpeed.java55 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.interaction.terrain;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.BlockInteractionCheck;
23
import me.islandscout.hawk.event.InteractWorldEvent;
24
import org.bukkit.entity.Player;
25
26
import java.util.HashMap;
27
import java.util.Map;
28
import java.util.UUID;
29
30
public class BlockInteractSpeed extends BlockInteractionCheck {
31
32
    private final Map<UUID, Long> lastPlaceTick;
33
34
    public BlockInteractSpeed() {
35
        super("blockplacespeed", "%player% failed block place speed. VL: %vl%");
36
        lastPlaceTick = new HashMap<>();
37
    }
38
39
    @Override
40
    protected void check(InteractWorldEvent e) {
41
        Player p = e.getPlayer();
42
        HawkPlayer pp = e.getHawkPlayer();
43
        if (pp.getCurrentTick() == lastPlaceTick.getOrDefault(p.getUniqueId(), 0L))
44
            punishAndTryCancelAndBlockRespawn(pp, 1, e);
45
        else
46
            reward(pp);
47
48
        lastPlaceTick.put(p.getUniqueId(), pp.getCurrentTick());
49
    }
50
51
    @Override
52
    public void removeData(Player p) {
53
        lastPlaceTick.remove(p.getUniqueId());
54
    }
55
}

How it counteracts this module

Hawk's BlockInteractSpeed punishes with vl 1 and cancel whenever a world interaction arrives on the same server tick as the previous one, keeping a per-player lastPlaceTick map and rewarding every interaction that lands on a later tick. The module caps at one C08 per tick because every placement branch returns immediately, so each interaction lands on a fresh tick and the check rewards the stream instead of punishing it.

This is the same-tick boundary that separates a per-tick placement module from a burst placement module: a stream of one placement per tick is exactly what BlockInteractSpeed does not flag, while two interactions in one tick (the shape a double-placement or a placement plus a use produces) trips it instantly. The honest statement is that this check is structurally blind to the module's cadence, and the real pressure comes from the FastPlace window ledger.

← Back to Analysis Hub