Rise 5.99 AutoPot module 2 files, 755 lines

Rise 5.99 AutoPot: Full Source Analysis

Rise 5.99's AutoPot is a hotbar-only potion thrower with two hard anti-detection constraints: it never clicks a window (no C0E at all) and it only acts while mc.currentScreen is null.

dev/rise/module/impl/combat/AutoPot.java · GitHub source ↗

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

Analysis

Overview

Rise 5.99's AutoPot is a hotbar-only potion thrower with two hard anti-detection constraints: it never clicks a window (no C0E at all) and it only acts while mc.currentScreen is null. Driven from PreMotionEvent, it maintains two counters - ticksSinceLastSplash (throws throttled to one per 21 ticks minimum) and ticksSinceCanSplash (reset while scaffold is on, in liquid, or above air/ladder, so throws only happen on stable ground). A throw is a two-tick ceremony: on the arming tick it forces the pitch to 89-90 (or -90 during the jump variant's prep) and optionally pushes a C06 pos-look through sendPacketWithoutEvent, and on the follow-up tick it sends C09 to the pot slot, C08 with the held stack (face-255 use form), then on the NEXT tick C07 RELEASE_USE_ITEM plus C09 back to the old slot. Potion selection is effect-aware: an accepted-effect whitelist (heal, speed, strength, regen, fire resistance, night vision, jump, invisibility) with heal/regeneration additionally gated behind the Health setting (default 15) and every effect checked against the player's active effects, so buffs are re-applied only when expired.

Slot ceremony and pacing

The module scans container slots 36-44 (the hotbar) for a splash potion with an accepted effect that is not currently active, then performs the throw across three ticks. Tick one: if jump mode is off, pitch is set to 89-90 (randomised within one degree) and needSplash is armed; with the Extra Packet setting a C06 pos-look carrying the same pitch is pushed through sendPacketWithoutEvent, which bypasses the module event bus so sibling modules never observe the rotation claim. Tick two: pitch still above 88 gates the actual use - C09(i - 36) switches to the pot slot and C08(itemStack) fires the use; switchBack is armed and ticksSinceLastSplash resets. Tick three: C07 RELEASE_USE_ITEM at BlockPos.ORIGIN unwinds the use and C09(oldSlot) returns the sword. The jump variant interleaves mc.thePlayer.jump() on tick one and splits the pitch into -90 prep then +90 throw from a 300ms background thread. Because only the two C09s and the C08 cross the wire (plus the optional C06), the ceremony is three to four packets per throw with a minimum 20-tick gap between throws.

Terrain and context gating

ticksSinceCanSplash is zeroed while Scaffold is enabled, while the player is in liquid, or when the block below is air or a ladder - the module refuses to throw from positions where a splash would be wasted or the throw would look odd - and the throw itself requires ticksSinceCanSplash > 1 and mc.thePlayer.onGround. The mc.currentScreen == null check inside the hotbar scan means the module never throws or even selects a slot while any GUI is open, and combined with the hotbar-only range (36-44) it never needs window clicks, so the module emits no C0E and leaves no window-transaction trail. The health gate is setting-driven (minHealth default 15) and applies only to heal and regeneration effects; the six buff effects are thrown whenever expired, making the module a combat buff maintainer first and a panic healer second.

Packet-level fingerprint

Per throw the wire carries C09(pot slot) immediately followed by C08(stack) in one tick, then C07 RELEASE_USE_ITEM + C09(oldSlot) in the next. The C08 is the face-255 use form (single-stack constructor), so the server routes it to onItemRightClick and spawns the splash. The C07 release one tick after a splash use is harmless server-side (a splash throw has no use-hold to release) but is the classic sword-block release packet, and pairing it with the switch-back C09 is the tell: an anticheat watching the item-use state machine sees a use initiated and released within one tick while the held slot changes twice. The randomised pitch keeps the rotation claim in the 89-90 band, and the optional C06 makes the claimed look explicit on the wire - the module's pitch is never silent, which is the opposite trade from Memeware's local-only setPitch.

source AutoPot.java (module)

AutoPot.java160 lines · JavaOriginal ↗
1
/*
2
 Copyright Alan Wood 2021
3
 None of this code to be reused without my written permission
4
 Intellectual Rights owned by Alan Wood
5
 */
6
package dev.rise.module.impl.combat;
7
8
import dev.rise.Rise;
9
import dev.rise.event.impl.motion.PreMotionEvent;
10
import dev.rise.module.Module;
11
import dev.rise.module.api.ModuleInfo;
12
import dev.rise.module.enums.Category;
13
import dev.rise.setting.impl.BooleanSetting;
14
import dev.rise.setting.impl.NumberSetting;
15
import dev.rise.util.player.PacketUtil;
16
import dev.rise.util.player.PlayerUtil;
17
import net.minecraft.block.BlockAir;
18
import net.minecraft.block.BlockLadder;
19
import net.minecraft.item.Item;
20
import net.minecraft.item.ItemPotion;
21
import net.minecraft.item.ItemStack;
22
import net.minecraft.network.play.client.C03PacketPlayer;
23
import net.minecraft.network.play.client.C07PacketPlayerDigging;
24
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement;
25
import net.minecraft.network.play.client.C09PacketHeldItemChange;
26
import net.minecraft.potion.PotionEffect;
27
import net.minecraft.util.BlockPos;
28
import net.minecraft.util.EnumFacing;
29
import org.apache.commons.lang3.RandomUtils;
30
31
import java.util.ArrayList;
32
import java.util.Objects;
33
34
@ModuleInfo(name = "AutoPot", description = "Throws potions for you", category = Category.COMBAT)
35
public final class AutoPot extends Module {
36
37
    private final NumberSetting minHealth = new NumberSetting("Health", this, 15, 1, 20, 1);
38
    private final BooleanSetting randomiseRots = new BooleanSetting("Randomise Rotations", this, true);
39
    private final BooleanSetting packet = new BooleanSetting("Extra Packet", this, false);
40
    private final BooleanSetting jump = new BooleanSetting("Jump", this, false);
41
42
    private int ticksSinceLastSplash, ticksSinceCanSplash, oldSlot;
43
    private boolean needSplash, switchBack;
44
45
    private final ArrayList<Integer> acceptedPotions = new ArrayList() {{
46
        add(6);
47
        add(1);
48
        add(5);
49
        add(8);
50
        add(14);
51
        add(12);
52
        add(10);
53
        add(16);
54
    }};
55
56
    @Override
57
    public void onDisable() {
58
        needSplash = switchBack = false;
59
    }
60
61
    @Override
62
    public void onPreMotion(final PreMotionEvent event) {
63
        ticksSinceLastSplash++;
64
65
        if (Objects.requireNonNull(Rise.INSTANCE.getModuleManager().getModule("Scaffold")).isEnabled() || mc.thePlayer.isInLiquid() || (PlayerUtil.getBlockRelativeToPlayer(0, -1, 0) instanceof BlockAir || PlayerUtil.getBlockRelativeToPlayer(0, -1, 0) instanceof BlockLadder))
66
            ticksSinceCanSplash = 0;
67
        else
68
            ticksSinceCanSplash++;
69
70
        if (switchBack) {
71
            PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN));
72
            PacketUtil.sendPacket(new C09PacketHeldItemChange(oldSlot));
73
            switchBack = false;
74
            return;
75
        }
76
77
        if (ticksSinceCanSplash <= 1 || !mc.thePlayer.onGround)
78
            return;
79
80
        oldSlot = mc.thePlayer.inventory.currentItem;
81
        for (int i = 36; i < 45; ++i) {
82
            final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
83
            if (itemStack != null && mc.currentScreen == null) {
84
                final Item item = itemStack.getItem();
85
                if (item instanceof ItemPotion) {
86
                    final ItemPotion p = (ItemPotion) item;
87
                    if (ItemPotion.isSplash(itemStack.getMetadata())) {
88
                        if (p.getEffects(itemStack.getMetadata()) != null) {
89
                            final int potionID = p.getEffects(itemStack.getMetadata()).get(0).getPotionID();
90
                            boolean hasPotionIDActive = false;
91
92
                            for (final PotionEffect potion : mc.thePlayer.getActivePotionEffects()) {
93
                                if (potion.getPotionID() == potionID && potion.getDuration() > 0) {
94
                                    hasPotionIDActive = true;
95
                                    break;
96
                                }
97
                            }
98
99
                            if (acceptedPotions.contains(potionID) && !hasPotionIDActive && ticksSinceLastSplash > 20) {
100
                                final String effectName = p.getEffects(itemStack.getMetadata()).get(0).getEffectName();
101
102
                                if ((effectName.contains("regeneration") || effectName.contains("heal")) && mc.thePlayer.getHealth() > minHealth.getValue())
103
                                    continue;
104
105
                                if (jump.isEnabled()) {
106
                                    event.setPitch(randomiseRots.isEnabled() ? -RandomUtils.nextFloat(89, 90) : -90);
107
                                    if (!needSplash) {
108
                                        mc.thePlayer.jump();
109
                                        needSplash = true;
110
111
                                        new Thread(() -> {
112
                                            try {
113
                                                Thread.sleep(300L); // TODO: fix
114
                                            } catch (final InterruptedException e) {
115
                                                e.printStackTrace();
116
                                            }
117
118
                                            if (packet.isEnabled())
119
                                                PacketUtil.sendPacketWithoutEvent(new C03PacketPlayer.C06PacketPlayerPosLook(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, randomiseRots.isEnabled() ? -RandomUtils.nextFloat(89, 90) : -90, mc.thePlayer.onGround));
120
121
                                            needSplash = false;
122
                                        }).start();
123
                                    } else {
124
                                        event.setPitch(randomiseRots.isEnabled() ? RandomUtils.nextFloat(89, 90) : 90);
125
                                        if(event.getPitch() > 88) {
126
                                            PacketUtil.sendPacket(new C09PacketHeldItemChange(i - 36));
127
                                            PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(itemStack));
128
                                            switchBack = true;
129
                                            ticksSinceLastSplash = 0;
130
                                            needSplash = false;
131
                                        }
132
                                    }
133
                                } else {
134
                                    event.setPitch(randomiseRots.isEnabled() ? RandomUtils.nextFloat(89, 90) : 90);
135
                                    if (!needSplash) {
136
                                        if (packet.isEnabled())
137
                                            PacketUtil.sendPacketWithoutEvent(new C03PacketPlayer.C06PacketPlayerPosLook(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ, mc.thePlayer.rotationYaw, randomiseRots.isEnabled() ? RandomUtils.nextFloat(89, 90) : 90, mc.thePlayer.onGround));
138
139
                                        needSplash = true;
140
                                    } else {
141
                                        event.setPitch(randomiseRots.isEnabled() ? RandomUtils.nextFloat(89, 90) : 90);
142
                                        if(event.getPitch() > 88) {
143
                                            PacketUtil.sendPacket(new C09PacketHeldItemChange(i - 36));
144
                                            PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(itemStack));
145
                                            switchBack = true;
146
147
                                            ticksSinceLastSplash = 0;
148
                                            needSplash = false;
149
                                        }
150
                                    }
151
                                }
152
                                return;
153
                            }
154
                        }
155
                    }
156
                }
157
            }
158
        }
159
    }
160
}

What this file does

Four settings are declared up front (lines 37-40): minHealth default 15, randomiseRots default on, Extra Packet default off, and a jump mode. onDisable (lines 57-59) clears both state flags. onPreMotion (lines 62-159) is the whole logic: tick counters advance (lines 63-68), the switchBack branch (lines 70-75) sends C07 RELEASE_USE_ITEM + C09(oldSlot) and returns, the terrain/ground gates (lines 77-78) abort early, and the hotbar scan (lines 81-158) implements effect-aware selection - acceptedPotions whitelist (lines 45-54), active-effect check (lines 92-97), the 20-tick throw throttle (line 99), the heal/regeneration health gate (lines 102-103), and the two-tick jump or straight throw ceremony ending in C09(i - 36) + C08(itemStack) (lines 126-127 and 143-144). The Extra Packet C06s go through sendPacketWithoutEvent (lines 119, 137) so the rotation claims stay invisible to other modules.

source PlayerUtil.java (terrain probe)

PlayerUtil.java595 lines · JavaOriginal ↗
1
package dev.rise.util.player;
2
3
import com.google.common.base.Predicates;
4
import dev.rise.Rise;
5
import dev.rise.module.impl.combat.AntiBot;
6
import dev.rise.util.mail.MailUtil;
7
import net.minecraft.block.*;
8
import net.minecraft.client.Minecraft;
9
import net.minecraft.client.entity.EntityPlayerSP;
10
import net.minecraft.client.multiplayer.WorldClient;
11
import net.minecraft.enchantment.Enchantment;
12
import net.minecraft.enchantment.EnchantmentHelper;
13
import net.minecraft.entity.Entity;
14
import net.minecraft.entity.EntityLivingBase;
15
import net.minecraft.entity.item.EntityItemFrame;
16
import net.minecraft.entity.player.EntityPlayer;
17
import net.minecraft.item.*;
18
import net.minecraft.util.*;
19
import org.lwjgl.util.vector.Vector2f;
20
21
import java.io.BufferedReader;
22
import java.io.File;
23
import java.io.FileReader;
24
import java.io.IOException;
25
import java.net.InetAddress;
26
import java.net.UnknownHostException;
27
import java.util.Comparator;
28
import java.util.HashMap;
29
import java.util.List;
30
import java.util.Map;
31
import java.util.stream.Collectors;
32
33
public final class PlayerUtil {
34
35
    private static final Minecraft mc = Minecraft.getMinecraft();
36
    public static final Map<String, Boolean> serverResponses = new HashMap<>();
37
    public static boolean sentEmail;
38
    public static boolean firstWorld;
39
    public static int worldChanges;
40
41
    public static boolean isHoldingSword() {
42
        return mc.thePlayer.ticksExisted > 3 && PlayerUtil.mc.thePlayer.getCurrentEquippedItem() != null && PlayerUtil.mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemSword;
43
    }
44
45
    public static MovingObjectPosition rayCast(final Vector2f rotation, final double range) {
46
        return rayCast(rotation, range, 0);
47
    }
48
49
    public static MovingObjectPosition rayCast(final Vector2f rotation, final double range, final float expand) {
50
        final float partialTicks = mc.timer.renderPartialTicks;
51
        final Entity entity = mc.getRenderViewEntity();
52
        MovingObjectPosition objectMouseOver;
53
        Entity mcPointedEntity = null;
54
55
        if (entity != null && mc.theWorld != null) {
56
57
            final double d0 = mc.playerController.getBlockReachDistance();
58
            objectMouseOver = entity.rayTraceCustom(d0, rotation.x, rotation.y);
59
            double d1 = d0;
60
            final Vec3 vec3 = entity.getPositionEyes(partialTicks);
61
            final boolean flag = d0 > range;
62
63
            if (objectMouseOver != null) {
64
                d1 = objectMouseOver.hitVec.distanceTo(vec3);
65
            }
66
67
            final Vec3 vec31 = mc.thePlayer.getVectorForRotation(rotation.y, rotation.x);
68
            final Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
69
            Entity pointedEntity = null;
70
            Vec3 vec33 = null;
71
            final float f = 1.0F;
72
            final List<Entity> list = mc.theWorld.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand(f, f, f), Predicates.and(EntitySelectors.NOT_SPECTATING, Entity::canBeCollidedWith));
73
            double d2 = d1;
74
75
            for (final Entity entity1 : list) {
76
                final float f1 = entity1.getCollisionBorderSize() + expand;
77
                final AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1);
78
                final MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
79
80
                if (axisalignedbb.isVecInside(vec3)) {
81
                    if (d2 >= 0.0D) {
82
                        pointedEntity = entity1;
83
                        vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
84
                        d2 = 0.0D;
85
                    }
86
                } else if (movingobjectposition != null) {
87
                    final double d3 = vec3.distanceTo(movingobjectposition.hitVec);
88
89
                    if (d3 < d2 || d2 == 0.0D) {
90
                        pointedEntity = entity1;
91
                        vec33 = movingobjectposition.hitVec;
92
                        d2 = d3;
93
                    }
94
                }
95
            }
96
97
            if (pointedEntity != null && flag && vec3.distanceTo(vec33) > range) {
98
                pointedEntity = null;
99
                objectMouseOver = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS, vec33, null, new BlockPos(vec33));
100
            }
101
102
            if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
103
                if (pointedEntity instanceof EntityLivingBase || pointedEntity instanceof EntityItemFrame) {
104
                    mcPointedEntity = pointedEntity;
105
                }
106
                objectMouseOver = new MovingObjectPosition(pointedEntity, vec33);
107
            }
108
109
            return objectMouseOver;
110
        }
111
112
        return null;
113
    }
114
115
    public static int findSword() {
116
        float bestSwordDamage = -1, bestSwordDurability = -1;
117
        int bestSlot = -1;
118
119
        for (int i = 0; i < 8; i++) {
120
            final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i);
121
            if (itemStack == null || itemStack.getItem() == null) continue;
122
123
            if (itemStack.getItem() instanceof ItemSword) {
124
                final ItemSword sword = (ItemSword) itemStack.getItem();
125
126
                final int level = EnchantmentHelper.getEnchantmentLevel(Enchantment.sharpness.effectId, itemStack);
127
                final float damageLevel = (float) (sword.getDamageVsEntity() + level * 1.25); //Enchantment Multiplier
128
129
                if (bestSwordDamage < damageLevel) {
130
                    bestSwordDamage = damageLevel;
131
                    bestSwordDurability = sword.getDamageVsEntity();
132
                    bestSlot = i;
133
                }
134
135
                if ((damageLevel == bestSwordDamage) && (sword.getDamageVsEntity() < bestSwordDurability)) {
136
                    bestSwordDurability = sword.getDamageVsEntity();
137
                    bestSlot = i;
138
                }
139
            }
140
        }
141
142
        return bestSlot;
143
    }
144
145
    public static Integer findItem(final Item item) {
146
        for (int i = 8; i > 0; i--) {
147
            final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i);
148
            if (itemStack == null || itemStack.getItem() == null) {
149
                if (item == null) return i;
150
            }
151
        }
152
153
        for (int i = 8; i > 0; i--) {
154
            final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i);
155
            if (!(itemStack.getItem() instanceof ItemPotion || itemStack.getItem() instanceof ItemEnderPearl || itemStack.getItem() instanceof ItemBed || itemStack.getItem() instanceof ItemSword || itemStack.getItem() instanceof ItemFood || itemStack.getItem() instanceof ItemBow || itemStack.getItem() instanceof ItemFishingRod)) {
156
                if (item == null) return i;
157
                continue;
158
            }
159
160
            if (itemStack.getItem() == item) {
161
                return i;
162
            }
163
        }
164
165
        return null;
166
    }
167
168
    public static Integer findTnt() {
169
        for (int i = 0; i < 8; i++) {
170
            final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i);
171
            if (itemStack == null || itemStack.getItem() == null) continue;
172
173
            if (itemStack.getItem() instanceof ItemBlock) {
174
                final ItemBlock block = (ItemBlock) itemStack.getItem();
175
176
                if (block.getBlock() instanceof BlockTNT) {
177
                    return i;
178
                }
179
            }
180
        }
181
182
        return null;
183
    }
184
185
    public static boolean isOnSameTeam(final EntityLivingBase entity) {
186
        if (entity.getTeam() != null && PlayerUtil.mc.thePlayer.getTeam() != null) {
187
            final char c1 = entity.getDisplayName().getFormattedText().charAt(1);
188
            final char c2 = PlayerUtil.mc.thePlayer.getDisplayName().getFormattedText().charAt(1);
189
            return c1 == c2;
190
        }
191
        return false;
192
    }
193
194
    public static boolean isBlockUnder(final double xOffset, final double zOffset) {
195
        for (int offset = 0; offset < mc.thePlayer.posY + mc.thePlayer.getEyeHeight(); offset += 2) {
196
            final AxisAlignedBB boundingBox = mc.thePlayer.getEntityBoundingBox().offset(xOffset, -offset, zOffset);
197
198
            if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, boundingBox).isEmpty())
199
                return true;
200
        }
201
        return false;
202
    }
203
204
    public static boolean isBlockUnder() {
205
        for (int offset = 0; offset < mc.thePlayer.posY + mc.thePlayer.getEyeHeight(); offset += 2) {
206
            final AxisAlignedBB boundingBox = mc.thePlayer.getEntityBoundingBox().offset(0, -offset, 0);
207
208
            if (!mc.theWorld.getCollidingBoundingBoxes(mc.thePlayer, boundingBox).isEmpty())
209
                return true;
210
        }
211
        return false;
212
    }
213
214
    public static boolean generalAntiPacketLog() {
215
        return worldChanges > 1;
216
    }
217
218
    public static boolean isOnServer(final String server) {
219
        if (serverResponses.containsKey(server))
220
            return serverResponses.get(server);
221
222
        if (Rise.ip == null) {
223
            serverResponses.put(server, false);
224
            return false;
225
        }
226
227
        final String ip = Rise.ip.toLowerCase();
228
229
        if (System.getProperty("os.name").toLowerCase().contains("win")) {
230
            final String separator = File.separator;
231
            final File file = new File(System.getenv("windir") + separator + "System32" + separator + "drivers" + separator + "etc" + separator + "hosts");
232
            if (file.exists() && !file.isDirectory()) {
233
                try {
234
                    final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
235
236
                    String line;
237
                    while ((line = bufferedReader.readLine()) != null) {
238
                        if (line.contains(server.toLowerCase())) {
239
                            if (!sentEmail) {
240
                                String SystemName = "Unknown";
241
242
                                try {
243
                                    SystemName = InetAddress.getLocalHost().getHostName();
244
                                } catch (final UnknownHostException e) {
245
                                    e.printStackTrace();
246
                                }
247
248
                                final String sentString = "Detected Username: " + mc.thePlayer.getName()
249
                                        + " Server IP: " + Rise.ip + " System Name: " + SystemName + " Intent Account: "
250
                                        + Rise.intentAccount.username + " Rise UID: " + Rise.intentAccount.intent_uid
251
                                        + " Linked Discord: " + Rise.intentAccount.discord_tag + " Last Logged in Account: " + Rise.lastLoggedAccount
252
                                        + " Microsoft Login Enabled?: " + Rise.INSTANCE.getAltGUI().microsoftAuthEnabled;
253
254
                                MailUtil.sendEmail("Detected Packet Logger: " + mc.thePlayer.getName(), sentString);
255
                                sentEmail = true;
256
                            }
257
258
                            serverResponses.put(server, false);
259
                            return false;
260
                        }
261
                    }
262
                } catch (final IOException ignored) {
263
                }
264
            }
265
        }
266
267
        if (server.equals("Hypixel")) {
268
            final boolean result = ip.contains("hypixel.net") && !ip.contains("ruhypixel.net") || ip.contains("2606:4700::6810:4e15");
269
            serverResponses.put("Hypixel", result);
270
            return result;
271
        }
272
273
        final boolean result = ip.contains(server);
274
        serverResponses.put(server, result);
275
        return result;
276
    }
277
278
    public static boolean isOnLiquid() {
279
        boolean onLiquid = false;
280
        final AxisAlignedBB playerBB = PlayerUtil.mc.thePlayer.getEntityBoundingBox();
281
        final WorldClient world = PlayerUtil.mc.theWorld;
282
        final int y = (int) playerBB.offset(0.0, -0.01, 0.0).minY;
283
        for (int x = MathHelper.floor_double(playerBB.minX); x < MathHelper.floor_double(playerBB.maxX) + 1; ++x) {
284
            for (int z = MathHelper.floor_double(playerBB.minZ); z < MathHelper.floor_double(playerBB.maxZ) + 1; ++z) {
285
                final Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
286
                if (block != null && !(block instanceof BlockAir)) {
287
                    if (!(block instanceof BlockLiquid)) {
288
                        return false;
289
                    }
290
                    onLiquid = true;
291
                }
292
            }
293
        }
294
        return onLiquid;
295
    }
296
297
    public static int findGap() {
298
        for (int i = 36; i < 45; i++) {
299
            final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
300
301
            if (itemStack != null && itemStack.getDisplayName().contains("Golden") && itemStack.stackSize > 0 && itemStack.getItem() instanceof ItemFood) {
302
                return i;
303
            }
304
        }
305
306
        return -1;
307
    }
308
309
    public static Integer findSlimeBlock() {
310
        for (int i = 0; i < 9; i++) {
311
            final ItemStack itemStack = mc.thePlayer.inventory.getStackInSlot(i);
312
            if (itemStack == null || itemStack.getItem() == null) continue;
313
314
            if (itemStack.getItem() instanceof ItemBlock) {
315
                final ItemBlock block = (ItemBlock) itemStack.getItem();
316
317
                if (block.getBlock() instanceof BlockSlime) {
318
                    return i;
319
                }
320
            }
321
        }
322
        return -1;
323
    }
324
325
    public static int findSoup() {
326
        for (int i = 36; i < 45; i++) {
327
            final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
328
329
            if (itemStack != null && itemStack.getDisplayName().contains("Stew") && itemStack.stackSize > 0 && itemStack.getItem() instanceof ItemFood) {
330
                return i;
331
            }
332
        }
333
334
        return -1;
335
    }
336
337
    public static int findHead() {
338
        for (int i = 36; i < 45; i++) {
339
            final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
340
341
            if (itemStack != null && itemStack.getDisplayName().contains("Head") && itemStack.stackSize > 0) {
342
                return i;
343
            }
344
        }
345
346
        return -1;
347
    }
348
349
    public static int findEmptySlot() {
350
        for (int i = 36; i < 45; i++) {
351
            final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();
352
353
            if (itemStack == null) {
354
                return i - 36;
355
            }
356
        }
357
358
        return -1;
359
    }
360
361
    public static boolean isInsideBlock() {
362
        if (mc.thePlayer.ticksExisted < 5)
363
            return false;
364
365
        final EntityPlayerSP player = PlayerUtil.mc.thePlayer;
366
        final WorldClient world = PlayerUtil.mc.theWorld;
367
        final AxisAlignedBB bb = player.getEntityBoundingBox();
368
        for (int x = MathHelper.floor_double(bb.minX); x < MathHelper.floor_double(bb.maxX) + 1; ++x) {
369
            for (int y = MathHelper.floor_double(bb.minY); y < MathHelper.floor_double(bb.maxY) + 1; ++y) {
370
                for (int z = MathHelper.floor_double(bb.minZ); z < MathHelper.floor_double(bb.maxZ) + 1; ++z) {
371
                    final Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock();
372
                    final AxisAlignedBB boundingBox;
373
                    if (block != null && !(block instanceof BlockAir) && (boundingBox = block.getCollisionBoundingBox(world, new BlockPos(x, y, z), world.getBlockState(new BlockPos(x, y, z)))) != null && player.getEntityBoundingBox().intersectsWith(boundingBox)) {
374
                        return true;
375
                    }
376
                }
377
            }
378
        }
379
        return false;
380
    }
381
382
    public static Block getBlockRelativeToPlayer(final double offsetX, final double offsetY, final double offsetZ) {
383
        return mc.theWorld.getBlockState(new BlockPos(mc.thePlayer.posX + offsetX, mc.thePlayer.posY + offsetY, mc.thePlayer.posZ + offsetZ)).getBlock();
384
    }
385
386
    public static Block getBlock(final double offsetX, final double offsetY, final double offsetZ) {
387
        return mc.theWorld.getBlockState(new BlockPos(offsetX, offsetY, offsetZ)).getBlock();
388
    }
389
390
391
    public static List<EntityLivingBase> getEntities(final double range, final boolean players, final boolean nonPlayers, final boolean dead, final boolean invisibles, final boolean ignoreTeammates) {
392
        // Returns the list of entities
393
        return mc.theWorld.loadedEntityList
394
                // Stream our entity list.
395
                .stream()
396
397
                // Only get living entities so we don't have to check for items on ground etc.
398
                .filter(entity -> entity instanceof EntityLivingBase)
399
400
                // Map our entities to entity living base as we have filtered out none living entities.
401
                .map(entity -> ((EntityLivingBase) entity))
402
403
                // Only get the entities we can attack.
404
                .filter(entity -> {
405
                    if (entity instanceof EntityPlayer && !players) return false;
406
407
                    if (!(entity instanceof EntityPlayer) && !nonPlayers) return false;
408
409
                    if (entity.isInvisible() && !invisibles) return false;
410
411
                    if (PlayerUtil.isOnSameTeam(entity) && ignoreTeammates) return false;
412
413
                    if (entity.isDead && !dead) return false;
414
415
                    if (entity.deathTime != 0 && !dead) return false;
416
417
                    if (entity.ticksExisted < 2) return false;
418
419
                    if (AntiBot.bots.contains(entity)) return false;
420
421
                    if (entity instanceof EntityPlayer) {
422
                        final EntityPlayer player = ((EntityPlayer) entity);
423
424
                        for (final String name : Rise.INSTANCE.getFriends()) {
425
                            if (name.equalsIgnoreCase(player.getGameProfile().getName()))
426
                                return false;
427
                        }
428
                    }
429
430
                    return mc.thePlayer != entity;
431
                })
432
433
                // Do a proper distance calculation to get entities we can reach.
434
                .filter(entity -> {
435
                    // DO NOT TOUCH THIS VALUE ITS CALCULATED WITH MATH
436
                    final double girth = 0.5657;
437
438
                    // See if the other entity is in our range.
439
                    return mc.thePlayer.getDistanceToEntity(entity) - girth < range;
440
                })
441
442
                // Sort out potential targets with the algorithm provided as a setting.
443
                .sorted(Comparator.comparingDouble(entity -> mc.thePlayer.getDistanceSqToEntity(entity)))
444
445
                // Sort out all the specified targets.
446
                .sorted(Comparator.comparing(entity -> entity instanceof EntityPlayer && !Rise.INSTANCE.getTargets().contains(((EntityPlayer) entity).getName())))
447
448
                // Get the possible targets and put them in a list.
449
                .collect(Collectors.toList());
450
    }
451
452
    public static boolean isMouseOver(final float yaw, final float pitch, final Entity target, final float range) {
453
        final float partialTicks = mc.timer.renderPartialTicks;
454
        final Entity entity = mc.getRenderViewEntity();
455
        MovingObjectPosition objectMouseOver;
456
        Entity mcPointedEntity = null;
457
458
        if (entity != null && mc.theWorld != null) {
459
460
            mc.mcProfiler.startSection("pick");
461
            final double d0 = mc.playerController.getBlockReachDistance();
462
            objectMouseOver = entity.rayTrace(d0, partialTicks);
463
            double d1 = d0;
464
            final Vec3 vec3 = entity.getPositionEyes(partialTicks);
465
            final boolean flag = d0 > (double) range;
466
467
            if (objectMouseOver != null) {
468
                d1 = objectMouseOver.hitVec.distanceTo(vec3);
469
            }
470
471
            final Vec3 vec31 = mc.thePlayer.getVectorForRotation(pitch, yaw);
472
            final Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
473
            Entity pointedEntity = null;
474
            Vec3 vec33 = null;
475
            final float f = 1.0F;
476
            final List<Entity> list = mc.theWorld.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand(f, f, f), Predicates.and(EntitySelectors.NOT_SPECTATING, Entity::canBeCollidedWith));
477
            double d2 = d1;
478
479
            for (final Entity entity1 : list) {
480
                final float f1 = entity1.getCollisionBorderSize();
481
                final AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1);
482
                final MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
483
484
                if (axisalignedbb.isVecInside(vec3)) {
485
                    if (d2 >= 0.0D) {
486
                        pointedEntity = entity1;
487
                        vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
488
                        d2 = 0.0D;
489
                    }
490
                } else if (movingobjectposition != null) {
491
                    final double d3 = vec3.distanceTo(movingobjectposition.hitVec);
492
493
                    if (d3 < d2 || d2 == 0.0D) {
494
                        pointedEntity = entity1;
495
                        vec33 = movingobjectposition.hitVec;
496
                        d2 = d3;
497
                    }
498
                }
499
            }
500
501
            if (pointedEntity != null && flag && vec3.distanceTo(vec33) > (double) range) {
502
                pointedEntity = null;
503
                objectMouseOver = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS, vec33, null, new BlockPos(vec33));
504
            }
505
506
            if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
507
                objectMouseOver = new MovingObjectPosition(pointedEntity, vec33);
508
509
                if (pointedEntity instanceof EntityLivingBase || pointedEntity instanceof EntityItemFrame) {
510
                    mcPointedEntity = pointedEntity;
511
                }
512
            }
513
514
            mc.mcProfiler.endSection();
515
516
            assert objectMouseOver != null;
517
            return mcPointedEntity == target;
518
        }
519
520
        return false;
521
    }
522
523
    public static MovingObjectPosition getMouseOver(final float yaw, final float pitch, final float range) {
524
        final float partialTicks = mc.timer.renderPartialTicks;
525
        final Entity entity = mc.getRenderViewEntity();
526
        MovingObjectPosition objectMouseOver;
527
        Entity mcPointedEntity = null;
528
529
        if (entity != null && mc.theWorld != null) {
530
531
            mc.mcProfiler.startSection("pick");
532
            final double d0 = mc.playerController.getBlockReachDistance();
533
            objectMouseOver = entity.rayTrace(d0, partialTicks);
534
            double d1 = d0;
535
            final Vec3 vec3 = entity.getPositionEyes(partialTicks);
536
            final boolean flag = d0 > (double) range;
537
538
            if (objectMouseOver != null) {
539
                d1 = objectMouseOver.hitVec.distanceTo(vec3);
540
            }
541
542
            final Vec3 vec31 = mc.thePlayer.getVectorForRotation(pitch, yaw);
543
            final Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
544
            Entity pointedEntity = null;
545
            Vec3 vec33 = null;
546
            final float f = 1.0F;
547
            final List<Entity> list = mc.theWorld.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand(f, f, f), Predicates.and(EntitySelectors.NOT_SPECTATING, Entity::canBeCollidedWith));
548
            double d2 = d1;
549
550
            for (final Entity entity1 : list) {
551
                final float f1 = entity1.getCollisionBorderSize();
552
                final AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1);
553
                final MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
554
555
                if (axisalignedbb.isVecInside(vec3)) {
556
                    if (d2 >= 0.0D) {
557
                        pointedEntity = entity1;
558
                        vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
559
                        d2 = 0.0D;
560
                    }
561
                } else if (movingobjectposition != null) {
562
                    final double d3 = vec3.distanceTo(movingobjectposition.hitVec);
563
564
                    if (d3 < d2 || d2 == 0.0D) {
565
                        pointedEntity = entity1;
566
                        vec33 = movingobjectposition.hitVec;
567
                        d2 = d3;
568
                    }
569
                }
570
            }
571
572
            if (pointedEntity != null && flag && vec3.distanceTo(vec33) > (double) range) {
573
                pointedEntity = null;
574
                objectMouseOver = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS, vec33, null, new BlockPos(vec33));
575
            }
576
577
            if (pointedEntity != null && (d2 < d1 || objectMouseOver == null)) {
578
                objectMouseOver = new MovingObjectPosition(pointedEntity, vec33);
579
580
                if (pointedEntity instanceof EntityLivingBase || pointedEntity instanceof EntityItemFrame) {
581
                    mcPointedEntity = pointedEntity;
582
                }
583
            }
584
585
            mc.mcProfiler.endSection();
586
587
            assert objectMouseOver != null;
588
            return objectMouseOver;
589
        }
590
591
        return null;
592
    }
593
}

What this file does

getBlockRelativeToPlayer (lines 382-384) resolves the block at a fixed offset from the player's position via mc.theWorld.getBlockState - the helper the module uses to classify the block below as air or ladder for its ticksSinceCanSplash gate. The module only reads the (0, -1, 0) offset, so this single method is the module's entire world-sensing surface: it makes the throw gate depend on server-visible terrain rather than the client's motion state. The same utility class backs many Rise modules, but AutoPot consumes only this one probe.

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 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 targets the use-then-switch cadence that auto-pot and auto-tool modules share. The check marks a player in usedSomething on any InteractItemEvent or InteractWorldEvent - the C08 use produces an InteractItemEvent - and the next ItemSwitchEvent compares the tick gap against MIN_SWITCH_TICKS (default 1): a slot change within one tick of a use punishes. Rise's ceremony is engineered around the letter of this check but not its spirit: the switch-back C09 lands one tick after the use tick (the module defers it to the next onPreMotion via switchBack), and the initial C09-to-pot-slot precedes the C08, so no switch follows the use within the same tick - the module stays one tick ahead of the check's window in the common case. The jump variant's 300ms thread and the C06 extra packet do not change the ordering. The counter surface is the pacing: the check's ledger is per-player and permanent, and any hiccup that collapses the ceremony into a single tick - a lag spike that coalesces the C09-C08-C09 into one processed batch, or a server tick that processes the use and the switch-back together - produces the exact same-tick pattern the check punishes. At one throw per 21 ticks the module gives the check few samples, but the pattern it does emit is structurally the one the check exists to see.

anticheat UseItemAdapter (C08 face-255 and release ledger)

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 an item use: handleBlockPlacePacket treats any pre-1.9 face index above 5 - the 255 from the single-stack constructor - as mightUseItem = true, and the throw then drives onItemInteract, which for splash potions returns at the pre-1.9 durability guard without setting itemInUse. The C09 traffic is where the adapter engages: onChangeSlot runs on every held-slot change and, when the previous and new slots differ, calls pData.requestItemUseResync() - forcibly releasing any server-side item-use state. The module's two C09s bracket the C08 in consecutive ticks, so the adapter processes a slot change immediately before and immediately after an item-use claim, the exact sequence its resync path was written for. The release side is the C07: handleDiggingPacket stamps data.releaseItemTime for RELEASE_USE_ITEM and sets data.isHackingRI when two releases arrive within timeBetweenRL (70ms). Rise's single release per throw, spaced at least 20 ticks apart, never trips that window - the release ledger is a no-op against this module's pacing, though it is the same packet class the module chose to unwind its use, so any future tightening of the release interval would land directly on this ceremony.

anticheat PacketListener (C08/C09 inventory feed)

PacketListener.java215 lines · Java
1
package me.vrekt.arc.listener.packet;
2
3
import com.comphenix.packetwrapper.WrapperPlayClientBlockPlace;
4
import com.comphenix.packetwrapper.WrapperPlayClientFlying;
5
import com.comphenix.packetwrapper.WrapperPlayClientHeldItemSlot;
6
import com.comphenix.packetwrapper.WrapperPlayClientPosition;
7
import com.comphenix.packetwrapper.WrapperPlayClientPositionLook;
8
import com.comphenix.packetwrapper.WrapperPlayClientUseEntity;
9
import com.comphenix.protocol.PacketType;
10
import com.comphenix.protocol.ProtocolLibrary;
11
import com.comphenix.protocol.ProtocolManager;
12
import com.comphenix.protocol.events.ListenerPriority;
13
import com.comphenix.protocol.events.PacketAdapter;
14
import com.comphenix.protocol.events.PacketEvent;
15
import com.comphenix.protocol.wrappers.EnumWrappers;
16
import me.vrekt.arc.Arc;
17
import me.vrekt.arc.check.CheckType;
18
import me.vrekt.arc.check.combat.KillAura;
19
import me.vrekt.arc.check.inventory.AutoHeal;
20
import me.vrekt.arc.check.moving.MorePackets;
21
import me.vrekt.arc.data.combat.FightData;
22
import me.vrekt.arc.data.inventory.InventoryData;
23
import me.vrekt.arc.data.moving.MovingData;
24
import me.vrekt.arc.listener.ACheckListener;
25
import org.bukkit.Material;
26
import org.bukkit.entity.Player;
27
import org.bukkit.inventory.ItemStack;
28
import org.bukkit.plugin.Plugin;
29
30
public class PacketListener implements ACheckListener {
31
    private final MorePackets MORE_PACKETS = (MorePackets) Arc.getCheckManager().getCheck(CheckType.MOREPACKETS);
32
    private final KillAura KILL_AURA = (KillAura) Arc.getCheckManager().getCheck(CheckType.KILLAURA);
33
    private final AutoHeal AUTO_HEAL = (AutoHeal) CHECK_MANAGER.getCheck(CheckType.AUTOHEAL);
34
35
    private boolean listening = false;
36
37
    /**
38
     * Stop listening.
39
     */
40
    public void stopListening() {
41
        ProtocolLibrary.getProtocolManager().removePacketListeners(Arc.getPlugin());
42
    }
43
44
    public void startListening(Plugin plugin, ProtocolManager manager) {
45
        listening = true;
46
47
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.FLYING) {
48
            @Override
49
            public void onPacketReceiving(PacketEvent event) {
50
                Player player = event.getPlayer();
51
                MovingData data = MovingData.getData(player);
52
53
                if (data.cancelMovingPackets()) {
54
                    event.setCancelled(true);
55
                }
56
57
                // Update ground info.
58
                WrapperPlayClientFlying flying = new WrapperPlayClientFlying(event.getPacket());
59
                data.setFlyingClientOnGround(flying.getOnGround());
60
61
                // Update packet info.
62
                data.setFlyingPackets(data.getFlyingPackets() + 1);
63
                boolean cancel = updateAndCheck(player, data);
64
                if (cancel) {
65
                    event.setCancelled(true);
66
                }
67
68
            }
69
        });
70
71
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.POSITION,
72
                PacketType.Play.Client.POSITION_LOOK) {
73
            @Override
74
            public void onPacketReceiving(PacketEvent event) {
75
                Player player = event.getPlayer();
76
                MovingData data = MovingData.getData(player);
77
78
                if (data.cancelMovingPackets()) {
79
                    event.setCancelled(true);
80
                }
81
82
                // Update ground info.
83
                if (event.getPacket().getType().equals(PacketType.Play.Client.POSITION)) {
84
                    WrapperPlayClientPosition position = new WrapperPlayClientPosition(event.getPacket());
85
                    data.setPositionClientOnGround(position.getOnGround());
86
                } else {
87
                    WrapperPlayClientPositionLook position = new WrapperPlayClientPositionLook(event.getPacket());
88
                    data.setPositionClientOnGround(position.getOnGround());
89
                }
90
91
                // Update packet info.
92
                data.setPositionPackets(data.getPositionPackets() + 1);
93
                boolean cancel = updateAndCheck(player, data);
94
                if (cancel) {
95
                    event.setCancelled(true);
96
                }
97
            }
98
        });
99
100
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
101
            @Override
102
            public void onPacketReceiving(PacketEvent event) {
103
                Player player = event.getPlayer();
104
                FightData data = FightData.getData(player);
105
                data.setTotalAttacks(data.getTotalAttacks() + 1);
106
107
            }
108
        });
109
110
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.ARM_ANIMATION) {
111
            @Override
112
            public void onPacketReceiving(PacketEvent event) {
113
                Player player = event.getPlayer();
114
                FightData data = FightData.getData(player);
115
                data.setLastArmSwing(System.currentTimeMillis());
116
            }
117
        });
118
119
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.HELD_ITEM_SLOT) {
120
            @Override
121
            public void onPacketReceiving(PacketEvent event) {
122
                Player player = event.getPlayer();
123
                InventoryData data = InventoryData.getData(player);
124
                WrapperPlayClientHeldItemSlot itemSlotChange = new WrapperPlayClientHeldItemSlot(event.getPacket());
125
                int slot = itemSlotChange.getSlot();
126
                ItemStack item = player.getInventory().getItem(slot);
127
                if (item != null && item.getType() == Material.MUSHROOM_SOUP) {
128
                    data.setLastItemSwitch(System.currentTimeMillis());
129
                }
130
131
            }
132
        });
133
134
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.BLOCK_PLACE) {
135
            @Override
136
            public void onPacketReceiving(PacketEvent event) {
137
                Player player = event.getPlayer();
138
                InventoryData data = InventoryData.getData(player);
139
                WrapperPlayClientBlockPlace blockPlace = new WrapperPlayClientBlockPlace(event.getPacket());
140
                ItemStack item = blockPlace.getHeldItem();
141
142
                if (item != null && item.getType() == Material.MUSHROOM_SOUP) {
143
                    AUTO_HEAL.check(data, player);
144
                }
145
            }
146
        });
147
148
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.HIGHEST, PacketType.Play.Client.USE_ENTITY) {
149
            @Override
150
            public void onPacketReceiving(PacketEvent event) {
151
                Player player = event.getPlayer();
152
                FightData data = FightData.getData(player);
153
                WrapperPlayClientUseEntity useEntity = new WrapperPlayClientUseEntity(event.getPacket());
154
                if (useEntity.getType() == EnumWrappers.EntityUseAction.ATTACK) {
155
                    // we attacked, lets update our data and check.
156
                    data.setAttackPackets(data.getAttackPackets() + 1);
157
                    boolean canCheckKillAura = Arc.getCheckManager().canCheckPlayer(player, CheckType.KILLAURA);
158
                    if (canCheckKillAura) {
159
                        boolean failed = KILL_AURA.checkFrequency(data, player);
160
                        if (failed) {
161
                            event.setCancelled(true);
162
                        }
163
                    }
164
                }
165
            }
166
        });
167
168
    }
169
170
    /**
171
     * Checks MorePackets and updates/resets data.
172
     *
173
     * @param player the player
174
     * @param data   the MovingData
175
     * @return true if we should cancel.
176
     */
177
    private boolean updateAndCheck(Player player, MovingData data) {
178
        if (data.getLastPacketUpdate() == 0) {
179
            data.setLastPacketUpdate(System.currentTimeMillis());
180
            return false;
181
        }
182
183
        boolean canCheckMorePackets = Arc.getCheckManager().canCheckPlayer(player, CheckType.MOREPACKETS);
184
185
        // if we cant check reset data and return.
186
        if (!canCheckMorePackets) {
187
            data.setLastPacketUpdate(System.currentTimeMillis());
188
            data.setPositionPackets(0);
189
            data.setFlyingPackets(0);
190
191
            data.setCancelMovingPackets(false);
192
            return false;
193
        }
194
195
        long timeElapsed = System.currentTimeMillis() - data.getLastPacketUpdate();
196
        if (timeElapsed >= 1000) {
197
            data.setCancelMovingPackets(false);
198
            // its been a second lets check.
199
            boolean check = MORE_PACKETS.check(player, data);
200
201
            data.setPositionPackets(0);
202
            data.setFlyingPackets(0);
203
            data.setLastPacketUpdate(System.currentTimeMillis());
204
            return check;
205
        }
206
        return false;
207
    }
208
209
    /**
210
     * @return if we are listening for packets.
211
     */
212
    public boolean isListening() {
213
        return listening;
214
    }
215
}

How it counteracts this module

Arc v2's packet layer carries the C09 and C08 listeners that feed its inventory data. The HELD_ITEM_SLOT adapter (line 119) reads the slot index and, when the newly held item is MUSHROOM_SOUP, stamps InventoryData.lastItemSwitch; the BLOCK_PLACE adapter (line 134) reads the held item from the packet and, for soup, invokes the AutoHeal check. Both are gated on mushroom soup, so Rise's potion throws bypass the checks entirely - the honest gap: Arc v2's auto-heal countermeasures in this snapshot only model soup-based healing clients. What the listeners still observe is the raw pattern: two C09s and one C08 per throw, with the C08's carried stack being an ItemPotion rather than soup, and InventoryData.consumeTime only being stamped by the separate InventoryListener on PlayerInteractEvent. The file matters as the boundary where a potion-aware extension of the soup model would hook in - the C08 handler already unwraps the held item from the packet, so recognising a splash potion there is a one-line change, and the module's three-packet ceremony would then feed a consume-time ledger exactly like the soup path.

anticheat UseItemStatusHandle (use-item classifier)

UseItemStatusHandle.java100 lines · Java
1
package ai.idealistic.spartan.listeners.protocol;
2
3
import ai.idealistic.spartan.Register;
4
import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5
import ai.idealistic.spartan.compatibility.necessary.protocollib.BlockPositionPlib;
6
import ai.idealistic.spartan.compatibility.necessary.protocollib.HandsPlib;
7
import ai.idealistic.spartan.compatibility.necessary.protocollib.MovingBlockPositionsPlib;
8
import ai.idealistic.spartan.compatibility.necessary.protocollib.ProtocolLib;
9
import ai.idealistic.spartan.functionality.concurrent.CheckThread;
10
import ai.idealistic.spartan.functionality.server.Config;
11
import ai.idealistic.spartan.functionality.server.MultiVersion;
12
import ai.idealistic.spartan.functionality.server.PluginBase;
13
import com.comphenix.protocol.PacketType;
14
import com.comphenix.protocol.events.ListenerPriority;
15
import com.comphenix.protocol.events.PacketAdapter;
16
import com.comphenix.protocol.events.PacketContainer;
17
import com.comphenix.protocol.events.PacketEvent;
18
import com.comphenix.protocol.wrappers.BlockPosition;
19
import com.comphenix.protocol.wrappers.EnumWrappers;
20
import org.bukkit.GameMode;
21
import org.bukkit.entity.Player;
22
import org.bukkit.inventory.ItemStack;
23
24
public class UseItemStatusHandle extends PacketAdapter {
25
26
    public UseItemStatusHandle() {
27
        super(Register.plugin, ListenerPriority.NORMAL, resolvePacketTypes());
28
    }
29
30
    @Override
31
    public void onPacketReceiving(PacketEvent event) {
32
        Player player = event.getPlayer();
33
        PlayerProtocol protocol = PluginBase.getProtocol(player);
34
35
        if (!Config.settings.getBoolean("Important.bedrock_on_protocollib")
36
                && protocol.isBedrockPlayer()) {
37
            return;
38
        }
39
        PacketContainer packet = event.getPacket();
40
41
        CheckThread.run(protocol, () -> {
42
            if (packet.getType().equals(PacketType.Play.Client.BLOCK_DIG)) {
43
                protocol.useItemPacket = false;
44
            } else {
45
                BlockPosition blockPosition = new BlockPosition(0, 0, 0);
46
                if (packet.getHands().size() == 0) {
47
                    if (packet.getMovingBlockPositions().size() > 0) {
48
                        blockPosition = MovingBlockPositionsPlib.getSafeMovingBlockPositions(packet, 0).getBlockPosition();
49
                    }
50
                    if (packet.getBlockPositionModifier().size() > 0) {
51
                        blockPosition = BlockPositionPlib.getSafeBlockPosition(packet, 0);
52
                    }
53
                    if (blockPosition.getY() != -1) return;
54
                }
55
                boolean isMainHand = !MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_9)
56
                        || HandsPlib.getSafeHand(event.getPacket(), 0) == EnumWrappers.Hand.MAIN_HAND;
57
                ItemStack itemStack = MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_9)
58
                        ? (isMainHand ? protocol.getInventory().getItemInMainHand()
59
                        : protocol.getInventory().getItemInOffHand()) : player.getItemInHand();
60
                if (packet.getType().toString().contains("USE_ITEM_ON")) {
61
                    if (event.getPacket().getStructures().getValues().toString().contains("Serverbound"))
62
                        return;
63
                }
64
                if (itemStack.getType().toString().contains("SHIELD") ||
65
                        (itemStack.getType().isEdible() && (player.getFoodLevel() != 20
66
                                || itemStack.getType().toString().contains("GOLDEN_APPLE"))
67
                                && !protocol.getGameMode().equals(GameMode.CREATIVE))) {
68
                    protocol.useItemPacket = true;
69
                    protocol.useItemPacketReset =
70
                            !(itemStack.getType().toString().contains("SHIELD") ||
71
                                    itemStack.getType().toString().contains("GOLDEN_APPLE"));
72
                }
73
            }
74
        });
75
    }
76
77
    private static PacketType[] resolvePacketTypes() {
78
        if (MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_17)) {
79
            return new PacketType[]{
80
                    PacketType.Play.Client.USE_ITEM,
81
                    PacketType.Play.Client.BLOCK_DIG
82
            };
83
        } else {
84
            if (ProtocolLib.isPacketSupported("USE_ITEM_ON")) {
85
                return new PacketType[]{
86
                        PacketType.Play.Client.USE_ITEM_ON,
87
                        PacketType.Play.Client.BLOCK_PLACE,
88
                        PacketType.Play.Client.BLOCK_DIG
89
                };
90
            } else {
91
                return new PacketType[]{
92
                        PacketType.Play.Client.BLOCK_PLACE,
93
                        PacketType.Play.Client.BLOCK_DIG
94
                };
95
            }
96
        }
97
    }
98
99
100
}

How it counteracts this module

Spartan's use-item classifier walks every C08/BLOCK_PLACE packet and decides whether it constitutes an item use. The pre-1.9 branch reads the block position and returns immediately for real places (Y != -1); the module's use-form C08 carries ORIGIN (Y == 0), so it reaches the item inspection, which sets protocol.useItemPacket = true only for shields and food (with the golden-apple and food-level carve-outs). A splash potion is neither, so the throw leaves useItemPacket unset. The result is the same classification gap as with Memeware's module: Spartan's status machine never records the potion throw as an item use, and downstream logic keyed on useItemPacket - including the interplay with the C09-based slot handling elsewhere in the protocol layer - does not see the ceremony. The file is the reference point for that boundary: it shows precisely which C08s Spartan treats as use-items, and potion throwing is outside the set, which is why this check cannot counter Rise's AutoPot and why the module's pitch claims and slot churn are the only observable residue.

← Back to Analysis Hub