Memeware 7.3 Player ESP module 2 files, 195 lines

Memeware 7.3 Player ESP: Full Source Analysis

Player ESP is a wall-hack renderer with a single registered event handler.

me/memewaredevs/client/module/render/ESP.java · GitHub source ↗

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

Analysis

Overview

Player ESP is a wall-hack renderer with a single registered event handler. On every Render3DEvent it walks mc.theWorld.loadedEntityList and, for each EntityPlayer other than the local player, calls RenderUtils.drawEsp(o, new Color(0, 0, 0, 21).getRGB()), which draws a 1x2 block axis-aligned box around the entity position (posX plus or minus 0.5, posY to posY + 2.0). The color is hardcoded near-transparent black: the module exposes no settings at all, no color picker, no box mode, no tracer option. It is wire-silent: the handler only reads the client-side entity mirror and issues GL11 calls, so no packet leaves the client and no server-side check can observe it.

Render path

The module is one Consumer<Render3DEvent> registered with the client event bus. Each fired event loops the loaded entity list, skips the local player and anything that is not an EntityPlayer, and renders the survivors with a fixed translucent color. drawEsp forwards to RenderUtils.box with the color object, and the surrounding enableGL2D and disableGL2D helpers configure GL11 blending (source 770, destination 771), line smoothing and depth state for the frame. There are no settings: the constructor registers only the keybind 0 and the render category.

Data source

The rendered state is the client's mirror of server broadcasts. S0C spawn-player packets create the EntityPlayer entries with position and rotation, and the entity-move and teleport packets (S14 family, S18) keep those entries current; the module draws each frame from that live state, so a player's current position is outlined regardless of occlusion. S0F spawn-mob packets populate non-player entries that the instanceof EntityPlayer filter discards, so the renderer is players-only by construction. The 1x2 box spans the standing entity bounds, posX plus or minus 0.5 to posY + 2.0.

Wire behavior

The module produces no network traffic of its own and changes no server-visible state. It cannot be inferred from the outside because the GL11 calls never leave the client, and the entity list it reads is data every vanilla client also receives and renders. The honest conclusion is that no server-side anticheat mechanism can detect this module; the countering entries below therefore describe the checks that police the data stream it consumes and the aim behavior it typically enables, each with the boundary stated explicitly.

source ESP.java (module)

ESP.java29 lines · JavaOriginal ↗
1
2
package me.memewaredevs.client.module.render;
3
4
import me.hippo.api.lwjeb.annotation.Handler;
5
import me.memewaredevs.client.event.events.Render3DEvent;
6
import me.memewaredevs.client.module.Module;
7
import me.memewaredevs.client.util.render.RenderUtils;
8
import net.minecraft.entity.Entity;
9
import net.minecraft.entity.player.EntityPlayer;
10
11
import java.awt.*;
12
import java.util.function.Consumer;
13
14
public class ESP extends Module {
15
    public ESP() {
16
        super("Player ESP", 0, Module.Category.RENDER);
17
    }
18
19
    @Handler
20
    public Consumer<Render3DEvent> onEvent = (event) -> {
21
        for (final Entity o : this.mc.theWorld.loadedEntityList) {
22
            if (o == this.mc.thePlayer || !(o instanceof EntityPlayer)) {
23
                continue;
24
            }
25
            RenderUtils.drawEsp(o, new Color(0, 0, 0, 21).getRGB());
26
        }
27
    };
28
29
}

What this file does

The module is the onEvent field, a Consumer<Render3DEvent> that walks mc.theWorld.loadedEntityList, filters to EntityPlayer instances other than the local player, and renders each with RenderUtils.drawEsp(o, new Color(0, 0, 0, 21).getRGB()). The fixed color and the absence of any settings are the defining traits: the constructor takes only the display name, keybind 0 and the RENDER category, so there is no configurable surface at all.

source RenderUtils.java (drawEsp renderer)

RenderUtils.java166 lines · JavaOriginal ↗
1
/*
2
 * Decompiled with CFR 0.145.
3
 *
4
 * Could not load the following classes:
5
 *  org.lwjgl.opengl.GL11
6
 */
7
package me.memewaredevs.client.util.render;
8
9
import net.minecraft.client.renderer.RenderGlobal;
10
import net.minecraft.client.renderer.Tessellator;
11
import net.minecraft.client.renderer.WorldRenderer;
12
import net.minecraft.client.renderer.entity.RenderManager;
13
import net.minecraft.entity.Entity;
14
import net.minecraft.tileentity.TileEntity;
15
import net.minecraft.util.AxisAlignedBB;
16
import org.lwjgl.opengl.GL11;
17
18
import java.awt.*;
19
20
public class RenderUtils {
21
22
    public static void box(double x, double y2, double z, double x2, double y22, double z2, final Color color) {
23
        GL11.glBlendFunc(770, 771);
24
        GL11.glEnable(3042);
25
        GL11.glLineWidth(2.0f);
26
        GL11.glDisable(3553);
27
        GL11.glDisable(2929);
28
        GL11.glDepthMask(false);
29
        final double n = x;
30
31
        final double x3 = x = n - RenderManager.renderPosX;
32
        final double n2 = y2;
33
34
        final double y3 = y2 = n2 - RenderManager.renderPosY;
35
        final double n3 = z;
36
37
        final double z3 = z = n3 - RenderManager.renderPosZ;
38
        final double n4 = x2;
39
40
        final double x4 = x2 = n4 - RenderManager.renderPosX;
41
        final double n5 = y22;
42
43
        final double y4 = y22 = n5 - RenderManager.renderPosY;
44
        final double n6 = z2;
45
46
        GL11.glColor4d(0.0, 0.0, 0.0, 0.2);
47
        z2 = n6 - RenderManager.renderPosZ;
48
        RenderUtils.drawColorBox(new AxisAlignedBB(x3, y3, z3, x4, y4, z2));
49
        RenderGlobal.drawOutlinedBoundingBox(new AxisAlignedBB(x, y2, z, x2, y22, z2), color.getRGB());
50
        GL11.glColor4d(0.0, 0.0, 0.0, 0.2);
51
        GL11.glEnable(3553);
52
        GL11.glEnable(2929);
53
        GL11.glDepthMask(true);
54
        GL11.glDisable(3042);
55
    }
56
57
    public static void drawColorBox(final AxisAlignedBB axisalignedbb) {
58
        final Tessellator ts = Tessellator.getInstance();
59
        final WorldRenderer wr = ts.getWorldRenderer();
60
        wr.startDrawingQuads();
61
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
62
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
63
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
64
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
65
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
66
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
67
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
68
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
69
        ts.draw();
70
        wr.startDrawingQuads();
71
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
72
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
73
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
74
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
75
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
76
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
77
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
78
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
79
        ts.draw();
80
        wr.startDrawingQuads();
81
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
82
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
83
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
84
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
85
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
86
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
87
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
88
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
89
        ts.draw();
90
        wr.startDrawingQuads();
91
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
92
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
93
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
94
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
95
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
96
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
97
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
98
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
99
        ts.draw();
100
        wr.startDrawingQuads();
101
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
102
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
103
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
104
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
105
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
106
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
107
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
108
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
109
        ts.draw();
110
        wr.startDrawingQuads();
111
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.maxZ);
112
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.maxZ);
113
        wr.addVertex(axisalignedbb.minX, axisalignedbb.maxY, axisalignedbb.minZ);
114
        wr.addVertex(axisalignedbb.minX, axisalignedbb.minY, axisalignedbb.minZ);
115
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.minZ);
116
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.minZ);
117
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.maxY, axisalignedbb.maxZ);
118
        wr.addVertex(axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
119
        ts.draw();
120
    }
121
122
    public static void drawGradientRect(final float x, final float y2, final float x1, final float y1,
123
                                        final int topColor, final int bottomColor) {
124
        RenderUtils.enableGL2D();
125
        GL11.glShadeModel(7425);
126
        GL11.glBegin(7);
127
        ColorUtils.glColor(topColor);
128
        GL11.glVertex2f(x, y1);
129
        GL11.glVertex2f(x1, y1);
130
        ColorUtils.glColor(bottomColor);
131
        GL11.glVertex2f(x1, y2);
132
        GL11.glVertex2f(x, y2);
133
        GL11.glEnd();
134
        GL11.glShadeModel(7425);
135
        RenderUtils.disableGL2D();
136
    }
137
138
    public static void enableGL2D() {
139
        GL11.glDisable(2929);
140
        GL11.glEnable(3042);
141
        GL11.glDisable(3553);
142
        GL11.glBlendFunc(770, 771);
143
        GL11.glDepthMask(true);
144
        GL11.glEnable(2848);
145
        GL11.glHint(3154, 4354);
146
        GL11.glHint(3155, 4354);
147
    }
148
149
    public static void disableGL2D() {
150
        GL11.glEnable(3553);
151
        GL11.glDisable(3042);
152
        GL11.glEnable(2929);
153
        GL11.glDisable(2848);
154
        GL11.glHint(3154, 4352);
155
        GL11.glHint(3155, 4352);
156
    }
157
158
    public static void drawEsp(final Entity o, final int c2) {
159
        RenderUtils.box(o.posX - 0.5, o.posY, o.posZ - 0.5, o.posX + 0.5, o.posY + 2.0, o.posZ + 0.5, new Color(c2));
160
    }
161
    public static void drawEsp(final TileEntity o, final int c2) {
162
        RenderUtils.box(o.getPos().getX() + 1, o.getPos().getY(),
163
                o.getPos().getZ() + 1, o.getPos().getX(),
164
                o.getPos().getY() + 1.0, o.getPos().getZ(), new Color(c2));
165
    }
166
}

What this file does

RenderUtils provides the drawEsp overloads and the GL11 state helpers the module relies on. drawEsp(Entity) calls box(o.posX - 0.5, o.posY, o.posZ - 0.5, o.posX + 0.5, o.posY + 2.0, o.posZ + 0.5, new Color(c2)), a 1x2 block axis-aligned box at the entity's current position, and the enableGL2D and disableGL2D helpers wrap the frame with blend, depth-mask and line-smoothing state. The whole module effect is one call into this class, which is why the file is the natural companion for the full-source page.

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 Grim PacketEntityReplication (entity state handler)

PacketEntityReplication.java627 lines · Java
1
package ac.grim.grimac.events.packets;
2
3
import ac.grim.grimac.GrimAPI;
4
import ac.grim.grimac.api.config.ConfigManager;
5
import ac.grim.grimac.checks.Check;
6
import ac.grim.grimac.checks.type.PacketReceiveListener;
7
import ac.grim.grimac.checks.type.PacketSendListener;
8
import ac.grim.grimac.player.GrimPlayer;
9
import ac.grim.grimac.utils.anticheat.LogUtil;
10
import ac.grim.grimac.utils.data.SprintingState;
11
import ac.grim.grimac.utils.data.TrackerData;
12
import ac.grim.grimac.utils.data.packetentity.DashableEntity;
13
import ac.grim.grimac.utils.data.packetentity.PacketEntity;
14
import ac.grim.grimac.utils.data.packetentity.PacketEntityHook;
15
import ac.grim.grimac.utils.data.packetentity.PacketEntityTrackXRot;
16
import ac.grim.grimac.utils.enums.Pose;
17
import ac.grim.grimac.utils.nmsutil.EntityMetadataPoseUtil;
18
import ac.grim.grimac.utils.viaversion.ViaVersionUtil;
19
import com.github.retrooper.packetevents.PacketEvents;
20
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
21
import com.github.retrooper.packetevents.event.PacketSendEvent;
22
import com.github.retrooper.packetevents.manager.server.ServerVersion;
23
import com.github.retrooper.packetevents.protocol.entity.EntityPositionData;
24
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
25
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
26
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
27
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
28
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
29
import com.github.retrooper.packetevents.protocol.player.InteractionHand;
30
import com.github.retrooper.packetevents.protocol.player.UserProfile;
31
import com.github.retrooper.packetevents.protocol.potion.PotionType;
32
import com.github.retrooper.packetevents.util.Vector3d;
33
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerAttachEntity;
34
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities;
35
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityEffect;
36
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityEquipment;
37
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
38
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityPositionSync;
39
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRelativeMove;
40
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRelativeMoveAndRotation;
41
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRotation;
42
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityStatus;
43
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityTeleport;
44
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfo;
45
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoRemove;
46
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoUpdate;
47
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerRemoveEntityEffect;
48
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSetPassengers;
49
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSetSlot;
50
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
51
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnLivingEntity;
52
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnPainting;
53
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnPlayer;
54
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerUpdateAttributes;
55
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerWindowItems;
56
import org.jetbrains.annotations.NotNull;
57
58
import java.util.ArrayList;
59
import java.util.List;
60
import java.util.UUID;
61
import java.util.concurrent.atomic.AtomicBoolean;
62
63
public class PacketEntityReplication extends Check implements PacketReceiveListener, PacketSendListener {
64
65
    private final AtomicBoolean hasSentPreWavePacket = new AtomicBoolean(true);
66
67
    // Let's imagine the player is on a boat.
68
    // The player breaks this boat
69
    // If we were to despawn the boat without an extra transaction, then the boat would disappear before
70
    // it disappeared on the client side, creating a ghost boat to flag checks with
71
    //
72
    // If we were to despawn the tick after, spawning must occur the transaction before to stop the same exact
73
    // problem with ghost boats in reverse.
74
    //
75
    // Therefore, we despawn the transaction after, and spawn the tick before.
76
    //
77
    // If we despawn then spawn an entity in the same transaction, then this solution would despawn the new entity
78
    // instead of the old entity, so we wouldn't see the boat at all
79
    //
80
    // Therefore, if the server sends a despawn and then a spawn in the same transaction for the same entity,
81
    // We should simply add a transaction (which will clear this list!)
82
    //
83
    // Another valid solution is to simply spam more transactions, but let's not waste bandwidth.
84
    private final List<Integer> despawnedEntitiesThisTransaction = new ArrayList<>();
85
86
    // Maximum ping when a firework boost is removed from the player.
87
    private int maxFireworkBoostPing = 1000;
88
89
    public PacketEntityReplication(GrimPlayer player) {
90
        super(player);
91
    }
92
93
    @Override
94
    public void onPacketReceive(PacketReceiveEvent event) {
95
        // Teleports don't interpolate, duplicate 1.17 packets don't interpolate
96
        if (!isTickPacket(event.getPacketType())) return;
97
        player.compensatedEntities.entitiesRemovedThisTick.clear();
98
        boolean isTickingReliably = player.isTickingReliablyFor(3);
99
100
        PacketEntity playerVehicle = player.compensatedEntities.self.getRiding();
101
        for (PacketEntity entity : player.compensatedEntities.entityMap.values()) {
102
            if (entity == playerVehicle && !player.vehicleData.lastDummy) {
103
                // The player has this as their vehicle, so they aren't interpolating it.
104
                // And it isn't a dummy position
105
                entity.setPositionRaw(player, entity.getPossibleLocationBoxes());
106
            } else {
107
                entity.onMovement(isTickingReliably);
108
            }
109
        }
110
111
        if (player.vehicleData.camelSprintingState == SprintingState.STOPPING) {
112
            player.vehicleData.camelSprintingState = SprintingState.STOPPED;
113
        } else if (player.vehicleData.camelSprintingState == SprintingState.STOPPED && player.isSprinting) { // For sprint desyncs
114
            player.vehicleData.camelSprintingState = SprintingState.STARTED;
115
        }
116
    }
117
118
    @Override
119
    public void onPacketSend(PacketSendEvent event) {
120
        // ensure grim is the one that sent the transaction
121
        if ((event.getPacketType() == PacketType.Play.Server.PING || event.getPacketType() == PacketType.Play.Server.WINDOW_CONFIRMATION) && player.packetStateData.lastServerTransWasValid) {
122
            despawnedEntitiesThisTransaction.clear();
123
        } else if (event.getPacketType() == PacketType.Play.Server.SPAWN_LIVING_ENTITY) {
124
            WrapperPlayServerSpawnLivingEntity packetOutEntity = new WrapperPlayServerSpawnLivingEntity(event);
125
            addEntity(packetOutEntity.getEntityId(), packetOutEntity.getEntityUUID(), packetOutEntity.getEntityType(), packetOutEntity.getPosition(), packetOutEntity.getYaw(), packetOutEntity.getPitch(), packetOutEntity.getEntityMetadata(), 0);
126
        } else if (event.getPacketType() == PacketType.Play.Server.SPAWN_ENTITY) {
127
            WrapperPlayServerSpawnEntity packetOutEntity = new WrapperPlayServerSpawnEntity(event);
128
            addEntity(packetOutEntity.getEntityId(), packetOutEntity.getUUID().orElse(null), packetOutEntity.getEntityType(), packetOutEntity.getPosition(), packetOutEntity.getYaw(), packetOutEntity.getPitch(), null, packetOutEntity.getData());
129
        } else if (event.getPacketType() == PacketType.Play.Server.SPAWN_PLAYER) {
130
            WrapperPlayServerSpawnPlayer packetOutEntity = new WrapperPlayServerSpawnPlayer(event);
131
            addEntity(packetOutEntity.getEntityId(), packetOutEntity.getUUID(), EntityTypes.PLAYER, packetOutEntity.getPosition(), packetOutEntity.getYaw(), packetOutEntity.getPitch(), packetOutEntity.getEntityMetadata(), 0);
132
        } else if (event.getPacketType() == PacketType.Play.Server.SPAWN_PAINTING) {
133
            WrapperPlayServerSpawnPainting packetOutEntity = new WrapperPlayServerSpawnPainting(event);
134
            addEntity(packetOutEntity.getEntityId(), packetOutEntity.getUUID(), EntityTypes.PAINTING, packetOutEntity.getPosition().toVector3d(), 0, 0f, null, packetOutEntity.getDirection().getHorizontalIndex());
135
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_RELATIVE_MOVE) {
136
            WrapperPlayServerEntityRelativeMove move = new WrapperPlayServerEntityRelativeMove(event);
137
            handleMoveEntity(event, move.getEntityId(), move.getDeltaX(), move.getDeltaY(), move.getDeltaZ(), null, null, true, true);
138
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_RELATIVE_MOVE_AND_ROTATION) {
139
            WrapperPlayServerEntityRelativeMoveAndRotation move = new WrapperPlayServerEntityRelativeMoveAndRotation(event);
140
            handleMoveEntity(event, move.getEntityId(), move.getDeltaX(), move.getDeltaY(), move.getDeltaZ(), move.getYaw() * 0.7111111F, move.getPitch() * 0.7111111F, true, true);
141
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_TELEPORT) {
142
            WrapperPlayServerEntityTeleport move = new WrapperPlayServerEntityTeleport(event);
143
            Vector3d pos = move.getPosition();
144
            handleMoveEntity(event, move.getEntityId(), pos.getX(), pos.getY(), pos.getZ(), move.getYaw(), move.getPitch(), false, true);
145
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_POSITION_SYNC) {
146
            // ENTITY_TELEPORT but without relative flags
147
            WrapperPlayServerEntityPositionSync move = new WrapperPlayServerEntityPositionSync(event);
148
            final EntityPositionData values = move.getValues();
149
            final Vector3d pos = values.getPosition();
150
            // TODO this isn't technically correct
151
            // If the position sync is to a pos > 4096 from the entity pos, client does some special stuff without interpolation
152
            handleMoveEntity(event, move.getId(), pos.getX(), pos.getY(), pos.getZ(), values.getYaw(), values.getPitch(), false, true);
153
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_ROTATION) { // Affects interpolation
154
            WrapperPlayServerEntityRotation move = new WrapperPlayServerEntityRotation(event);
155
            handleMoveEntity(event, move.getEntityId(), 0, 0, 0, move.getYaw() * 0.7111111F, move.getPitch() * 0.7111111F, true, false);
156
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) {
157
            WrapperPlayServerEntityMetadata entityMetadata = new WrapperPlayServerEntityMetadata(event);
158
            schedulePoseTransition(entityMetadata, event);
159
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedEntities.updateEntityMetadata(entityMetadata.getEntityId(), entityMetadata.getEntityMetadata()));
160
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_EQUIPMENT) {
161
            WrapperPlayServerEntityEquipment equipment = new WrapperPlayServerEntityEquipment(event);
162
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.compensatedEntities.updateEntityEquipment(equipment.getEntityId(), equipment.getEquipment()));
163
        }
164
165
        // 1.19.3+
166
        else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_UPDATE) {
167
            WrapperPlayServerPlayerInfoUpdate info = new WrapperPlayServerPlayerInfoUpdate(event);
168
            if (info.getActions().contains(WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER)) {
169
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
170
                    for (WrapperPlayServerPlayerInfoUpdate.PlayerInfo entry : info.getEntries()) {
171
                        final UserProfile gameProfile = entry.getGameProfile();
172
                        final UUID uuid = gameProfile.getUUID();
173
                        player.compensatedEntities.profiles.put(uuid, gameProfile);
174
                    }
175
                });
176
            }
177
        } else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO_REMOVE) {
178
            WrapperPlayServerPlayerInfoRemove remove = new WrapperPlayServerPlayerInfoRemove(event);
179
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> remove.getProfileIds().forEach(player.compensatedEntities.profiles::remove));
180
        } else if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) {
181
            WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo(event);
182
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
183
                if (info.getAction() == WrapperPlayServerPlayerInfo.Action.ADD_PLAYER) {
184
                    for (WrapperPlayServerPlayerInfo.PlayerData entry : info.getPlayerDataList()) {
185
                        final UserProfile gameProfile = entry.getUserProfile();
186
                        final UUID uuid = gameProfile.getUUID();
187
                        player.compensatedEntities.profiles.put(uuid, gameProfile);
188
                    }
189
                } else if (info.getAction() == WrapperPlayServerPlayerInfo.Action.REMOVE_PLAYER) {
190
                    info.getPlayerDataList().forEach(profile -> player.compensatedEntities.profiles.remove(profile.getUserProfile().getUUID()));
191
                }
192
            });
193
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_EFFECT) {
194
            WrapperPlayServerEntityEffect effect = new WrapperPlayServerEntityEffect(event);
195
196
            PotionType type = effect.getPotionType();
197
198
            // ViaVersion tries faking levitation effects and fails badly lol, flagging the anticheat
199
            // Block other effects just in case ViaVersion gets any ideas
200
            //
201
            // Set to 24 so ViaVersion blocks it
202
            // 24 is the levitation effect
203
            if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && ViaVersionUtil.isAvailable && type.getId(player.getClientVersion()) > 23) {
204
                event.setCancelled(true);
205
                return;
206
            }
207
208
            // ViaVersion dolphin's grace also messes us up, set it to a potion effect that doesn't exist on 1.12
209
            // Effect 31 is bad omen
210
            if (player.getClientVersion().isOlderThan(ClientVersion.V_1_13) && ViaVersionUtil.isAvailable && type.getId(player.getClientVersion()) == 30) {
211
                event.setCancelled(true);
212
                return;
213
            }
214
215
            if (isDirectlyAffectingPlayer(player, effect.getEntityId())) player.sendTransaction();
216
217
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
218
                PacketEntity entity = player.compensatedEntities.getEntity(effect.getEntityId());
219
                if (entity == null) return;
220
221
                entity.addPotionEffect(type, effect.getEffectAmplifier());
222
            });
223
        } else if (event.getPacketType() == PacketType.Play.Server.REMOVE_ENTITY_EFFECT) {
224
            WrapperPlayServerRemoveEntityEffect effect = new WrapperPlayServerRemoveEntityEffect(event);
225
226
            if (isDirectlyAffectingPlayer(player, effect.getEntityId())) player.sendTransaction();
227
228
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
229
                PacketEntity entity = player.compensatedEntities.getEntity(effect.getEntityId());
230
                if (entity == null) return;
231
232
                entity.removePotionEffect(effect.getPotionType());
233
            });
234
        } else if (event.getPacketType() == PacketType.Play.Server.UPDATE_ATTRIBUTES) {
235
            WrapperPlayServerUpdateAttributes attributes = new WrapperPlayServerUpdateAttributes(event);
236
237
            int entityID = attributes.getEntityId();
238
239
            // The attributes for this entity is active, currently
240
            if (isDirectlyAffectingPlayer(player, entityID)) player.sendTransaction();
241
242
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(),
243
                    () -> player.compensatedEntities.updateAttributes(entityID, attributes.getProperties()));
244
        } else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
245
            WrapperPlayServerEntityStatus status = new WrapperPlayServerEntityStatus(event);
246
            // This hasn't changed from 1.7.2 to 1.17
247
            // Needed to exempt players on dead vehicles, as dead entities have strange physics.
248
            if (status.getStatus() == 3) {
249
                PacketEntity entity = player.compensatedEntities.getEntity(status.getEntityId());
250
251
                if (entity == null) return;
252
                entity.isDead = true;
253
            }
254
255
            if (status.getStatus() == 9) {
256
                if (status.getEntityId() != player.entityID) return;
257
258
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.packetStateData.setSlowedByUsingItem(false));
259
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> player.packetStateData.setSlowedByUsingItem(false));
260
            }
261
262
            if (status.getStatus() == 31) {
263
                PacketEntity hook = player.compensatedEntities.getEntity(status.getEntityId());
264
                if (!(hook instanceof PacketEntityHook hookEntity)) return;
265
266
                if (hookEntity.attached == player.entityID) {
267
                    player.sendTransaction();
268
                    // We don't transaction sandwich this, it's too rare to be a real problem.
269
                    player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.uncertaintyHandler.fishingRodPulls.add(hookEntity.owner));
270
                }
271
            }
272
273
            if (status.getStatus() >= 24 && status.getStatus() <= 28 && status.getEntityId() == player.entityID) {
274
                player.compensatedEntities.self.opLevel = status.getStatus() - 24;
275
            }
276
        } else if (event.getPacketType() == PacketType.Play.Server.SET_SLOT) {
277
            WrapperPlayServerSetSlot slot = new WrapperPlayServerSetSlot(event);
278
279
            if (slot.getWindowId() == 0) {
280
                Runnable task = () -> {
281
                    if (slot.getSlot() - 36 == player.packetStateData.lastSlotSelected && (
282
                            !player.inventory.getHeldItem().is(slot.getItem().getType()) || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)
283
                    ) || slot.getSlot() == 45 && !player.inventory.getOffHand().is(slot.getItem().getType())) {
284
                        InteractionHand hand = slot.getSlot() == 45 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
285
                        if (hand == player.packetStateData.itemInUseHand) {
286
                            player.packetStateData.setSlowedByUsingItem(false);
287
                        }
288
289
                        if (player.isResetItemUsageOnItemUpdate() && hand == GrimAPI.INSTANCE.getItemResetHandler().getItemUsageHand(player.platformPlayer)) {
290
                            GrimAPI.INSTANCE.getItemResetHandler().resetItemUsage(player.platformPlayer);
291
                        }
292
                    }
293
                };
294
295
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), task);
296
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, task);
297
            }
298
        } else if (event.getPacketType() == PacketType.Play.Server.WINDOW_ITEMS) {
299
            WrapperPlayServerWindowItems items = new WrapperPlayServerWindowItems(event);
300
301
            if (items.getWindowId() == 0) { // Player inventory
302
                Runnable task = () -> {
303
                    if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
304
                        player.packetStateData.setSlowedByUsingItem(false);
305
                        if (player.isResetItemUsageOnItemUpdate()) {
306
                            GrimAPI.INSTANCE.getItemResetHandler().resetItemUsage(player.platformPlayer);
307
                        }
308
                    } else {
309
                        if (items.getItems().size() > 45 && !player.inventory.getOffHand().is(items.getItems().get(45).getType())) {
310
                            if (player.packetStateData.itemInUseHand == InteractionHand.OFF_HAND) {
311
                                player.packetStateData.setSlowedByUsingItem(false);
312
                            }
313
314
                            if (player.isResetItemUsageOnItemUpdate() && GrimAPI.INSTANCE.getItemResetHandler().getItemUsageHand(player.platformPlayer) == InteractionHand.OFF_HAND) {
315
                                GrimAPI.INSTANCE.getItemResetHandler().resetItemUsage(player.platformPlayer);
316
                            }
317
                        }
318
319
                        if (!player.inventory.getHeldItem().is(items.getItems().get(player.packetStateData.lastSlotSelected + 36).getType())) {
320
                            if (player.packetStateData.itemInUseHand == InteractionHand.MAIN_HAND) {
321
                                player.packetStateData.setSlowedByUsingItem(false);
322
                            }
323
324
                            if (player.isResetItemUsageOnItemUpdate() && GrimAPI.INSTANCE.getItemResetHandler().getItemUsageHand(player.platformPlayer) == InteractionHand.MAIN_HAND) {
325
                                GrimAPI.INSTANCE.getItemResetHandler().resetItemUsage(player.platformPlayer);
326
                            }
327
                        }
328
                    }
329
                };
330
331
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), task);
332
                player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, task);
333
            }
334
        }
335
336
        // 1.8 clients fail to send the RELEASE_USE_ITEM packet when a window is opened client sided while using an item
337
        else if (event.getPacketType() == PacketType.Play.Server.OPEN_WINDOW) {
338
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.packetStateData.setSlowedByUsingItem(false));
339
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> player.packetStateData.setSlowedByUsingItem(false));
340
        } else if (event.getPacketType() == PacketType.Play.Server.OPEN_HORSE_WINDOW) {
341
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> player.packetStateData.setSlowedByUsingItem(false));
342
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get() + 1, () -> player.packetStateData.setSlowedByUsingItem(false));
343
        } else if (event.getPacketType() == PacketType.Play.Server.SET_PASSENGERS) {
344
            WrapperPlayServerSetPassengers mount = new WrapperPlayServerSetPassengers(event);
345
346
            int vehicleID = mount.getEntityId();
347
            int[] passengers = mount.getPassengers();
348
349
            handleMountVehicle(event, vehicleID, passengers);
350
        } else if (event.getPacketType() == PacketType.Play.Server.ATTACH_ENTITY) {
351
            WrapperPlayServerAttachEntity attach = new WrapperPlayServerAttachEntity(event);
352
353
            // This packet was replaced by the mount packet on 1.9+ servers - to support multiple passengers on one vehicle
354
            if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9))
355
                return;
356
357
            // If this is mounting rather than leashing
358
            if (!attach.isLeash()) {
359
                // Alright, let's convert this to the 1.9+ format to make it easier for grim
360
                int vehicleID = attach.getHoldingId();
361
                int attachID = attach.getAttachedId();
362
                TrackerData trackerData = player.compensatedEntities.getTrackedEntity(attachID);
363
364
                if (trackerData != null) {
365
                    // 1.8 sends a vehicle ID of -1 to dismount the entity from its vehicle
366
                    // This is opposite of the 1.9+ format, which sends the vehicle ID and then an empty array.
367
                    if (vehicleID == -1) { // Dismounting
368
                        vehicleID = trackerData.getLegacyPointEightMountedUpon();
369
                        handleMountVehicle(event, vehicleID, new int[]{}); // The vehicle is empty
370
                    } else { // Mounting
371
                        trackerData.setLegacyPointEightMountedUpon(vehicleID);
372
                        handleMountVehicle(event, vehicleID, new int[]{attachID});
373
                    }
374
                } else {
375
                    // I don't think we can recover from this... warn and move on as this shouldn't happen.
376
                    LogUtil.warn("Server sent an invalid attach entity packet for entity " + attach.getHoldingId() + " with passenger " + attach.getAttachedId() + "! The client ignores this.");
377
                }
378
            }
379
        } else if (event.getPacketType() == PacketType.Play.Server.DESTROY_ENTITIES) {
380
            WrapperPlayServerDestroyEntities destroy = new WrapperPlayServerDestroyEntities(event);
381
382
            int[] destroyEntityIds = destroy.getEntityIds();
383
384
            for (int entityID : destroyEntityIds) {
385
                despawnedEntitiesThisTransaction.add(entityID);
386
                player.compensatedEntities.serverPositionsMap.remove(entityID);
387
                // Remove the tracked vehicle (handling tracking knockback) if despawned
388
                if (player.compensatedEntities.serverPlayerVehicle != null && player.compensatedEntities.serverPlayerVehicle == entityID) {
389
                    player.compensatedEntities.serverPlayerVehicle = null;
390
                }
391
            }
392
393
            final int destroyTransaction = player.lastTransactionSent.get() + 1;
394
            player.latencyUtils.addRealTimeTask(destroyTransaction, () -> {
395
                for (int entityId : destroyEntityIds) {
396
                    player.compensatedEntities.removeEntity(entityId);
397
                    player.dashableEntities.removeEntity(entityId);
398
                    player.fireworks.removeFirework(entityId);
399
                    player.compensatedEntities.entitiesRemovedThisTick.add(entityId);
400
                }
401
            });
402
403
            // Don't let the player freeze transactions to keep the firework boost velocity + uncertainty
404
            // Also generally prevents people with high ping gaining too high an advantage in firework use
405
            if (maxFireworkBoostPing > 0) {
406
                player.runNettyTaskInMs(() -> {
407
                    if (player.lastTransactionReceived.get() >= destroyTransaction) return;
408
                    for (int entityID : destroyEntityIds) {
409
                        // If the player has a firework boosting them, setback
410
                        if (player.fireworks.hasFirework(entityID)) {
411
                            player.getSetbackTeleportUtil().executeViolationSetback();
412
                            break;
413
                        }
414
                    }
415
                }, maxFireworkBoostPing);
416
            }
417
        }
418
    }
419
420
    private void handleMountVehicle(PacketSendEvent event, int vehicleID, int[] passengers) {
421
        boolean wasInVehicle = player.compensatedEntities.serverPlayerVehicle != null && player.compensatedEntities.serverPlayerVehicle == vehicleID;
422
        boolean inThisVehicle = false;
423
424
        for (int passenger : passengers) {
425
            inThisVehicle = passenger == player.entityID;
426
            if (inThisVehicle) break;
427
        }
428
429
        if (inThisVehicle && !wasInVehicle) {
430
            player.handleMountVehicle(vehicleID);
431
        }
432
433
        if (!inThisVehicle && wasInVehicle) {
434
            player.handleDismountVehicle(event);
435
        }
436
        // Better lag compensation if we were affected by this
437
        if (wasInVehicle || inThisVehicle) {
438
            player.sendTransaction();
439
        }
440
        player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
441
            PacketEntity vehicle = player.compensatedEntities.getEntity(vehicleID);
442
443
            // Vanilla likes sending null vehicles, so we must ignore those like the client ignores them
444
            if (vehicle == null) return;
445
446
            // Eject existing passengers for this vehicle
447
            for (PacketEntity passenger : new ArrayList<>(vehicle.passengers)) {
448
                passenger.eject();
449
            }
450
451
            // Add the entities as vehicles
452
            for (int entityID : passengers) {
453
                PacketEntity passenger = player.compensatedEntities.getEntity(entityID);
454
                if (passenger == null) continue;
455
                passenger.mount(vehicle);
456
            }
457
        });
458
    }
459
460
    private void handleMoveEntity(PacketSendEvent event, int entityId, double deltaX, double deltaY, double deltaZ, Float yaw, Float pitch, boolean isRelative, boolean hasPos) {
461
        TrackerData data = player.compensatedEntities.getTrackedEntity(entityId);
462
463
        final boolean didNotSendPreWave = hasSentPreWavePacket.compareAndSet(false, true);
464
        if (didNotSendPreWave) player.sendTransaction();
465
466
        if (data != null) {
467
            // Update the tracked server's entity position
468
            if (isRelative) {
469
                // There is a bug where vehicles may start flying due to mojang setting packet position on the client
470
                // (Works at 0 ping but causes funny bugs at any higher ping)
471
                // As we don't want vehicles to fly, we need to replace it with a teleport if it is player vehicle
472
                //
473
                // Don't bother with client controlled vehicles though
474
                boolean vanillaVehicleFlight = player.compensatedEntities.serverPlayerVehicle != null
475
                        && player.compensatedEntities.serverPlayerVehicle == entityId
476
                        && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9)
477
                        // TODO: https://discord.com/channels/721686193061888071/721686193515003966/1310659538831020123
478
                        // Why does the server now send an entity rel move packet matching the player's vehicle movement every time?
479
                        && PacketEvents.getAPI().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_21_2)
480
                        && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9);
481
482
                // ViaVersion sends two relative packets when moving more than 4 blocks
483
                // This is broken and causes the client to interpolate like (0, 4) and (1, 3) instead of (1, 7)
484
                // This causes impossible hits, so grim must replace this with a teleport entity packet
485
                // Not ideal, but neither is 1.8 players on a 1.9+ server.
486
                if (vanillaVehicleFlight ||
487
                        ((Math.abs(deltaX) >= 3.9375 || Math.abs(deltaY) >= 3.9375 || Math.abs(deltaZ) >= 3.9375) && player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9))) {
488
                    player.user.writePacket(new WrapperPlayServerEntityTeleport(entityId, new Vector3d(data.getX() + deltaX, data.getY() + deltaY, data.getZ() + deltaZ), yaw == null ? data.getXRot() : yaw, pitch == null ? data.getYRot() : pitch, false));
489
                    event.setCancelled(true);
490
                    return;
491
                }
492
493
                data.setX(data.getX() + deltaX);
494
                data.setY(data.getY() + deltaY);
495
                data.setZ(data.getZ() + deltaZ);
496
            } else {
497
                data.setX(deltaX);
498
                data.setY(deltaY);
499
                data.setZ(deltaZ);
500
            }
501
            if (yaw != null) {
502
                data.setXRot(yaw);
503
                data.setYRot(pitch);
504
            }
505
506
            // We can't hang two relative moves on one transaction
507
            if (data.getLastTransactionHung() == player.lastTransactionSent.get()) {
508
                player.sendTransaction();
509
            }
510
            data.setLastTransactionHung(player.lastTransactionSent.get());
511
        }
512
513
        int lastTrans = player.lastTransactionSent.get();
514
515
        player.latencyUtils.addRealTimeTask(lastTrans, () -> {
516
            PacketEntity entity = player.compensatedEntities.getEntity(entityId);
517
            if (entity == null) return;
518
            if (entity instanceof PacketEntityTrackXRot xRotEntity && yaw != null) {
519
                xRotEntity.packetYaw = yaw;
520
                xRotEntity.steps = entity.isBoat ? 10 : 3;
521
            }
522
523
            entity.onFirstTransaction(isRelative, hasPos, deltaX, deltaY, deltaZ, yaw, pitch, player);
524
        });
525
526
        player.latencyUtils.addRealTimeTask(lastTrans + 1, () -> {
527
            PacketEntity entity = player.compensatedEntities.getEntity(entityId);
528
            if (entity == null) return;
529
            entity.onSecondTransaction();
530
        });
531
    }
532
533
    public void addEntity(int entityID, UUID uuid, EntityType type, Vector3d position, float xRot, float yRot, List<EntityData<?>> entityMetadata, int extraData) {
534
        if (despawnedEntitiesThisTransaction.contains(entityID)) {
535
            player.sendTransaction();
536
        }
537
538
        player.compensatedEntities.serverPositionsMap.put(entityID, new TrackerData(position.getX(), position.getY(), position.getZ(), xRot, yRot, type, player.lastTransactionSent.get()));
539
540
        player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
541
            PacketEntity entity = player.compensatedEntities.addEntity(entityID, uuid, type, position, xRot, extraData);
542
            if (entity instanceof DashableEntity dashable) {
543
                player.dashableEntities.addEntity(entityID, dashable);
544
            }
545
546
            if (entityMetadata != null) {
547
                if (EntityMetadataPoseUtil.usesPoseMetadata(entity) && player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_14)) {
548
                    Pose initialPose = EntityMetadataPoseUtil.getPoseFromMetadata(entityMetadata);
549
                    if (initialPose != null) {
550
                        entity.currentPose = initialPose;
551
                    }
552
                }
553
554
                player.compensatedEntities.updateEntityMetadata(entityID, entityMetadata);
555
            }
556
        });
557
    }
558
559
    private void schedulePoseTransition(WrapperPlayServerEntityMetadata entityMetadata, PacketSendEvent event) {
560
        if (player.getClientVersion().isOlderThan(ClientVersion.V_1_14)) return;
561
562
        int entityId = entityMetadata.getEntityId();
563
        if (entityId == player.entityID) return;
564
565
        Pose newPose = EntityMetadataPoseUtil.getPoseFromMetadata(entityMetadata.getEntityMetadata());
566
        if (newPose == null) return;
567
568
        boolean shouldTrackPoseTransition = false;
569
        PacketEntity entity = player.compensatedEntities.getEntity(entityId);
570
        if (entity != null) {
571
            shouldTrackPoseTransition = EntityMetadataPoseUtil.usesPoseMetadata(entity);
572
        } else {
573
            // If the client didn't respond to the spawn packet yet, we need to check if we should track the pose transition based on the entity type
574
            // is there a better way to do this?
575
            TrackerData trackedEntity = player.compensatedEntities.getTrackedEntity(entityId);
576
            if (trackedEntity != null) {
577
                shouldTrackPoseTransition = EntityMetadataPoseUtil.usesPoseMetadata(trackedEntity.getEntityType());
578
            }
579
        }
580
581
        if (!shouldTrackPoseTransition) return;
582
583
        player.sendTransaction();
584
        player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
585
            PacketEntity target = player.compensatedEntities.getEntity(entityId);
586
            if (target == null) {
587
                return;
588
            }
589
590
            target.beginPoseTransition(newPose);
591
        });
592
593
        event.getTasksAfterSend().add(() -> {
594
            player.sendTransaction();
595
            player.latencyUtils.addRealTimeTask(player.lastTransactionSent.get(), () -> {
596
                PacketEntity target = player.compensatedEntities.getEntity(entityId);
597
                if (target == null) {
598
                    return;
599
                }
600
601
                target.completePoseTransition(newPose);
602
            });
603
        });
604
    }
605
606
    private boolean isDirectlyAffectingPlayer(GrimPlayer player, int entityID) {
607
        // The attributes for this entity is active, currently
608
        return (player.compensatedEntities.serverPlayerVehicle == null && entityID == player.entityID) ||
609
                (player.compensatedEntities.serverPlayerVehicle != null && entityID == player.compensatedEntities.serverPlayerVehicle);
610
    }
611
612
    public void onEndOfTickEvent(boolean async, boolean flush) {
613
        // Only send a transaction at the end of the tick if we are tracking players
614
        player.sendTransaction(async);
615
        if (flush) player.user.flushPackets();
616
    }
617
618
    public void tickStartTick() {
619
        hasSentPreWavePacket.set(false);
620
    }
621
622
    @Override
623
    public void onReload(@NotNull ConfigManager config) {
624
        maxFireworkBoostPing = config.getIntElse("max-ping-firework-boost", 1000);
625
    }
626
627
}

How it counteracts this module

PacketEntityReplication is Grim's consumer for the spawn and entity-update broadcasts, maintaining the server-side mirror of entity state that the prediction engine reads. The module renders the client-side mirror of exactly the same stream, so this handler is the closest server-side counterpart to what ESP draws, and the honest finding is a gap: the handler validates and tracks entity data, but client rendering is invisible to it, so the module cannot be detected through this path. The check matters here as the description of the data ESP consumes, not as a detection mechanism.

anticheat NCP fight Angle (wall-aim rotation stream)

Angle.java255 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.fight;
16
17
import java.util.Iterator;
18
import java.util.LinkedList;
19
import java.util.List;
20
import java.util.UUID;
21
22
import org.bukkit.ChatColor;
23
import org.bukkit.Location;
24
import org.bukkit.entity.Entity;
25
import org.bukkit.entity.Player;
26
27
import fr.neatmonster.nocheatplus.actions.ParameterName;
28
import fr.neatmonster.nocheatplus.checks.Check;
29
import fr.neatmonster.nocheatplus.checks.CheckType;
30
import fr.neatmonster.nocheatplus.checks.ViolationData;
31
import fr.neatmonster.nocheatplus.permissions.Permissions;
32
import fr.neatmonster.nocheatplus.players.IPlayerData;
33
import fr.neatmonster.nocheatplus.utilities.StringUtil;
34
import fr.neatmonster.nocheatplus.utilities.TickTask;
35
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
36
37
/**
38
 * A check used to verify if the player isn't using a forcefield in order to attack multiple entities at the same time.
39
 * 
40
 * Thanks @asofold for the original idea!
41
 */
42
public class Angle extends Check {
43
  
44
45
  private final List<String> tags = new LinkedList<String>();
46
47
48
    public static class AttackLocation {
49
        public final double x, y, z;
50
        /** Yaw of the attacker. */
51
        public final float yaw;
52
        public long time;
53
        public final UUID damagedId;
54
        /** Squared distance to the last location (0 if none given). */
55
        public final double distSqLast;
56
        /** Difference in yaw to the last location (0 if none given). */
57
        public final double yawDiffLast;
58
        /** Time difference to the last location (0 if none given). */
59
        public final long timeDiff;
60
        /** If the id differs from the last damaged entity (true if no lastLoc is given). */
61
        public final boolean idDiffLast;
62
        public AttackLocation(final Location loc, final UUID damagedId, final long time, final AttackLocation lastLoc) {
63
            x = loc.getX();
64
            y = loc.getY();
65
            z = loc.getZ();
66
            yaw = loc.getYaw();
67
            this.time = time;
68
            this.damagedId = damagedId;
69
70
            if (lastLoc != null) {
71
                distSqLast = TrigUtil.distanceSquared(x, y, z, lastLoc.x, lastLoc.y, lastLoc.z);
72
                yawDiffLast = TrigUtil.yawDiff(yaw, lastLoc.yaw);
73
                timeDiff = Math.max(0L, time - lastLoc.time);
74
                idDiffLast = !damagedId.equals(lastLoc.damagedId);
75
            } 
76
            else {
77
                distSqLast = 0.0;
78
                yawDiffLast = 0f;
79
                timeDiff = 0L;
80
                idDiffLast = true;
81
            }
82
        }
83
    }
84
    
85
    /** Used to also monitor lag-time */
86
    public static long maxTimeDiff = 1000L;
87
88
89
    /**
90
     * Instantiates a new angle check.
91
     */
92
    public Angle() {
93
        super(CheckType.FIGHT_ANGLE);
94
    }
95
96
97
    /**
98
     * The Angle check.
99
     * @param player
100
     * @param loc Location of the player.
101
     * @param worldChanged
102
     * @param data
103
     * @param cc
104
     * @return
105
     */
106
    public boolean check(final Player player, final Location loc, 
107
                         final Entity damagedEntity, final boolean worldChanged, 
108
                         final FightData data, final FightConfig cc, final IPlayerData pData) {
109
110
        if (worldChanged) {
111
            data.angleHits.clear();
112
        }
113
114
        boolean cancel = false;
115
        tags.clear();
116
117
        // Quick check for expiration of all entries.
118
        final long time = System.currentTimeMillis();
119
        AttackLocation lastLoc = data.angleHits.isEmpty() ? null : data.angleHits.getLast();
120
        if (lastLoc != null && time - lastLoc.time > maxTimeDiff) {
121
            data.angleHits.clear();
122
            lastLoc = null;
123
        }
124
125
        // Add the new location.
126
        data.angleHits.add(new AttackLocation(loc, damagedEntity.getUniqueId(), System.currentTimeMillis(), lastLoc));
127
128
        // Calculate the sums of differences.
129
        double deltaMove = 0D;
130
        long deltaTime = 0L;
131
        float deltaYaw = 0f;
132
        int deltaSwitchTarget = 0;
133
        final Iterator<AttackLocation> it = data.angleHits.iterator();
134
        while (it.hasNext()) {
135
            final AttackLocation refLoc = it.next();
136
            if (time - refLoc.time > maxTimeDiff) {
137
                it.remove();
138
                continue;
139
            }
140
            deltaMove += refLoc.distSqLast;
141
            final double yawDiff = Math.abs(refLoc.yawDiffLast);
142
            deltaYaw += yawDiff;
143
            deltaTime += refLoc.timeDiff;
144
            if (refLoc.idDiffLast && yawDiff > 30.0) {
145
                // TODO: Configurable sensitivity ? Scale with yawDiff?
146
                deltaSwitchTarget += 1;
147
            }
148
        }
149
150
        // Check if there is enough data present.
151
        if (data.angleHits.size() < 2) {
152
            return false;
153
        }
154
155
        final double n = (double) (data.angleHits.size() - 1);
156
157
        // Let's calculate the average move.
158
        double averageMove = deltaMove / n;
159
        // Adjust to server-sided lag
160
        averageMove *= TickTask.getLag(maxTimeDiff, true);
161
162
        // And the average time elapsed.
163
        double averageTime = (double) deltaTime / n;
164
        // Adjust to server-sided lag
165
        averageTime *= TickTask.getLag(maxTimeDiff, true);
166
167
        // And the average yaw delta.
168
        double averageYaw = (double) deltaYaw / n;
169
        // Adjust to server-sided lag
170
        averageYaw /= TickTask.getLag(maxTimeDiff, true);
171
172
        // Average target switching.
173
        double averageSwitching = (double) deltaSwitchTarget / n;
174
        // Adjust to server-sided lag
175
        averageSwitching /= TickTask.getLag(maxTimeDiff, true);
176
177
        // Declare the variables.
178
        double violation = 0.0;
179
        double violationMove = 0.0;
180
        double violationTime = 0.0;
181
        double violationYaw = 0.0;
182
        double violationSwitchSpeed = 0.0;
183
184
        // If the average move is between 0 and 0.2 block(s), add it to the violation.
185
        if (averageMove >= 0.0 && averageMove < 0.2D) {
186
            violationMove += 20.0 * (0.2 - averageMove) / 0.2;
187
            tags.add("avgmove");
188
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
189
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgMove: " + averageMove + " avgMove VL: " + violationMove + "/" + cc.angleMove);
190
            }
191
        }
192
193
        // If the average time elapsed is between 0 and 150 millisecond(s), add it to the violation.
194
        if (averageTime >= 0.0 && averageTime < 150.0) {
195
            violationTime += 30.0 * (150.0 - averageTime) / 150.0;
196
            tags.add("avgtime");
197
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
198
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgTime: " + averageTime + " avgTime VL: " + violationTime + "/" + cc.angleTime);
199
            }
200
        }
201
202
        // If the average difference of yaw is superior to 50 degrees, add it to the violation.
203
        if (averageYaw > 50.0) {
204
            violationYaw += 30.0 * averageYaw / 180.0;
205
            tags.add("avgyaw");
206
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
207
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgYaw: " + averageYaw + " avgYaw VL: " + violationYaw + "/" + cc.angleYaw);
208
            }
209
        }
210
        
211
        // Check for too quick target switch speed
212
        if (averageSwitching > 0.0) {
213
            violationSwitchSpeed += 20.0 * averageSwitching;
214
            tags.add("switchspeed");
215
            if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
216
                player.sendMessage(ChatColor.RED + "NC+ Debug: " + ChatColor.RESET + "avgSwitch: " + averageSwitching + " avgSwitch VL: " + violationSwitchSpeed + "/" + cc.angleSwitch);
217
            }
218
        }
219
220
221
        if (violationMove > cc.angleMove) {
222
            violation = violationMove;
223
            data.angleVL += violation;
224
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
225
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
226
            cancel = executeActions(vd).willCancel();
227
        }
228
        else if (violationTime > cc.angleTime) {
229
            violation = violationTime;
230
            data.angleVL += violation;
231
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
232
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
233
            cancel = executeActions(vd).willCancel();
234
        }
235
        else if (violationYaw > cc.angleYaw) {
236
            violation = violationYaw;
237
            data.angleVL += violation;
238
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
239
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
240
            cancel = executeActions(vd).willCancel();
241
        } 
242
        else if (violationSwitchSpeed > cc.angleSwitch) {
243
            violation = violationSwitchSpeed;
244
            data.angleVL += violation;
245
            final ViolationData vd = new ViolationData(this, player, data.angleVL, violation, cc.angleActions);
246
            if (vd.needsParameters()) vd.setParameter(ParameterName.TAGS, StringUtil.join(tags, "+"));
247
            cancel = executeActions(vd).willCancel();
248
        } 
249
        else {
250
            // Reward the player by lowering their violation level.
251
            data.angleVL *= 0.98D;  
252
        }
253
        return cancel;
254
    }
255
}

How it counteracts this module

The realistic detection surface for an ESP user is the aim behavior it enables: a player who knows enemy positions through walls aims at wall-hidden targets, producing a rotation stream with no visible target and target switches without yaw motion. NCP fight Angle scores exactly those signals inside a 1000ms window with 0.98 decay, but it is config-gated and dormant at the stock thresholds in this tree (move 100, time 150, yaw 60, switch 50). ESP alone emits no rotation at all, so the check is an honest boundary: it polices the companion aim, never the renderer.

anticheat Hawk EntityInteractDirection (server ray validation)

EntityInteractDirection.java95 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.interaction.entity;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.EntityInteractionCheck;
23
import me.islandscout.hawk.event.InteractEntityEvent;
24
import me.islandscout.hawk.util.*;
25
import me.islandscout.hawk.wrap.entity.WrappedEntity;
26
import org.bukkit.Location;
27
import org.bukkit.entity.Entity;
28
import org.bukkit.entity.Player;
29
import org.bukkit.util.Vector;
30
31
public class EntityInteractDirection extends EntityInteractionCheck {
32
33
    private final int PING_LIMIT;
34
    private final boolean LAG_COMPENSATION;
35
    private final boolean CHECK_OTHER_ENTITIES;
36
    private final double BOX_EXPAND;
37
38
    public EntityInteractDirection() {
39
        super("entityinteractdirection", true, 0, 10, 0.9, 5000, "%player% failed entity interact direction, VL: %vl%", null);
40
        PING_LIMIT = (int) customSetting("pingLimit", "", -1);
41
        LAG_COMPENSATION = (boolean) customSetting("lagCompensation", "", true);
42
        CHECK_OTHER_ENTITIES = (boolean) customSetting("checkOtherEntities", "", true);
43
        BOX_EXPAND = (double) customSetting("boxExpand", "", 0.2);
44
    }
45
46
    @Override
47
    protected void check(InteractEntityEvent e) {
48
        Player p = e.getPlayer();
49
        HawkPlayer pp = e.getHawkPlayer();
50
        Entity victimEntity = e.getEntity();
51
        if (!(victimEntity instanceof Player) && !CHECK_OTHER_ENTITIES)
52
            return;
53
        int ping = ServerUtils.getPing(e.getPlayer());
54
        if (PING_LIMIT > -1 && ping > PING_LIMIT)
55
            return;
56
        Vector pos;
57
        if(pp.isInVehicle()) {
58
            pos = hawk.getLagCompensator().getHistoryLocation(ping, p).toVector();
59
            pos.setY(pos.getY() + p.getEyeHeight());
60
        }
61
        else {
62
            pos = pp.getHeadPosition();
63
        }
64
        //As I always say in math class, converting polar coordinates to rectangular coordinates is a pain in
65
        //the ass. If you want to use the previous direction vector, you cannot make an accurate cut through the AABB
66
        //using only the previous and extrapolated direction vectors. You'd think you could since the extrapolation
67
        //on yaw and pitch is linear, but the current direction vector won't lie between the other two. Remember Non-
68
        //Euclidean geometry!
69
        Vector dir = MathPlus.getDirection(pp.getYaw(), pp.getPitch());
70
        //Note: in MC 1.8, the cursor yaw is not updated per frame, but rather per tick.
71
        //For ray-hitbox checks, this means that we do not need to extrapolate the yaw,
72
        //but for this check it does not matter whether we do it or not.
73
        Vector extraDir = MathPlus.getDirection(pp.getYaw() + pp.getDeltaYaw(), pp.getPitch() + pp.getDeltaPitch());
74
75
        Location victimLoc;
76
        if(LAG_COMPENSATION)
77
            victimLoc = hawk.getLagCompensator().getHistoryLocation(ping, victimEntity);
78
        else
79
            victimLoc = e.getEntity().getLocation();
80
81
        AABB victimAABB = WrappedEntity.getWrappedEntity(e.getEntity()).getHitbox(victimLoc.toVector());
82
        victimAABB.expand(BOX_EXPAND, BOX_EXPAND, BOX_EXPAND);
83
84
        //this is a crappy workaround to one of the issues with AABB#betweenRays. I'll keep this here until it is rewritten.
85
        Vector toVictim = victimLoc.toVector().setY(0).subtract(pos.clone().setY(0));
86
        boolean behind = toVictim.clone().normalize().dot(dir.clone().setY(0).normalize()) < 0 && toVictim.lengthSquared() > victimAABB.getMax().clone().setY(0).subtract(victimAABB.getMin().clone().setY(0)).lengthSquared();
87
88
        if(victimAABB.betweenRays(pos, dir, extraDir) && !behind) {
89
            reward(pp);
90
        }
91
        else {
92
            punish(pp, true, e);
93
        }
94
    }
95
}

How it counteracts this module

EntityInteractDirection ray traces from the server-observed yaw and pitch to the victim with a 0.2 box expansion and fails any C02 attack whose facing cone misses the target. An ESP-informed aura that attacks a wall-hidden player fails this check the moment the victim is off the facing cone, because the server's ray passes through the wall while the client aimed at the ESP outline. The boundary is explicit: the module itself sends no C02, so the check only ever sees the pairing, and a pure ESP user who never attacks is invisible to it.

anticheat Hawk AimbotConvergence (fixed-point lock)

AimbotConvergence.java84 lines · Java
1
/*
2
 * This file is part of Hawk Anticheat.
3
 * Copyright (C) 2018 Hawk Development Team
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
package me.islandscout.hawk.check.movement.look;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.CustomCheck;
23
import me.islandscout.hawk.event.Event;
24
import me.islandscout.hawk.event.MoveEvent;
25
import me.islandscout.hawk.util.*;
26
import org.bukkit.entity.Player;
27
import org.bukkit.util.Vector;
28
29
import java.util.*;
30
31
public class AimbotConvergence extends CustomCheck {
32
33
    //You better turn off your aimbot when your opponent is standing still!
34
    //Flags basic aimbots that update rotation before motion updates
35
36
    private Map<UUID, Vector> lastConvergencePointMap;
37
38
    public AimbotConvergence() {
39
        super("aimbotconvergence", true, -1, 5, 0.999, 5000, "%player% failed aimbot (convergence), VL: %vl%", null);
40
        this.lastConvergencePointMap = new HashMap<>();
41
    }
42
43
    @Override
44
    protected void check(Event event) {
45
        if(event instanceof MoveEvent) {
46
            MoveEvent e = (MoveEvent) event;
47
            HawkPlayer pp = e.getHawkPlayer();
48
            if(!e.hasDeltaPos())
49
                return;
50
            UUID uuid = pp.getUuid();
51
            Vector prePos = e.getFrom().toVector().clone().subtract(pp.getVelocity()).add(new Vector(0, 1.62, 0));
52
            Vector postPos = e.getFrom().toVector().add(new Vector(0, 1.62, 0));
53
            Vector preDir = e.getFrom().getDirection();
54
            Vector postDir = e.getTo().getDirection();
55
            Pair<Vector, Vector> points = new Ray(prePos, preDir).closestPointsBetweenLines(new Ray(postPos, postDir));
56
57
            Vector lastConvergence = lastConvergencePointMap.get(uuid);
58
            Vector convergence = points.getKey().add(points.getValue()).multiply(0.5);
59
60
            if(lastConvergence != null &&
61
                    //make sure TPs don't false this check
62
                    pp.getCurrentTick() - pp.getLastTeleportAcceptTick() > ServerUtils.getPing(e.getPlayer()) / 50 + 10 &&
63
                    pp.getCurrentTick() > 100) {
64
65
                double distance = lastConvergence.distanceSquared(convergence);
66
                if(!Double.isNaN(distance)) {
67
68
                    if(distance < 0.00000001) //TODO convergence point should be some distance away from head position to filter some falses
69
                        punish(pp, false, e);
70
                    else
71
                        reward(pp);
72
73
                }
74
            }
75
76
            lastConvergencePointMap.put(uuid, convergence);
77
        }
78
    }
79
80
    @Override
81
    public void removeData(Player p) {
82
        lastConvergencePointMap.remove(p.getUniqueId());
83
    }
84
}

How it counteracts this module

AimbotConvergence tracks whether a player's ray converges on a fixed point across consecutive moves, with convergence scored when the squared distance to the lock point falls below 1e-8; a smooth aim that repeatedly returns to the same point across ticks is the signature. An ESP-assisted aimbot locks onto the outline's center, which is a fixed point the server's own geometry never corroborates, so the convergence signature builds. As with the other boundary checks, ESP alone produces no rotation stream, so the check fires only on the companion aim module.

← Back to Analysis Hub