Sigma 4.11 AutoPot module 2 files, 393 lines

Sigma 4.11 AutoPot: Full Source Analysis

Sigma 4.11's AutoPot is a three-effect potion bot - heal, regen and speed - with a spoof-slot design: getBestSpoofSlot picks an empty hotbar slot (or the first potion slot) as the routing target…

info/sigmaclient/module/impl/combat/AutoPot.java · GitHub source ↗

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

Analysis

Overview

Sigma 4.11's AutoPot is a three-effect potion bot - heal, regen and speed - with a spoof-slot design: getBestSpoofSlot picks an empty hotbar slot (or the first potion slot) as the routing target, and getBestPot swaps the best available splash of the wanted effect into that slot with a mode-2 window click before the throw. The throw itself is a four-packet burst in one pre-update tick: C09 to the spoof slot, C05 look at the throw rotation (pitch 90, or a PREDICT-computed aim at the player's position extrapolated 26 ticks ahead and 3.6 blocks down), C08 with the current stack, and C09 back to the old slot. A public static potting flag and a 200ms timer let other modules react, while the actual re-arms are gated at 900ms for heal/regen and 1000ms for speed, each requiring the effect to be inactive and (for heal) health below twice the HEALTH setting (default 6). The window click is the differentiator: the swap emits C0E traffic on the player container, optionally with the inventory screen open (GuiInventory is explicitly allowed), which the hotbar-only throwers avoid.

Spoof-slot routing and swap

getBestSpoofSlot returns the first hotbar slot whose container slot 36-44 is empty, or the first slot already holding a potion - the throw target that minimises visible disruption. getBestPot scans container slots 9-44 for a splash potion of the wanted effect, ranks candidates with isBestPot (rejecting any potion of the same effect with a higher amplifier, or an equal amplifier with a longer duration), and if the winner is not already in the spoof slot performs swap(i, hotbarSlot): windowClick(windowId, i, hotbarSlot, 2) - mode 2 SWAP, which exchanges the inventory slot with the named hotbar slot and emits a C0E. The scan permits mc.currentScreen == null or a GuiInventory, so the swap can legitimately occur while the player is looking at the inventory screen, and the windowId comes from inventoryContainer, keeping the click on the player window. After the swap the module sends the throw burst and resets the timer; the 200ms timer clears the public potting flag so a sprint or scaffold module can resume quickly.

Throw burst and rotation modes

The burst is queued in one pre-update tick: C09(hotbarSlot), C05PacketPlayerLook(rotations[0], rotations[1], onGround), C08(inventory.getCurrentItem()), C09(oldSlot). The C05 is what distinguishes Sigma from the others - the throw pitch is claimed on the wire before the use, so the server throws the splash at the claimed rotation. getRotations returns either {currentYaw, 90} or, with PREDICT on, the yaw to a point at posX + motionX * 26, boundingBox.minY - 3.6, posZ + motionZ * 26 - a lead-aim 26 ticks ahead and 3.6 blocks below the feet, so the potion lands under the predicted position. The C08 is the face-255 use form carrying the potion stack from the current slot, which the C09 just switched to. The three settings (SPEED, REGEN, HEALTH) build a pots[] priority list [heal, regen, speed]; heal and regen share the 900ms gate and the health check (health < HEALTH * 2), speed uses the 1000ms gate and no health requirement, and both require the effect to be inactive.

Effect ranking and gate cadence

isBestPot normalizes the comparison surface: it rejects potions with null or multi-effect lists, then walks the entire container comparing every splash of the same effect ID by amplifier first and duration second - a genuine best-of-inventory selection, unlike the Memeware/Nekoware ranker bug in the sibling analyses. The gates are timer-based: heal/regen re-arm at 900ms, speed at 1000ms, each only when the effect is not active, so buff refresh is demand-driven rather than periodic. The effect list is fixed by the settings - heal (ID 6) is always armed, regen (10) and speed (1) are toggles - and the module never drinks, only throws splash. The combination of a wire-claimed rotation and a window-click swap makes Sigma's AutoPot the most packet-visible of the three autopot modules: C0E, C09, C05 and C08 per cycle.

source AutoPot.java (module)

AutoPot.java196 lines · JavaOriginal ↗
1
package info.sigmaclient.module.impl.combat;
2
3
import java.util.ArrayList;
4
5
import net.minecraft.client.gui.GuiChat;
6
import net.minecraft.client.gui.inventory.GuiFurnace;
7
import net.minecraft.client.gui.inventory.GuiInventory;
8
import net.minecraft.enchantment.Enchantment;
9
import net.minecraft.enchantment.EnchantmentHelper;
10
import net.minecraft.item.Item;
11
import net.minecraft.item.ItemAppleGold;
12
import net.minecraft.item.ItemArmor;
13
import net.minecraft.item.ItemAxe;
14
import net.minecraft.item.ItemBlock;
15
import net.minecraft.item.ItemBow;
16
import net.minecraft.item.ItemFood;
17
import net.minecraft.item.ItemGlassBottle;
18
import net.minecraft.item.ItemPickaxe;
19
import net.minecraft.item.ItemPotion;
20
import net.minecraft.item.ItemStack;
21
import net.minecraft.item.ItemSword;
22
import net.minecraft.item.ItemTool;
23
import net.minecraft.network.Packet;
24
import net.minecraft.network.play.client.C03PacketPlayer;
25
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
26
import net.minecraft.network.play.client.C09PacketHeldItemChange;
27
import net.minecraft.network.play.client.C0EPacketClickWindow;
28
import net.minecraft.network.play.server.S1CPacketEntityMetadata;
29
import net.minecraft.potion.Potion;
30
import net.minecraft.potion.PotionEffect;
31
import net.minecraft.potion.PotionHelper;
32
import net.minecraft.util.MathHelper;
33
import info.sigmaclient.event.Event;
34
import info.sigmaclient.event.RegisterEvent;
35
import info.sigmaclient.event.impl.EventPacket;
36
import info.sigmaclient.event.impl.EventUpdate;
37
import info.sigmaclient.management.MoveUtils;
38
import info.sigmaclient.module.Module;
39
import info.sigmaclient.module.data.ModuleData;
40
import info.sigmaclient.module.data.Setting;
41
import info.sigmaclient.module.impl.player.Scaffold;
42
import info.sigmaclient.util.RotationUtils;
43
import info.sigmaclient.util.misc.ChatUtil;
44
import info.sigmaclient.util.misc.Timer;
45
46
/*
47
 * Made by LeakedPvP
48
 */
49
public class AutoPot extends Module {
50
51
	public static final String SPEED = "SPEED";
52
	public static final String REGEN = "REGEN";
53
	public static final String HEALTH = "HEALTH";
54
	public static final String PREDICT = "PREDICT";
55
    public AutoPot(ModuleData data) {   	   
56
        super(data);
57
        settings.put(SPEED, new Setting<>(SPEED, true, "Uses Speed pots."));
58
        settings.put(REGEN, new Setting<>(REGEN, true, "Uses Regen pots."));
59
        settings.put(HEALTH, new Setting<>(HEALTH, 6, "Maximum health before healing.", 0.5, 0.5, 10));
60
        settings.put(PREDICT, new Setting<>(PREDICT, false, "Predicts where to pot when moving."));
61
        
62
    }
63
64
    public static boolean potting;
65
    Timer timer = new Timer();
66
    @Override
67
    public void onEnable() {
68
        super.onEnable();
69
    }
70
    public static boolean isPotting(){
71
    	return potting;
72
    }
73
    @Override
74
    @RegisterEvent(events = {EventUpdate.class})
75
    public void onEvent(Event event) {
76
    	if(event instanceof EventUpdate){
77
            EventUpdate em =(EventUpdate)event;
78
            final boolean speed = (Boolean) settings.get(SPEED).getValue();
79
            final boolean regen = (Boolean) settings.get(REGEN).getValue();
80
            if(!em.isPre())
81
            	return;
82
            if(timer.check(200)){
83
            	if(potting)
84
            		potting = false;
85
            }
86
            int spoofSlot = getBestSpoofSlot();
87
            int pots[] = {6,-1,-1};
88
            if(regen)
89
            	pots[1] = 10;
90
            if(speed)
91
            	pots[2] = 1;
92
            
93
            for(int i = 0; i < pots.length; i ++){
94
            	if(pots[i] == -1)
95
            		continue;
96
            	if(pots[i] == 6 || pots[i] == 10){
97
            		if(timer.check(900) && !mc.thePlayer.isPotionActive(pots[i])){
98
                		if(mc.thePlayer.getHealth() < ((Number)settings.get(HEALTH).getValue()).doubleValue()*2){
99
                			getBestPot(spoofSlot, pots[i]);
100
                		}
101
            		}
102
            	}else
103
            	if(timer.check(1000) && !mc.thePlayer.isPotionActive(pots[i])){
104
            		getBestPot(spoofSlot, pots[i]);               		
105
            	}
106
            }       
107
    	}
108
    }
109
  
110
    public void swap(int slot1, int hotbarSlot){
111
    	mc.playerController.windowClick(mc.thePlayer.inventoryContainer.windowId, slot1, hotbarSlot, 2, mc.thePlayer);
112
    }
113
    float[] getRotations(){    	
114
        double movedPosX = mc.thePlayer.posX + mc.thePlayer.motionX * 26.0D;
115
        double movedPosY = mc.thePlayer.boundingBox.minY - 3.6D;
116
        double movedPosZ = mc.thePlayer.posZ + mc.thePlayer.motionZ * 26.0D;	
117
        if((Boolean) settings.get(PREDICT).getValue())
118
        	return RotationUtils.getRotationFromPosition(movedPosX, movedPosZ, movedPosY);
119
        else
120
        	return new float[]{mc.thePlayer.rotationYaw, 90};
121
    }
122
    int getBestSpoofSlot(){  	
123
    	int spoofSlot = 5;
124
    	for (int i = 36; i < 45; i++) {       		
125
    		if (!mc.thePlayer.inventoryContainer.getSlot(i).getHasStack()) {
126
     			spoofSlot = i - 36;
127
     			break;
128
            }else if(mc.thePlayer.inventoryContainer.getSlot(i).getStack().getItem() instanceof ItemPotion) {
129
            	spoofSlot = i - 36;
130
     			break;
131
            }
132
        }
133
    	return spoofSlot;
134
    }
135
    void getBestPot(int hotbarSlot, int potID){
136
    	for (int i = 9; i < 45; i++) {
137
            if (mc.thePlayer.inventoryContainer.getSlot(i).getHasStack() &&(mc.currentScreen == null || mc.currentScreen instanceof GuiInventory)) {
138
                ItemStack is = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
139
                if(is.getItem() instanceof ItemPotion){
140
              	  ItemPotion pot = (ItemPotion)is.getItem();
141
              	  if(pot.getEffects(is).isEmpty())
142
              		  return;
143
              	  PotionEffect effect = (PotionEffect) pot.getEffects(is).get(0);              	  
144
                  int potionID = effect.getPotionID();
145
                  if(potionID == potID)
146
              	  if(ItemPotion.isSplash(is.getItemDamage()) && isBestPot(pot, is)){
147
              		  if(36 + hotbarSlot != i)
148
              			  swap(i, hotbarSlot);
149
              		  timer.reset();
150
              		  boolean canpot = true;
151
              		  int oldSlot = mc.thePlayer.inventory.currentItem;
152
              		  mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(hotbarSlot));
153
          			  mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(getRotations()[0], getRotations()[1], mc.thePlayer.onGround));
154
          			  mc.thePlayer.sendQueue.addToSendQueue(new C08PacketPlayerBlockPlacement(mc.thePlayer.inventory.getCurrentItem()));
155
          			  mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(oldSlot));
156
          			  potting = true;
157
          			  break;
158
              	  }               	  
159
                }              
160
            }
161
        }
162
    }
163
    
164
    boolean isBestPot(ItemPotion potion, ItemStack stack){
165
    	if(potion.getEffects(stack) == null || potion.getEffects(stack).size() != 1)
166
    		return false;
167
        PotionEffect effect = (PotionEffect) potion.getEffects(stack).get(0);
168
        int potionID = effect.getPotionID();
169
        int amplifier = effect.getAmplifier(); 
170
        int duration = effect.getDuration();
171
    	for (int i = 9; i < 45; i++) {    		
172
            if (mc.thePlayer.inventoryContainer.getSlot(i).getHasStack()) {           	
173
                ItemStack is = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
174
                if(is.getItem() instanceof ItemPotion){
175
                	ItemPotion pot = (ItemPotion)is.getItem();
176
                	 if (pot.getEffects(is) != null) {
177
                         for (Object o : pot.getEffects(is)) {
178
                             PotionEffect effects = (PotionEffect) o;
179
                             int id = effects.getPotionID();
180
                             int ampl = effects.getAmplifier(); 
181
                             int dur = effects.getDuration();
182
                             if (id == potionID && ItemPotion.isSplash(is.getItemDamage())){
183
                            	 if(ampl > amplifier){
184
                            		 return false;
185
                            	 }else if (ampl == amplifier && dur > duration){
186
                            		 return false;
187
                            	 }
188
                             }                            
189
                         }
190
                     }
191
                }
192
            }
193
        }
194
    	return true;
195
    }
196
}

What this file does

The settings are declared in the constructor (lines 55-61): SPEED, REGEN toggles, HEALTH default 6 (compared as health < value * 2), PREDICT off. onEvent (lines 75-108) handles EventUpdate pre-only, clears the potting flag on the 200ms timer, builds the pots[] list, and dispatches getBestPot per enabled effect with the 900/1000ms gates. swap (lines 110-112) is the mode-2 C0E hotbar swap. getRotations (lines 113-121) implements the 90-degree throw or the 26-tick PREDICT lead-aim. getBestSpoofSlot (lines 122-134) picks the routing slot. getBestPot (lines 135-162) selects the best splash, swaps it in, then queues the C09-C05-C08-C09 burst and sets potting. isBestPot (lines 164-195) ranks candidates by amplifier then duration.

source RotationUtils.java (throw aim)

RotationUtils.java197 lines · JavaOriginal ↗
1
package info.sigmaclient.util;
2
3
import info.sigmaclient.util.misc.ChatUtil;
4
5
import java.util.List;
6
import java.util.Objects;
7
8
import net.minecraft.client.Minecraft;
9
import net.minecraft.entity.Entity;
10
import net.minecraft.entity.EntityLivingBase;
11
import net.minecraft.entity.player.EntityPlayer;
12
import net.minecraft.util.AxisAlignedBB;
13
import net.minecraft.util.MathHelper;
14
import net.minecraft.util.Vec3;
15
16
public class RotationUtils {
17
	static Minecraft mc = Minecraft.getMinecraft();
18
    public static float[] getRotations(EntityLivingBase ent) {
19
        double x = ent.posX;
20
        double z = ent.posZ;
21
        double y = ent.posY + ent.getEyeHeight() / 2.0F;
22
        return getRotationFromPosition(x, z, y);
23
    }
24
    public static float[] getPredictedRotations(EntityLivingBase ent) {
25
        double x = ent.posX + (ent.posX - ent.lastTickPosX);
26
        double z = ent.posZ + (ent.posZ - ent.lastTickPosZ);
27
        double y = ent.posY + ent.getEyeHeight() / 2.0F;
28
        return getRotationFromPosition(x, z, y);
29
    }
30
    public static float[] getAverageRotations(List<EntityLivingBase> targetList) {
31
        double posX = 0.0D;
32
        double posY = 0.0D;
33
        double posZ = 0.0D;
34
        for (Entity ent : targetList) {
35
            posX += ent.posX;
36
            posY += ent.boundingBox.maxY - 2.0D;
37
            posZ += ent.posZ;
38
        }
39
        posX /= targetList.size();
40
        posY /= targetList.size();
41
        posZ /= targetList.size();
42
43
        return new float[]{getRotationFromPosition(posX, posZ, posY)[0], getRotationFromPosition(posX, posZ, posY)[1]};
44
    }
45
    public static float getStraitYaw(){
46
    	float YAW = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw);
47
    	if(YAW < 45 && YAW > -45){
48
			YAW = 0;
49
		}else if(YAW > 45 && YAW < 135){
50
			YAW = 90f;
51
		}else if(YAW > 135 || YAW < -135){
52
			YAW = 180;
53
		}else{
54
			YAW = -90f;
55
		}	 
56
    	return YAW;
57
    }
58
    public static float[] getBowAngles(final Entity entity) {
59
        final double xDelta = (entity.posX - entity.lastTickPosX) * 0.4;
60
        final double zDelta = (entity.posZ - entity.lastTickPosZ) * 0.4;
61
        double d = Minecraft.getMinecraft().thePlayer.getDistanceToEntity(entity);
62
        d -= d % 0.8;
63
        double xMulti = 1.0;
64
        double zMulti = 1.0;
65
        final boolean sprint = entity.isSprinting();
66
        xMulti = d / 0.8 * xDelta * (sprint ? 1.25 : 1.0);
67
        zMulti = d / 0.8 * zDelta * (sprint ? 1.25 : 1.0);
68
        final double x = entity.posX + xMulti - Minecraft.getMinecraft().thePlayer.posX;
69
        final double z = entity.posZ + zMulti - Minecraft.getMinecraft().thePlayer.posZ;
70
        final double y = Minecraft.getMinecraft().thePlayer.posY + Minecraft.getMinecraft().thePlayer.getEyeHeight() - (entity.posY + entity.getEyeHeight());
71
        final double dist = Minecraft.getMinecraft().thePlayer.getDistanceToEntity(entity);
72
        final float yaw = (float) Math.toDegrees(Math.atan2(z, x)) - 90.0f;
73
		double d1 = MathHelper.sqrt_double(x * x + z * z);
74
        final float pitch =  (float) - (Math.atan2(y, d1) * 180.0D / Math.PI) + (float)dist*0.11f;
75
        
76
        return new float[]{yaw, -pitch};
77
    }
78
79
    public static float[] getRotationFromPosition(double x, double z, double y) {
80
        double xDiff = x - Minecraft.getMinecraft().thePlayer.posX;
81
        double zDiff = z - Minecraft.getMinecraft().thePlayer.posZ;
82
        double yDiff = y - Minecraft.getMinecraft().thePlayer.posY - 1.2;
83
84
        double dist = MathHelper.sqrt_double(xDiff * xDiff + zDiff * zDiff);
85
        float yaw = (float) (Math.atan2(zDiff, xDiff) * 180.0D / 3.141592653589793D) - 90.0F;
86
        float pitch = (float) -(Math.atan2(yDiff, dist) * 180.0D / 3.141592653589793D);
87
        return new float[]{yaw, pitch};
88
    }
89
90
    public static float getTrajAngleSolutionLow(float d3, float d1, float velocity) {
91
        float g = 0.006F;
92
        float sqrt = velocity * velocity * velocity * velocity - g * (g * (d3 * d3) + 2.0F * d1 * (velocity * velocity));
93
        return (float) Math.toDegrees(Math.atan((velocity * velocity - Math.sqrt(sqrt)) / (g * d3)));
94
    }
95
96
    public static float getYawChange(float yaw, double posX, double posZ) {
97
        double deltaX = posX - Minecraft.getMinecraft().thePlayer.posX;
98
        double deltaZ = posZ - Minecraft.getMinecraft().thePlayer.posZ;
99
        double yawToEntity = 0;
100
        if ((deltaZ < 0.0D) && (deltaX < 0.0D)) {
101
        	if(deltaX != 0)
102
            yawToEntity = 90.0D + Math.toDegrees(Math.atan(deltaZ / deltaX));
103
        } else if ((deltaZ < 0.0D) && (deltaX > 0.0D)) {
104
        	if(deltaX != 0)
105
            yawToEntity = -90.0D + Math.toDegrees(Math.atan(deltaZ / deltaX));
106
        } else {
107
        	if(deltaZ != 0)
108
            yawToEntity = Math.toDegrees(-Math.atan(deltaX / deltaZ));
109
        }
110
111
        return MathHelper.wrapAngleTo180_float(-(yaw- (float) yawToEntity));
112
    }
113
114
    public static float getPitchChange(float pitch, Entity entity, double posY) {
115
        double deltaX = entity.posX - Minecraft.getMinecraft().thePlayer.posX;
116
        double deltaZ = entity.posZ - Minecraft.getMinecraft().thePlayer.posZ;
117
        double deltaY = posY - 2.2D + entity.getEyeHeight() - Minecraft.getMinecraft().thePlayer.posY;
118
        double distanceXZ = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
119
        double pitchToEntity = -Math.toDegrees(Math.atan(deltaY / distanceXZ));
120
        return -MathHelper.wrapAngleTo180_float(pitch - (float) pitchToEntity) - 2.5F;
121
    }
122
123
124
    public static float getNewAngle(float angle) {
125
        angle %= 360.0F;
126
        if (angle >= 180.0F) {
127
            angle -= 360.0F;
128
        }
129
        if (angle < -180.0F) {
130
            angle += 360.0F;
131
        }
132
        return angle;
133
    }
134
135
    public static boolean canEntityBeSeen(Entity e){
136
    	Vec3 vec1 = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + mc.thePlayer.getEyeHeight(),mc.thePlayer.posZ);
137
138
    	AxisAlignedBB box = e.getEntityBoundingBox();
139
        Vec3 vec2 = new Vec3(e.posX, e.posY + (e.getEyeHeight()/1.32F),e.posZ);	
140
        double minx = e.posX - 0.25;
141
        double maxx = e.posX + 0.25;
142
        double miny = e.posY;
143
        double maxy = e.posY + Math.abs(e.posY - box.maxY) ;
144
        double minz = e.posZ - 0.25;
145
        double maxz = e.posZ + 0.25;
146
        boolean see =  mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
147
	    if(see)
148
	    	return true;
149
	    vec2 = new Vec3(maxx,miny,minz);	
150
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
151
	    if(see)
152
	    	return true;
153
	    vec2 = new Vec3(minx,miny,minz);	
154
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
155
	  
156
	    if(see)
157
	    	return true;
158
	    vec2 = new Vec3(minx,miny,maxz);	
159
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
160
	    if(see)
161
	    	return true;
162
	    vec2 = new Vec3(maxx,miny,maxz);	
163
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
164
	    if(see)
165
	    	return true;
166
	    
167
	    vec2 = new Vec3(maxx, maxy,minz);	
168
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
169
	  
170
	    if(see)
171
	    	return true;
172
	    vec2 = new Vec3(minx, maxy,minz);	
173
	
174
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
175
	    if(see)
176
	    	return true;
177
	    vec2 = new Vec3(minx, maxy,maxz - 0.1);	
178
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
179
	    if(see)
180
	    	return true;
181
	    vec2 = new Vec3(maxx, maxy,maxz);	
182
	    see = mc.theWorld.rayTraceBlocks(vec1, vec2) == null? true:false;
183
	    if(see)
184
	    	return true;
185
	    
186
	
187
    	return false;
188
    }
189
    public static float getDistanceBetweenAngles(float angle1, float angle2) {
190
        float angle = Math.abs(angle1 - angle2) % 360.0F;
191
        if (angle > 180.0F) {
192
            angle = 360.0F - angle;
193
        }
194
        return angle;
195
    }
196
}

What this file does

The module consumes exactly one method from this utility: getRotationFromPosition(x, z, y), the atan2/MathHelper math that converts a target point into yaw and pitch. The PREDICT mode feeds it the extrapolated position (pos + motion * 26, minY - 3.6), and the pitch that comes back is what the C05 look packet claims before the C08 throw. The same utility backs Sigma's Killaura and Scaffold aim paths, so the throw rotation is computed with the client's standard aim machinery rather than a hardcoded angle - only the non-PREDICT fallback hardcodes pitch 90.

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 FastConsume (consume-time ledger)

FastConsume.java117 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 org.bukkit.Material;
18
import org.bukkit.entity.Player;
19
import org.bukkit.inventory.ItemStack;
20
21
import fr.neatmonster.nocheatplus.actions.ParameterName;
22
import fr.neatmonster.nocheatplus.checks.Check;
23
import fr.neatmonster.nocheatplus.checks.CheckType;
24
import fr.neatmonster.nocheatplus.checks.ViolationData;
25
import fr.neatmonster.nocheatplus.players.IPlayerData;
26
import fr.neatmonster.nocheatplus.utilities.entity.InventoryUtil;
27
import fr.neatmonster.nocheatplus.utilities.TickTask;
28
29
/**
30
 * Replaces the former InstantEat check (pre 1.5). Will be disabled from 1.8 and higher versions.<br>
31
 * @author asofold
32
 *
33
 */
34
public class FastConsume extends Check {
35
36
    public FastConsume() {
37
        super(CheckType.INVENTORY_FASTCONSUME);
38
    }
39
    
40
    /**
41
     * Checks a player
42
     * 
43
     * @param player
44
     * @param stack
45
     * @param time
46
     * @param data
47
     * @param pData
48
     * @return True, if to cancel the event. In that case, the inventory will be updated as well.
49
     */
50
    public boolean check(final Player player, final ItemStack stack, final long time, final InventoryData data, final IPlayerData pData) {
51
        // Consistency checks...
52
        if (stack == null) { // || stack.getType() != data.fastConsumeFood){
53
            // TODO: Strict version should prevent other material (?).
54
            return false;
55
        }
56
        final long ref = data.fastConsumeInteract == 0 ? 0 : Math.max(data.fastConsumeInteract, data.lastClickTime);
57
        if (time < ref) {
58
            // Time ran backwards.
59
            data.fastConsumeInteract = data.lastClickTime = time;
60
            return false;
61
        }
62
        // Check exceptions.
63
        final InventoryConfig cc = pData.getGenericInstance(InventoryConfig.class);
64
        final Material mat = stack == null ? null : stack.getType();
65
        if (mat != null) {
66
            if (cc.fastConsumeWhitelist) {
67
                if (!cc.fastConsumeItems.contains(mat)) {
68
                    return false;
69
                }
70
            }
71
            else if (cc.fastConsumeItems.contains(mat)) {
72
                return false;
73
            }
74
        }
75
        // Actually check.
76
        final long timeSpent = ref == 0 ? 0 : (time - ref); // Not interact = instant.
77
        final long expectedDuration = cc.fastConsumeDuration;
78
        boolean cancel = false;
79
        if (timeSpent < expectedDuration) {
80
            // TODO: Might have to do a specialized check for lag spikes here instead.
81
            final float lag = TickTask.getLag(expectedDuration, true);
82
            if (timeSpent * lag < expectedDuration) {
83
                final double difference = (expectedDuration - timeSpent * lag) / 100.0;
84
                data.fastConsumeVL += difference;
85
                final ViolationData vd = new ViolationData(this, player, data.fastConsumeVL, difference, cc.fastConsumeActions);
86
                vd.setParameter(ParameterName.FOOD, "" + mat);
87
                if (data.fastConsumeFood != mat) {
88
                    vd.setParameter(ParameterName.TAGS, "inconsistent(" + data.fastConsumeFood + ")");
89
                }
90
                else {
91
                    vd.setParameter(ParameterName.TAGS, "");
92
                }
93
                if (executeActions(vd).willCancel()){
94
                    cancel = true;
95
                }
96
            }
97
        }
98
        else {
99
            data.fastConsumeVL *= 0.6; 
100
        }
101
        // Reset interaction.
102
        if (cancel) {
103
            // Fake interaction to prevent violation loops with false positives.
104
            final ItemStack actualStack = InventoryUtil.getFirstConsumableItemInHand(player);
105
            data.fastConsumeFood = actualStack == null ? null : actualStack.getType();
106
            // TODO: Allows some abuse: 1. try instantly eat (cancelled) 2. consume item directly when needed.
107
        }
108
        else  {
109
            if (pData.isDebugActive(type)) {
110
                debug(player, "PlayerItemConsumeEvent, reset fastconsume: " + data.fastConsumeFood);
111
            }
112
            data.fastConsumeFood = null;
113
        }
114
        data.fastConsumeInteract = time;
115
        return cancel;
116
    }
117
}

How it counteracts this module

NCP's FastConsume times the gap between starting and finishing a consumable. The interaction side is fed by InventoryListener.onPlayerInteract (consumables stamp fastConsumeInteract and fastConsumeFood) and the completion side by PlayerItemConsumeEvent; the check compares the elapsed time against fastConsumeDuration with lag division and a VL that decays by 0.6 on clean completions. Against Sigma's module the ledger sees only the start half: each throw fires a right-click with the potion in hand, stamping the interaction time, but a splash throw never emits PlayerItemConsumeEvent, so the completion branch (and its cancel path via getFirstConsumableItemInHand) never runs - NCP cannot time what never completes. The C09 half is where the ledger does engage: InventoryListener.onItemHeldChange (MONITOR priority) resets fastConsumeInteract to now and clears fastConsumeFood on every slot change, and the module's C09-to-pot and C09-back sandwich the throw, so each ceremony re-stamps the interaction baseline twice. The result is that NCP's consume machinery churns on every throw without ever flagging - the honest reading is that this check is structured for drinking/eating clients and the module's splash-only design steps around its only timing hook.

anticheat ItemSwitchSpeed (C09 after item use)

ItemSwitchSpeed.java80 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
package me.islandscout.hawk.check.interaction.item;
19
20
import me.islandscout.hawk.HawkPlayer;
21
import me.islandscout.hawk.check.Cancelless;
22
import me.islandscout.hawk.check.CustomCheck;
23
import me.islandscout.hawk.event.Event;
24
import me.islandscout.hawk.event.InteractItemEvent;
25
import me.islandscout.hawk.event.InteractWorldEvent;
26
import me.islandscout.hawk.event.ItemSwitchEvent;
27
import org.bukkit.entity.Player;
28
29
import java.util.*;
30
31
public class ItemSwitchSpeed extends CustomCheck implements Cancelless {
32
33
    private Map<UUID, Long> lastSwitchTicks;
34
    private Set<UUID> usedSomething;
35
    private int MIN_SWITCH_TICKS;
36
37
    //might rename this to "AutoUse"
38
    public ItemSwitchSpeed() {
39
        super("itemswitchspeed", true, -1, 1, 0.999, 5000, "%player% failed item switch speed, VL: %vl%", null);
40
        lastSwitchTicks = new HashMap<>();
41
        usedSomething = new HashSet<>();
42
        MIN_SWITCH_TICKS = (int)customSetting("minSwitchTicks", "", 1);
43
    }
44
45
    //For future reference, if you try to verify that the item-switch packet points to a different slot, beware of falses.
46
    //The client can send item-switch packets regardless if the slot switched or not.
47
48
    @Override
49
    protected void check(Event event) {
50
        if(event instanceof InteractItemEvent || event instanceof InteractWorldEvent) {
51
            usedSomething.add(event.getPlayer().getUniqueId());
52
        }
53
        else if(event instanceof ItemSwitchEvent) {
54
55
            HawkPlayer pp = event.getHawkPlayer();
56
            UUID uuid = pp.getUuid();
57
58
            if(usedSomething.contains(uuid)) {
59
                long lastSwitchTick = lastSwitchTicks.getOrDefault(uuid, 0L);
60
                if(pp.getCurrentTick() - lastSwitchTick < MIN_SWITCH_TICKS) {
61
                    punish(pp, 1, false, event);
62
                }
63
                else {
64
                    reward(pp);
65
                }
66
67
                usedSomething.remove(uuid);
68
            }
69
70
            lastSwitchTicks.put(pp.getUuid(), pp.getCurrentTick());
71
        }
72
    }
73
74
    @Override
75
    public void removeData(Player p) {
76
        UUID uuid = p.getUniqueId();
77
        lastSwitchTicks.remove(uuid);
78
        usedSomething.remove(uuid);
79
    }
80
}

How it counteracts this module

Hawk's ItemSwitchSpeed is the direct counter to Sigma's burst. The check feeds on the event pairing: an InteractItemEvent (the C08 use) adds the player to usedSomething, and the next ItemSwitchEvent - the switch-back C09 - is measured against the last switch tick with MIN_SWITCH_TICKS default 1. Sigma queues C09(pot slot), C05, C08, C09(oldSlot) inside one pre-update tick, so both C09s and the use arrive in a single processed batch: the switch-back's ItemSwitchEvent follows the use's InteractItemEvent within the same tick, a delta of zero against a window of one. Every throw violates, and the 900/1000ms re-arm gates mean sustained low-health or expired-buff play produces a steady violation stream with no human-like jitter to smooth it. The PREDICT and rotation settings change the C05's payload, not the ordering, so no configuration of the module alters the verdict - the only mitigation would be deferring the switch-back by at least one tick, which is exactly the change Rise's ceremony already implements.

anticheat UseItemAdapter (C08 face-255 and slot-change resync)

UseItemAdapter.java438 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.net.protocollib;
16
17
import java.util.Arrays;
18
import java.util.LinkedList;
19
import java.util.List;
20
21
import org.bukkit.GameMode;
22
import org.bukkit.Material;
23
import org.bukkit.entity.HumanEntity;
24
import org.bukkit.entity.Player;
25
import org.bukkit.event.Event;
26
import org.bukkit.event.EventHandler;
27
import org.bukkit.event.EventPriority;
28
import org.bukkit.event.block.Action;
29
import org.bukkit.event.entity.PlayerDeathEvent;
30
import org.bukkit.event.inventory.InventoryOpenEvent;
31
import org.bukkit.event.player.PlayerInteractEvent;
32
import org.bukkit.event.player.PlayerItemConsumeEvent;
33
import org.bukkit.event.player.PlayerItemHeldEvent;
34
import org.bukkit.event.player.PlayerRespawnEvent;
35
import org.bukkit.event.player.PlayerRiptideEvent;
36
import org.bukkit.inventory.EquipmentSlot;
37
import org.bukkit.inventory.ItemStack;
38
import org.bukkit.inventory.meta.CrossbowMeta;
39
import org.bukkit.plugin.Plugin;
40
41
import com.comphenix.protocol.PacketType;
42
import com.comphenix.protocol.events.ListenerPriority;
43
import com.comphenix.protocol.events.PacketContainer;
44
import com.comphenix.protocol.events.PacketEvent;
45
import com.comphenix.protocol.reflect.StructureModifier;
46
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
47
48
import fr.neatmonster.nocheatplus.NCPAPIProvider;
49
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
50
import fr.neatmonster.nocheatplus.checks.moving.MovingConfig;
51
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
52
import fr.neatmonster.nocheatplus.compat.Bridge1_13;
53
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
54
import fr.neatmonster.nocheatplus.compat.bukkit.BridgeEnchant;
55
import fr.neatmonster.nocheatplus.compat.bukkit.BridgeMaterial;
56
import fr.neatmonster.nocheatplus.compat.BridgeMisc;
57
import fr.neatmonster.nocheatplus.compat.versions.ClientVersion;
58
import fr.neatmonster.nocheatplus.compat.versions.ServerVersion;
59
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
60
import fr.neatmonster.nocheatplus.components.registry.order.RegistrationOrder.RegisterMethodWithOrder;
61
import fr.neatmonster.nocheatplus.event.mini.MiniListener;
62
import fr.neatmonster.nocheatplus.logging.StaticLog;
63
import fr.neatmonster.nocheatplus.players.DataManager;
64
import fr.neatmonster.nocheatplus.players.IPlayerData;
65
import fr.neatmonster.nocheatplus.utilities.entity.InventoryUtil;
66
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
67
import fr.neatmonster.nocheatplus.utilities.map.MaterialUtil;
68
69
/**
70
 * <p>Adapter for listening to packets and Bukkit events relevant to item use.</p>
71
 *
72
 * On versions 1.17 and above, the adapter will only register events related to a specific item-use exploit, 
73
 * as Bukkit provides the {@link HumanEntity#getItemInUse()} method.<br>
74
 *
75
 * <p>On versions 1.12 and above, up to 1.17, all listeners will be registered because Bukkit does not offer a way to 
76
 * determine <em>which</em> item is in use; we can only detect if a player is using an item through {@link HumanEntity#isHandRaised()}.</p>
77
 *
78
 * The {@link PlayerRespawnEvent} is always listened to in order to fix a specific item desynchronization issue.
79
 */
80
public class UseItemAdapter extends BaseAdapter {
81
    
82
    private final static String dftag = "system.nocheatplus.useitemadapter";
83
        
84
    // All relevant Bukkit events for item-use.
85
    private final static MiniListener<?>[] miniListeners = new MiniListener<?>[] {
86
        new MiniListener<PlayerItemConsumeEvent>() {
87
            @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
88
            @RegisterMethodWithOrder(tag = dftag)
89
            @Override
90
            public void onEvent(final PlayerItemConsumeEvent event) {
91
                onItemConsume(event);
92
            }
93
        },
94
        new MiniListener<PlayerInteractEvent>() {
95
            @EventHandler(priority = EventPriority.MONITOR)
96
            @RegisterMethodWithOrder(tag = dftag)
97
            @Override
98
            public void onEvent(final PlayerInteractEvent event) {
99
                onItemInteract(event);
100
            }
101
        },
102
        new MiniListener<InventoryOpenEvent>() {
103
            @EventHandler(priority = EventPriority.LOWEST)
104
            @RegisterMethodWithOrder(tag = dftag)
105
            @Override
106
            public void onEvent(final InventoryOpenEvent event) {
107
                onInventoryOpen(event);
108
            }
109
        },
110
        new MiniListener<PlayerDeathEvent>() {
111
            @EventHandler(priority = EventPriority.MONITOR)
112
            @RegisterMethodWithOrder(tag = dftag)
113
            @Override
114
            public void onEvent(final PlayerDeathEvent event) {
115
                onDeath(event);
116
            }
117
        },
118
        new MiniListener<PlayerItemHeldEvent>() {
119
            @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
120
            @RegisterMethodWithOrder(tag = dftag)
121
            @Override
122
            public void onEvent(final PlayerItemHeldEvent event) {
123
                onChangeSlot(event);
124
            }
125
        },
126
    };
127
128
    private static int timeBetweenRL = 70;
129
130
    private static PacketType[] initPacketTypes() {
131
        // Only interested in these two packets.
132
        final List<PacketType> types = new LinkedList<PacketType>(Arrays.asList(PacketType.Play.Client.BLOCK_DIG, PacketType.Play.Client.BLOCK_PLACE));
133
        return types.toArray(new PacketType[types.size()]);
134
    }
135
136
    public UseItemAdapter(Plugin plugin) {
137
        super(plugin, ListenerPriority.MONITOR, initPacketTypes());
138
        final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
139
        if (!BridgeMisc.hasGetItemInUseMethod()) {
140
            // getItemInUse() isn't there, register all events
141
            if (Bridge1_13.hasPlayerRiptideEvent()) {
142
                // Only register this one if available.
143
                final MiniListener<?> riptideListener = new MiniListener<PlayerRiptideEvent>() {
144
                    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
145
                    @RegisterMethodWithOrder(tag = dftag)
146
                    @Override
147
                    public void onEvent(final PlayerRiptideEvent event) {
148
                        onTridentRelease(event);
149
                   }
150
                };
151
                api.addComponent(riptideListener, false);
152
            }
153
            // ...All the other listeners
154
            for (final MiniListener<?> listener : miniListeners) {
155
                api.addComponent(listener, false);
156
            }
157
        }
158
        // Always register this event, because it is used to fix an MC/Bukkit glitch, not for item-use setting.
159
        final MiniListener<?> respawningListener = new MiniListener<PlayerRespawnEvent>() {
160
            @EventHandler(priority = EventPriority.MONITOR)
161
            @RegisterMethodWithOrder(tag = dftag)
162
            @Override
163
            public void onEvent(final PlayerRespawnEvent event) {
164
                onRespawning(event);
165
            }
166
        };
167
        api.addComponent(respawningListener, false);
168
    }
169
170
    @Override
171
    public void onPacketReceiving(final PacketEvent event) {
172
        // Fast return tests first.
173
        try {
174
            if (event.isPlayerTemporary()) return;
175
        } 
176
        catch (NoSuchMethodError e) {
177
            if (event.getPlayer() == null) {
178
                counters.add(ProtocolLibComponent.idNullPlayer, 1);
179
                return;
180
            }
181
            if (DataManager.getPlayerDataSafe(event.getPlayer()) == null) {
182
                StaticLog.logWarning("Failed to fetch player data with " + event.getPacketType() + " for: " + event.getPlayer().toString());
183
                return;
184
            }
185
        }
186
        if (BridgeMisc.hasGetItemInUseMethod()) {
187
            // getItemInUse() is already there. Only check the digging packet for exploitation prevention purposes.
188
            if (event.getPacketType().equals(PacketType.Play.Client.BLOCK_DIG)) {
189
                handleDiggingPacket(event);
190
            }
191
            // Don't need to do anything else.
192
            return;
193
        }
194
        
195
        // getItemInUse() ins't there: do the ordinary stuff.
196
        if (event.getPacketType().equals(PacketType.Play.Client.BLOCK_DIG)) {
197
            handleDiggingPacket(event);
198
        }
199
        else handleBlockPlacePacket(event);
200
    }
201
    
202
    /** Attempt to fix server-side-only blocking after respawn. */
203
    private static void onRespawning(final PlayerRespawnEvent e) {
204
        final IPlayerData pData = DataManager.getPlayerData(e.getPlayer());
205
        // Patch up issues on Bukkit's (Minecraft's ?) side (item has been reset already on death).
206
        if (Bridge1_9.hasGetItemInOffHand() && e.getPlayer().isBlocking()) {
207
            pData.requestItemUseResync();
208
        }
209
    }
210
211
    private static void onTridentRelease(final PlayerRiptideEvent e) {
212
        final IPlayerData pData = DataManager.getPlayerData(e.getPlayer());
213
        // This event is called on releasing the trident (See ItemTrident.java), so the item is not in use anymore.
214
        pData.setItemInUse(null);
215
    }
216
217
    private static void onItemConsume(final PlayerItemConsumeEvent e) {
218
        final Player p = e.getPlayer();
219
        final IPlayerData pData = DataManager.getPlayerData(p);
220
        // Consume(d) (!!), so the player isn't using the item anymore
221
        pData.setItemInUse(null);   
222
    }
223
224
    private static void onInventoryOpen(final InventoryOpenEvent e) {
225
        if (e.isCancelled()) return;
226
        final Player p = (Player) e.getPlayer();
227
        final IPlayerData pData = DataManager.getPlayerData(p);
228
        // Can't use item with an inventory open.
229
        pData.setItemInUse(null);
230
    }
231
232
    private static void onDeath(final PlayerDeathEvent e) {
233
        final IPlayerData pData = DataManager.getPlayerData((Player) e.getEntity());
234
        // Can't use item if dead
235
        pData.setItemInUse(null);  
236
    }
237
238
    @SuppressWarnings("deprecation")
239
	private static void onItemInteract(final PlayerInteractEvent e) {
240
        if (e.getAction() != Action.RIGHT_CLICK_AIR && e.getAction() != Action.RIGHT_CLICK_BLOCK) {
241
            return;
242
        }
243
        final Player p = e.getPlayer();
244
        final IPlayerData pData = DataManager.getPlayerData(p);
245
        final MovingConfig mCC = pData.getGenericInstance(MovingConfig.class);
246
        final CombinedData data = pData.getGenericInstance(CombinedData.class);
247
        data.offHandUse = false;
248
        if (!data.mightUseItem) {
249
            // Player did not send the block-placement packet, so they are for sure not using anything, return.
250
            return;
251
        }
252
        // Do reset the flag at the start (!)
253
        data.mightUseItem = false;
254
255
        if (e.useItemInHand().equals(Event.Result.DENY)) {
256
            // A plugin denied the item-use.
257
            return;
258
        }
259
260
        if (p.getGameMode() == GameMode.CREATIVE) {
261
            // TODO: If merging SurvivalFly and CreativeFly, creative mode needs to be taken into consideration as well.
262
            pData.setItemInUse(null);
263
            return;
264
        }
265
        
266
        // Proceed to check...
267
        if (e.hasItem()) {
268
            final ItemStack item = e.getItem();
269
            final Material m = item.getType();
270
            if (Bridge1_9.hasElytra() && p.hasCooldown(m)) {
271
                // Item is in cooldown so it cannot be used.
272
                return;
273
            }
274
            
275
            // Edible / consumable items...
276
            if (InventoryUtil.isConsumable(item)) {
277
                if (!Bridge1_9.hasElytra() && item.getDurability() > 16384) {
278
                    // pre1.9 splash potion edge case.
279
                    return;
280
                }
281
                if (m == Material.POTION || m == Material.MILK_BUCKET || m.toString().endsWith("_APPLE") || m.name().startsWith("HONEY_BOTTLE")) {
282
                    // Can be consumed regardless of hunger level
283
                    pData.setItemInUse(m);
284
                    data.offHandUse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
285
                    return;
286
                }
287
                if (item.getType().isEdible() && p.getFoodLevel() < 20) {
288
                    // Hunger level dependant consumables.
289
                    pData.setItemInUse(m); 
290
                    data.offHandUse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
291
                    return;
292
                }
293
            }
294
            // Bows...
295
            if (m == Material.BOW && InventoryUtil.hasArrow(p.getInventory(), false)) {
296
                pData.setItemInUse(m);
297
                data.offHandUse = Bridge1_9.hasGetItemInOffHand() && e.getHand() == EquipmentSlot.OFF_HAND;
298
                return;
299
            }
300
            // Shields and swords (legacy)... Bukkit takes care here, but set anyway.
301
            if (ServerVersion.isAtLeast("1.9") && pData.getClientVersion().isAtLeast(ClientVersion.V_1_9)) {
302
                // Both server and client are on a version that support shield (thus, sword-blocking is not possible)
303
            	if (m == Material.SHIELD) {
304
            	    pData.setItemInUse(m);
305
                    data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
306
                    return;
307
            	}
308
            }
309
            else if (MaterialUtil.isSword(m) && (ServerVersion.isLowerThan("1.9") || pData.getClientVersion().isAtMost(ClientVersion.V_1_8))) {
310
            	// Legacy server. Or legacy client on a modern server. Blocking is done with swords in both cases.
311
            	pData.setItemInUse(m);
312
            	// (Off hand doesn't exist)
313
            	return;
314
            }
315
            
316
            // Crosswbows...
317
            if (m.toString().equals("CROSSBOW")) {
318
                if (!((CrossbowMeta) item.getItemMeta()).hasChargedProjectiles() && InventoryUtil.hasArrow(p.getInventory(), true)) {
319
                    pData.setItemInUse(m);
320
                    data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
321
                }
322
            }
323
            // Tridents (1.13)... 
324
            if (m == BridgeMaterial.TRIDENT && item.getDurability() < m.getMaxDurability() - 1 && pData.getClientVersion().isAtLeast(ClientVersion.V_1_13)
325
            	&& (
326
                    // 1: If the trident has riptide enchant, it can only be used in rain or water 
327
            		BridgeEnchant.getRiptideLevel(p) > 0.0
328
                    && (
329
                        // 2: In water
330
                        BlockProperties.isInWater(p, p.getLocation(), mCC.yOnGround)
331
                        // 2: Always check raining first, since canSeeSky is a much more expensive call. Needs optimization.
332
                        || p.getLocation().getWorld().hasStorm() && BlockProperties.canSeeSky(p, p.getLocation(), mCC.yOnGround) 
333
                    ) 
334
                    // 1: Otherwise, the trident can be used and thrown anywhere
335
                    || BridgeEnchant.getRiptideLevel(p) <= 0.0
336
                )) {
337
                pData.setItemInUse(m);
338
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
339
                return;
340
            }
341
            // Spyglass (1.17)...
342
            if (BridgeMisc.hasIsFrozen() && m == Material.SPYGLASS) {
343
                pData.setItemInUse(m);
344
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
345
                return;
346
            }
347
            // Lastly, goat horns (1.19)...
348
            if (m.toString().equals("GOAT_HORN")) {
349
                pData.setItemInUse(m);
350
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
351
                return;
352
            }
353
            // 1.21.11: Spears...
354
            if (MaterialUtil.isSpear(m)) {
355
                pData.setItemInUse(m);
356
                data.offHandUse = e.getHand() == EquipmentSlot.OFF_HAND;
357
            }
358
        } 
359
        else {
360
            // No item in hands, no deal.
361
            pData.setItemInUse(null);  
362
        }
363
    }
364
    
365
    // NOTE: Bukkit takes care of invalid slot values (< 0 or > 8. PlayerConnection.java), so we don't need to check for this as well.
366
    private static void onChangeSlot(final PlayerItemHeldEvent e) {
367
        final Player p = e.getPlayer();
368
        final IPlayerData pData = DataManager.getPlayerData(p);
369
        // Switching a slot, so the item use status is reset.
370
        final MovingData mData = pData.getGenericInstance(MovingData.class);
371
        final CombinedData cData = pData.getGenericInstance(CombinedData.class);
372
        if (e.getPreviousSlot() != e.getNewSlot()) {
373
            /*if ((pData.getItemInUse() != null || p.isBlocking()) && mData.playerMoves.getCurrentMove() != null) {
374
                p.getInventory().setHeldItemSlot(e.getPreviousSlot());
375
                cData.invalidItemUse = true;
376
            }*/
377
            // To avoid any more potential bypasses, let Minecraft forcibly release the item.
378
            pData.requestItemUseResync();
379
        }
380
    }
381
382
    private void handleBlockPlacePacket(PacketEvent event) {
383
        final Player p = event.getPlayer();
384
        final IPlayerData pData = DataManager.getPlayerData(p);
385
        final CombinedData data = pData.getGenericInstance(CombinedData.class);
386
        final PacketContainer packet = event.getPacket();
387
        final StructureModifier<Integer> ints = packet.getIntegers();
388
        // Legacy: pre 1.9
389
        if (ints.size() > 0 && !ServerVersion.isAtLeast("1.9")) {
390
            final int faceIndex = ints.read(0); // arg 3 if 1.7.10 below
391
            if (faceIndex <= 5) {
392
                data.mightUseItem = false;
393
                return;
394
            }
395
        }
396
        // Player sends a block-placement item when right-clicking, so they might be actually using an item. Set the flag.
397
        if (!event.isCancelled()) data.mightUseItem = true;
398
    }
399
400
    private void handleDiggingPacket(PacketEvent event) {
401
        Player p = event.getPlayer();       
402
        final IPlayerData pData = DataManager.getPlayerDataSafe(p);
403
        final CombinedData data = pData.getGenericInstance(CombinedData.class);
404
        PlayerDigType digtype = event.getPacket().getPlayerDigTypes().read(0);
405
        if (!BridgeMisc.hasGetItemInUseMethod()) {
406
            // DROP_ALL_ITEMS when dead?
407
            if (digtype == PlayerDigType.DROP_ALL_ITEMS || digtype == PlayerDigType.DROP_ITEM) {
408
                pData.setItemInUse(null);
409
            }
410
        }
411
        
412
        if (digtype == PlayerDigType.RELEASE_USE_ITEM) {
413
            pData.setItemInUse(null);
414
            long now = System.currentTimeMillis();
415
            if (data.releaseItemTime != 0) {
416
                if (now < data.releaseItemTime) {
417
                    data.releaseItemTime = now;
418
                    return;
419
                }
420
                if (data.releaseItemTime + timeBetweenRL > now) {
421
                    data.isHackingRI = true;
422
                }
423
            }
424
            data.releaseItemTime = now;
425
        }
426
    }
427
428
    /**
429
     * Set Minimum time between RELEASE_USE_ITEM packet is sent.
430
     * If time lower this value, A check will flag
431
     * Should be set from 51-100. Larger number, more protection more false-positive
432
     * 
433
     * @param time milliseconds
434
     */ 
435
    public static void setuseRLThreshold(int time) {
436
        timeBetweenRL = time;
437
    }   
438
}

How it counteracts this module

NCP's adapter classifies the module's C08 as a use-item claim: handleBlockPlacePacket sets mightUseItem for any face index above 5, and the throw's face-255 form qualifies, so the right-click that follows drives onItemInteract - which skips setItemInUse for splash potions at the pre-1.9 durability guard. The C09 pair is the part the adapter processes for real: onChangeSlot runs on each held-slot change and calls requestItemUseResync whenever the slot actually differs, forcibly unwinding server-side item-use state. Sigma's burst fires both C09s within one tick of the use, so the adapter sees a use-claim bracketed by two slot changes - the precise sequence its resync path was built to reconcile. The C05 look packet is invisible to this adapter (it only listens to BLOCK_DIG and BLOCK_PLACE), so the claimed 90-degree throw rotation passes through the net layer unexamined; the item-use state machine, however, is churned on every cycle.

anticheat InventoryListener (consume-time feed)

InventoryListener.java87 lines · Java
1
package me.vrekt.arc.listener.inventory;
2
3
import me.vrekt.arc.Arc;
4
import me.vrekt.arc.check.CheckType;
5
import me.vrekt.arc.check.inventory.FastConsume;
6
import me.vrekt.arc.data.inventory.InventoryData;
7
import me.vrekt.arc.listener.ACheckListener;
8
import org.bukkit.Bukkit;
9
import org.bukkit.ChatColor;
10
import org.bukkit.Material;
11
import org.bukkit.entity.Player;
12
import org.bukkit.event.EventHandler;
13
import org.bukkit.event.EventPriority;
14
import org.bukkit.event.Listener;
15
import org.bukkit.event.block.Action;
16
import org.bukkit.event.inventory.InventoryClickEvent;
17
import org.bukkit.event.player.PlayerInteractEvent;
18
import org.bukkit.event.player.PlayerItemConsumeEvent;
19
import org.bukkit.inventory.Inventory;
20
import org.bukkit.inventory.ItemStack;
21
22
public class InventoryListener implements Listener, ACheckListener {
23
    private final FastConsume FAST_CONSUME = (FastConsume) CHECK_MANAGER.getCheck(CheckType.FASTCONSUME);
24
25
    @EventHandler(priority = EventPriority.LOWEST)
26
    public void onConsume(PlayerItemConsumeEvent event) {
27
        Player player = event.getPlayer();
28
        InventoryData data = InventoryData.getData(player);
29
30
        boolean canCheckFastConsume = CHECK_MANAGER.canCheckPlayer(player, CheckType.FASTCONSUME);
31
        if (canCheckFastConsume) {
32
            // check and cancel if we failed.
33
            boolean cancel = FAST_CONSUME.check(player, data);
34
            event.setCancelled(cancel);
35
        }
36
37
    }
38
39
    @EventHandler(priority = EventPriority.HIGHEST)
40
    public void onInteract(PlayerInteractEvent event) {
41
        Action action = event.getAction();
42
        ItemStack item = event.getItem();
43
44
        if (item == null) {
45
            return;
46
        }
47
48
        if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
49
            Player player = event.getPlayer();
50
            InventoryData data = InventoryData.getData(player);
51
            // check if we are consuming an item.
52
            if (item.getType().isEdible() || item.getType() == Material.POTION) {
53
                // update data.
54
                data.setConsumeTime(System.currentTimeMillis());
55
            }
56
        }
57
58
    }
59
60
    /**
61
     * Handle the GUI stuff.
62
     */
63
    @EventHandler
64
    public void onClick(InventoryClickEvent event) {
65
66
        Inventory inventory = event.getInventory();
67
        if (inventory.getTitle().contains("Summary for ")) {
68
            event.setCancelled(true);
69
70
            ItemStack item = event.getCurrentItem();
71
            Player viewer = (Player) event.getWhoClicked();
72
            if (item.getType() == Material.IRON_SWORD) {
73
                Player player = Bukkit.getPlayer(inventory.getTitle().split(" ")[2]);
74
                if (player == null) {
75
                    viewer.sendMessage(ChatColor.RED + "This player has logged out.");
76
                    viewer.closeInventory();
77
                    return;
78
                }
79
80
                Arc.getArcPlayerManager().scheduleBan(player);
81
            }
82
83
        }
84
85
    }
86
87
}

How it counteracts this module

Arc v2's inventory listener is the feed for its FastConsume check: onInteract stamps InventoryData.consumeTime for any RIGHT_CLICK_AIR or RIGHT_CLICK_BLOCK while holding an edible or POTION, and onConsume runs FastConsume.check on PlayerItemConsumeEvent. Sigma's C08 throw produces the right-click, so consumeTime is stamped on every throw; the splash completion never fires the consume event, leaving the ledger half-open exactly as with NCP. The listener's onClick handler, by contrast, only guards Arc's own management GUI, so the module's mode-2 C0E swap passes through unexamined - Arc v2 has no window-click check for the player container in this snapshot, which is why the C0E half of Sigma's cycle is unobserved here. The countering value of the file is the consume-time hook itself: with consumeTime stamped on every potion right-click and the module's 900/1000ms gates setting the minimum separation, any lowering of the module's gates below Arc's consume-time threshold - or any server lag that coalesces two ceremonies - turns the repeated stamps into a FastConsume violation, and the soup-gated AutoHeal path in PacketListener shows the intended shape of that detection for consumable-based healing.

← Back to Analysis Hub