Memeware 7.3 Hacker Detect module 1 files, 60 lines

Memeware 7.3 Hacker Detect: Full Source Analysis

Memeware 7.3's Hacker Detect is a client-side observer that scans other players' rendered state for one anomaly: an out-of-range pitch.

me/memewaredevs/client/module/misc/HackerDetect.java · GitHub source ↗

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

Analysis

Overview

Memeware 7.3's Hacker Detect is a client-side observer that scans other players' rendered state for one anomaly: an out-of-range pitch. A single UpdateEvent handler iterates mc.theWorld.loadedEntityList every tick, and for each EntityPlayer other than the local player that has existed for more than 50 ticks, it checks whether rotationPitch falls outside [-90, 90]; offenders are reported with a '[MAC]'-tagged client-side chat line via ChatUtil.printChatFlag. The module reads only the client's own entity list - the state that arrived via spawn, entity-look and teleport packets - and emits no packets of its own, so its reports are local-only observations. The more ambitious speed heuristic (one-block-per-tick movement with ice-exemption logic) exists in the source only as commented-out code, and the isMoving helper it would use is never called.

Architecture

The module is one @Handler Consumer<UpdateEvent> plus an EntityLivingBase field reused as a scratch reference. Every tick it iterates the loaded entity list, skips anything that is not an EntityPlayer, skips the local player, and skips players with ticksExisted <= 50 - a grace period that keeps freshly spawned entities out of the check. The single active test is the pitch range: rotationPitch < -90 or rotationPitch > 90 triggers ChatUtil.printChatFlag with the offending player's name and a canned message. The imported movement utilities (MovementUtils), the ice-block and BlockPane types, and the isMoving helper are all vestiges of the disabled speed heuristic, which the author left in place as a comment block marked 'fixing my cancer code here later, lazy rn'. The module holds no per-player state, so the same player is re-flagged on every tick for as long as the bad pitch persists.

What the check actually observes

The rotation values come from the client's own entity simulation, not from any packet the module reads: other players' yaw and pitch are updated client-side from the spawn packet (S0C), entity-look/move packets (S14 family), and teleports (S18), each carrying byte-encoded angles that the client decodes into degrees. The pitch bound it enforces matches the vanilla server-side constraint, but the client never clamps remote entities, so a server or a hacked client that transmits an out-of-range pitch leaves the value visible in the world state - which is what the module detects. The comment block shows the intended second check: flag players whose x or z position moves more than 1 block per tick over non-ice ground while moving and visible, i.e. a crude speed threshold - but that path is dead code in this build. The output channel is printChatFlag, which renders the report locally with a '[MAC]' prefix and never sends a packet.

Wire behavior

Hacker Detect produces no network traffic of its own: it is a pure reader of client-side world state and a local chat renderer. That makes it invisible to server-side anticheats by construction - there is no packet, timing pattern, or server-visible state change to detect, and the module cannot even be inferred from the outside since its reports never leave the client. Its practical value is equally limited: it re-implements, on the observing client, a single narrow check that real anticheats already run server-side against each player's own movement packets, and it only sees what the server already accepted and broadcast. The commented-out speed check would have been equally redundant: the same '>1 block per tick' heuristic is the core of server-side speed validation, minus the ice and piston exemptions the comment block half-remembers.

source HackerDetect.java (client-side rotation observer)

HackerDetect.java60 lines · JavaOriginal ↗
1
package me.memewaredevs.client.module.misc;
2
3
import me.hippo.api.lwjeb.annotation.Handler;
4
import me.memewaredevs.client.event.events.UpdateEvent;
5
import me.memewaredevs.client.module.Module;
6
import me.memewaredevs.client.util.ChatUtil;
7
import me.memewaredevs.client.util.movement.MovementUtils;
8
import net.minecraft.block.BlockIce;
9
import net.minecraft.block.BlockPackedIce;
10
import net.minecraft.block.BlockPane;
11
import net.minecraft.entity.Entity;
12
import net.minecraft.entity.EntityLiving;
13
import net.minecraft.entity.EntityLivingBase;
14
import net.minecraft.entity.player.EntityPlayer;
15
import net.minecraft.util.ChatComponentText;
16
17
import java.util.Iterator;
18
import java.util.function.Consumer;
19
20
public class HackerDetect extends Module {
21
22
    EntityLivingBase player;
23
24
    public HackerDetect() {
25
        super("Hacker Detect", 0, Category.MISC);
26
    }
27
28
    @Handler
29
    public Consumer<UpdateEvent> eventConsumer1 = (event) -> {
30
        for (Iterator<Entity> people = mc.theWorld.loadedEntityList.iterator(); people.hasNext();) { // simple way to get poop players
31
            Object gottem = people.next();
32
            if (gottem instanceof EntityPlayer) {
33
                EntityPlayer aPlayer = (EntityPlayer) gottem;
34
                if(aPlayer != mc.thePlayer) {
35
                    this.player = aPlayer;
36
                    if (this.player.ticksExisted > 50) {
37
                        if (this.player.rotationPitch < -90 || this.player.rotationPitch > 90) // poop headless invalid direction check for gay auras
38
                            ChatUtil.printChatFlag(this.player.getName() + " is rotated in an invalid direction!");
39
40
//                        if (this.player.posX > this.player.lastTickPosX + 1 && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockIce) && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockPackedIce) || this.player.posX < this.player.lastTickPosX - 1 && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockIce) && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockPackedIce) || this.player.posZ > this.player.lastTickPosZ + 1 && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockIce) && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockPackedIce) || this.player.posZ < this.player.lastTickPosZ - 1 && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockIce) && !(mc.theWorld.getBlock(this.player.posX, this.player.posY - 1, this.player.posZ) instanceof BlockPackedIce))
41
//                            if (!this.player.getName().endsWith("s") && this.isMoving(this.player) && !this.player.isInvisible())
42
//                                ChatUtil.printChatFlag(this.player.getName() + "'s speed isn't legitimate!");
43
//                            else if (this.isMoving(this.player) && !this.player.isInvisible())
44
//                                ChatUtil.printChatFlag(this.player.getName() + "' speed isn't legitimate!");
45
                    } // fixing my cancer code here later, lazy rn
46
                }
47
            }
48
        }
49
    };
50
51
    private boolean isMoving(EntityLivingBase player) { // this for later
52
        if(player.prevPosX != player.posX)
53
            return true;
54
        if(player.prevPosY != player.posY)
55
            return true;
56
        if(player.prevPosZ != player.posZ)
57
            return true;
58
        return false;
59
    }
60
}

What this file does

The module is the eventConsumer1 field: a @Handler UpdateEvent consumer that walks the loaded entity list each tick, filters to EntityPlayer instances other than the local player with ticksExisted > 50, and reports any whose rotationPitch lies outside [-90, 90] through ChatUtil.printChatFlag. The active code is that one range test; everything else in the file is scaffolding for a disabled speed detector. The commented block compares per-axis position deltas against 1 block with BlockIce/BlockPackedIce exemptions and an invisibility check, and the private isMoving helper (prevPos vs pos comparison on three axes) exists to serve it but is never invoked. The unused imports - MovementUtils, BlockPane, ChatComponentText - reinforce that the speed path was never finished. Because the module keeps no per-player record, a persistently bad pitch produces the same flag line every tick, and the '[MAC]' prefix ties the output to the same ChatUtil channel the Commands module's feedback uses.

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 Hawk InvalidPitch (server-side pitch validation)

InvalidPitch.java42 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.check.MovementCheck;
22
import me.islandscout.hawk.event.MoveEvent;
23
24
//Not really an important check. This just stops skids from thinking they're so cool.
25
public class InvalidPitch extends MovementCheck {
26
27
    //PASSED (9/11/18)
28
29
    public InvalidPitch() {
30
        super("invalidpitch", "%player% failed invalid pitch. VL: %vl%");
31
    }
32
33
    @Override
34
    protected void check(MoveEvent event) {
35
        if (!event.hasDeltaRot())
36
            return;
37
        if (Math.abs(event.getTo().getPitch()) > 90)
38
            punishAndTryRubberband(event.getHawkPlayer(), event);
39
        else
40
            reward(event.getHawkPlayer());
41
    }
42
}

How it counteracts this module

Hawk's InvalidPitch is the server-side twin of the exact test this module runs locally, and the comparison is the honest core of the countering story. On every MoveEvent with a rotation delta (hasDeltaRot), Hawk computes Math.abs(event.getTo().getPitch()) and punishes plus rubber-bands the player when it exceeds 90 (lines 34-41) - the same bound the client module checks against other players' pitch, but validated from the player's own movement packets, per player, with punishment instead of a local chat line. The module's author even labeled it a skid-check: 'Not really an important check. This just stops skids from thinking they're so cool.'

What this means for Hacker Detect is that the module is fully redundant and fully undetectable at the same time. Any player whose pitch the module would flag locally is already being punished by Hawk server-side from their own packets, so the module's report adds no information. And because the module sends nothing, no server-side mechanism - this check included - can observe that a client is running it: InvalidPitch measures the player being watched, not the watcher. The only counter to the module is the honest statement that it does not need one.

anticheat Hawk AimbotPrecision (pitch-delta GCD analysis)

AimbotPrecision.java132 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.Cancelless;
23
import me.islandscout.hawk.check.MovementCheck;
24
import me.islandscout.hawk.event.MoveEvent;
25
import me.islandscout.hawk.util.Debug;
26
import me.islandscout.hawk.util.MathPlus;
27
import org.bukkit.ChatColor;
28
import org.bukkit.entity.Player;
29
30
import java.util.*;
31
32
/**
33
 * The AimbotPrecision check detects aim-bots by
34
 * checking for variation in head pitch precision.
35
 * It does this by solving the greatest common divisor
36
 * of the samples. All pitch changes should be divisible
37
 * by a constant, which is determined by the in-game
38
 * mouse sensitivity. Not compatible with cinematic
39
 * camera mode.
40
 *
41
 * The main issue with this approach to detecting aimbots
42
 * (besides cinematic camera mode) is its unreliability
43
 * at high client framerates. Because rotation is updated
44
 * per frame, there can be multiple rotation updates per
45
 * tick. Every time a new delta yaw/pitch is added to the
46
 * current rotation, there is precision loss due to the
47
 * arithmetic involved. These errors can add up very quickly,
48
 * ultimately causing the GCD algorithm to fail and
49
 * produce false-positives.
50
 */
51
public class AimbotPrecision extends MovementCheck implements Cancelless {
52
53
    //This concept could be used to determine someone's in-game sensitivity.
54
    //That's pretty spoopy if you ask me.
55
56
    //Inspired by https://www.spigotmc.org/threads/killaura-detection.143226/page-17#post-2821779
57
58
    private final Map<UUID, List<Float>> deltaPitches;
59
    private final Map<UUID, Float> lastDeltaPitchGCDs;
60
61
    private final int SAMPLES;
62
    private final float PITCHRATE_LIMIT;
63
64
    public AimbotPrecision() {
65
        super("aimbotprecision", false, -1, 5, 0.9, 5000, "%player% failed aimbot (precision), VL: %vl%", null);
66
        SAMPLES = (int)customSetting("samples", "", 10);
67
        PITCHRATE_LIMIT = (float)((double)customSetting("ignorePitchrateHigherThan", "", 0.96D));
68
        this.deltaPitches = new HashMap<>();
69
        this.lastDeltaPitchGCDs = new HashMap<>();
70
    }
71
72
    @Override
73
    protected void check(MoveEvent e) {
74
        HawkPlayer pp = e.getHawkPlayer();
75
        UUID uuid = pp.getUuid();
76
        float deltaPitch = e.getTo().getPitch() - e.getFrom().getPitch();
77
        List<Float> lastDeltaPitches = deltaPitches.getOrDefault(uuid, new ArrayList<>());
78
79
        //ignore if deltaPitch is 0 or >= 10 or if pitch is +/-90.
80
        if(deltaPitch != 0 && Math.abs(deltaPitch) <= PITCHRATE_LIMIT && Math.abs(e.getTo().getPitch()) != 90) {
81
            lastDeltaPitches.add(Math.abs(deltaPitch));
82
        }
83
84
        //Only check for pitch
85
        //For some reason when you spin your head around too much,
86
        //yaw checking becomes unreliable. Precision errors?
87
        //Still, this check is pretty impressive.
88
        if(lastDeltaPitches.size() >= SAMPLES) {
89
90
            float deltaPitchGCD = MathPlus.gcdRational(lastDeltaPitches);
91
            float gcdDiff = Math.abs(deltaPitchGCD - lastDeltaPitchGCDs.getOrDefault(uuid, deltaPitchGCD));
92
93
            if(gcdDiff > 0.001) {
94
95
                //Assuming sens didn't change, add last GCD in our delta pitches
96
                //just in case we didn't collect enough samples to compute the same GCD.
97
                //Try again. Mathematically, the GCD should remain the same.
98
                if(lastDeltaPitchGCDs.containsKey(uuid)) {
99
                    float lastDeltaPitchGCD = lastDeltaPitchGCDs.get(uuid);
100
                    if(lastDeltaPitchGCD > 0.001) {
101
                        lastDeltaPitches.add(lastDeltaPitchGCD);
102
                        deltaPitchGCD = MathPlus.gcdRational(lastDeltaPitches);
103
                        gcdDiff = Math.abs(deltaPitchGCD - lastDeltaPitchGCDs.getOrDefault(uuid, deltaPitchGCD));
104
                    }
105
                }
106
            }
107
108
            //if GCD is practically unsolvable
109
            if(deltaPitchGCD < 0.00001) {
110
                fail(pp, e);
111
            }
112
            else
113
                reward(pp);
114
115
            lastDeltaPitches.clear();
116
            lastDeltaPitchGCDs.put(uuid, deltaPitchGCD);
117
        }
118
119
        deltaPitches.put(uuid, lastDeltaPitches);
120
    }
121
122
    private void fail(HawkPlayer pp, MoveEvent e) {
123
        punish(pp, false, e);
124
    }
125
126
    @Override
127
    public void removeData(Player p) {
128
        UUID uuid = p.getUniqueId();
129
        deltaPitches.remove(uuid);
130
        lastDeltaPitchGCDs.remove(uuid);
131
    }
132
}

How it counteracts this module

AimbotPrecision is the real rotation-validity check in Hawk's look package, and it shows how shallow the client module's pitch-range test is by comparison. The check collects absolute pitch deltas per player, keeps only deltas between 0 and PITCHRATE_LIMIT (0.96 by default) excluding exact +/-90 (lines 79-82), and once SAMPLES (default 10) are gathered computes the rational GCD of the samples via MathPlus.gcdRational (lines 88-90). A GCD that drifts by more than 0.001 from the player's previous GCD fails after one retry seeded with the prior value (lines 93-106), and a GCD below 0.00001 - 'practically unsolvable' - fails outright (lines 109-111). The theory is that human mouse sensitivity quantizes every rotation delta to multiples of a constant, so aim-assist rotations produce a mathematically impossible GCD.

For this module the relationship is illustrative rather than adversarial: Hacker Detect's pitch-range test is a crude client-side echo of the property class these checks police, catching only values the server already treats as impossible. AimbotPrecision catches the smooth, quantized rotations that a range test can never see, and it does so server-side on the cheater's own packets. The honest conclusion is unchanged: the client module neither helps nor hinders either check, because it never touches the wire.

anticheat Hawk Speed (movement prediction discrepancy)

Speed.java280 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.position;
20
21
import me.islandscout.hawk.Hawk;
22
import me.islandscout.hawk.HawkPlayer;
23
import me.islandscout.hawk.check.MovementCheck;
24
import me.islandscout.hawk.event.Event;
25
import me.islandscout.hawk.event.HawkEventListener;
26
import me.islandscout.hawk.event.ItemSwitchEvent;
27
import me.islandscout.hawk.event.MoveEvent;
28
import me.islandscout.hawk.util.*;
29
import me.islandscout.hawk.wrap.entity.WrappedEntity;
30
import org.bukkit.ChatColor;
31
import org.bukkit.Material;
32
import org.bukkit.enchantments.Enchantment;
33
import org.bukkit.entity.Player;
34
import org.bukkit.event.Listener;
35
import org.bukkit.util.Vector;
36
37
import java.util.*;
38
39
public class Speed extends MovementCheck implements Listener {
40
41
    //I legit hate this game's movement.
42
    //Do you realize how much easier it would be if
43
    //the server handled movement?
44
45
    //TODO False flag with pistons
46
47
    //Basically, this check is doing, "if your previous speed was X then your current speed must not exceed f(X)"
48
49
    private static final double EPSILON = 0.000001;
50
    //Now what we can do is predict how far a player could have travelled
51
    //if the move doesn't have a deltaPos due to insignificance.
52
    private static final double MAX_NO_MOVE_DISTANCE = 0.03;
53
    private final double DISCREPANCY_THRESHOLD;
54
    private final double VL_FAIL_DISCREPANCY_FACTOR;
55
    private final boolean RESET_DISCREPANCY_ON_FAIL;
56
    private final int RELEASE_ITEM_OVER_VL;
57
    private final boolean CHECK_FLYING;
58
    private final boolean DEBUG;
59
60
    private final Map<UUID, Double> prevSpeed;
61
    private final Map<UUID, Double> discrepancies;
62
    private final Map<UUID, Integer> noMovesMap;
63
    private final Map<UUID, Double> lastNegativeDiscrepancies;
64
    private final Map<UUID, Double> negativeDiscrepanciesCumulative;
65
    private final Map<UUID, Integer> slotSwitchQuirkTicksMap; //I hate this game.
66
    private final Map<UUID, Long> lastSlotSwitchTickMap;
67
68
    public Speed() {
69
        super("speed", true, 0, 5, 0.99, 5000, "%player% failed movement speed, VL: %vl%", null);
70
        prevSpeed = new HashMap<>();
71
        discrepancies = new HashMap<>();
72
        noMovesMap = new HashMap<>();
73
        lastNegativeDiscrepancies = new HashMap<>();
74
        negativeDiscrepanciesCumulative = new HashMap<>();
75
        slotSwitchQuirkTicksMap = new HashMap<>();
76
        lastSlotSwitchTickMap = new HashMap<>();
77
        DISCREPANCY_THRESHOLD = (double) customSetting("discrepancyThreshold", "", 0.1D);
78
        VL_FAIL_DISCREPANCY_FACTOR = (double) customSetting("vlFailDiscrepancyFactor", "", 10D);
79
        RESET_DISCREPANCY_ON_FAIL = (boolean) customSetting("resetDiscrepancyOnFail", "", true);
80
        RELEASE_ITEM_OVER_VL = (int) customSetting("releaseItemOverVl", "", 4);
81
        CHECK_FLYING = (boolean) customSetting("checkFlying", "", true);
82
        DEBUG = (boolean) customSetting("debug", "", false);
83
    }
84
85
    @Override
86
    protected void check(MoveEvent event) {
87
        Player p = event.getPlayer();
88
        HawkPlayer pp = event.getHawkPlayer();
89
90
        int noMoves = noMovesMap.getOrDefault(p.getUniqueId(), 0);
91
        double lastSpeed;
92
        double speed;
93
        if(event.isUpdatePos()) {
94
            lastSpeed = prevSpeed.getOrDefault(p.getUniqueId(), 0D);
95
            if(noMoves > 0) {
96
                //Players don't update position unless they've moved at least 0.03 blocks (or if 20 ticks passed)
97
                lastSpeed = Math.min(lastSpeed, MAX_NO_MOVE_DISTANCE);
98
            }
99
            speed = MathPlus.distance2d(event.getTo().getX() - event.getFrom().getX(), event.getTo().getZ() - event.getFrom().getZ());
100
        }
101
        else {
102
            speed = prevSpeed.getOrDefault(p.getUniqueId(), 0D) - (lastNegativeDiscrepancies.getOrDefault(p.getUniqueId(), 0D) + EPSILON);
103
            lastSpeed = speed;
104
        }
105
106
        if(event.isUpdatePos())
107
            noMoves = 0;
108
        else
109
            noMoves++;
110
111
        boolean flying = pp.isFlying();
112
        boolean swimming = pp.isInWater(); //this needs improvement
113
        //it is possible that the player has pressed the jump key even if this move is "stepped" (only while sprinting)
114
        boolean jump = event.isJump() || (event.isStep() && pp.isOnGround() && pp.isSprinting());
115
116
        float friction = event.getFriction();
117
        float maxForce = event.getMaxExpectedInputForce();
118
        float maxForceNoItemUse = event.getMaxExpectedInputForceNoItemUse();
119
120
        //It represents the previous location. Block collision is done after moving the entity.
121
        Set<Material> touchedBlocks = WrappedEntity.getWrappedEntity(p).getCollisionBox(event.getFrom().toVector()).getMaterials(pp.getWorld());
122
123
        //handle any pending knockbacks
124
        if(event.hasAcceptedKnockback() || (flying && !CHECK_FLYING)) {
125
            prepareNextMove(pp, noMoves, speed, touchedBlocks);
126
            return;
127
        }
128
129
        double lastSpeedCompare = lastSpeed;
130
        //Handle other things in the game that multiply velocity.
131
        //These affect velocity first (coincidentally, these are all multiplication operations)
132
        double handleMultipliers = 1;
133
        if(event.hasHitSlowdown())
134
            handleMultipliers *= 0.6;
135
        if(touchedBlocks.contains(Material.SOUL_SAND) && !flying)
136
            handleMultipliers *= 0.4;
137
        if(touchedBlocks.contains(Material.WEB) && !flying)
138
            handleMultipliers *= 0.25;
139
        if(Hawk.getServerVersion() > 7 && touchedBlocks.contains(Material.SLIME_BLOCK)) {
140
            //TODO I believe webs affect this mot Y too.
141
            if (Math.abs(pp.getVelocity().getY()) < 0.1 && !pp.isSneaking()) {
142
                handleMultipliers *= 0.4 + Math.abs(pp.getVelocity().getY()) * 0.2;
143
            }
144
        }
145
        //Handle other things in the game that add to velocity.
146
        //These affect velocity later (coincidentally, these are all addition operations)
147
        double handleAdders = 0;
148
        if(pp.isSprinting() && jump) {
149
            handleAdders += 0.2;
150
        }
151
        if(swimming && !flying) { //This is actually a terrible way of handling horizontal water flow.
152
            Vector move = new Vector(event.getTo().getX() - event.getFrom().getX(), 0, event.getTo().getZ() - event.getFrom().getZ());
153
            Vector waterForce = event.getWaterFlowForce().clone().setY(0);
154
            double waterForceLength = waterForce.length() + 0.003; //add epsilon to allow room for error
155
            double moveLength = move.length();
156
            double computedForce = moveLength == 0 ? waterForceLength : (move.dot(waterForce) / moveLength);
157
158
            handleAdders += computedForce;
159
        }
160
161
        //Finally, the expected speed calculation. There's another "expected" because of a dumb quirk when switching slots while using an item.
162
        //Optimize later.
163
        double expected = friction * lastSpeedCompare * handleMultipliers + (maxForce + handleAdders + EPSILON);
164
        double expectedNoItemUse = friction * lastSpeedCompare * handleMultipliers + (maxForceNoItemUse + handleAdders + EPSILON);
165
166
        //I hate this game. Handle slot switching quirk. The slot switch packet is delayed by a tick.
167
        //This sort of "event listening" must be done because Hawk's MoveEvents can be skipped under certain conditions.
168
        long slotSwitchTick = pp.getLastSlotSwitchTick();
169
        boolean switchedSlot = slotSwitchTick != lastSlotSwitchTickMap.getOrDefault(p.getUniqueId(), slotSwitchTick);
170
        int slotSwitchQuirkTicks = slotSwitchQuirkTicksMap.getOrDefault(p.getUniqueId(), 0);
171
        if(switchedSlot) {
172
            slotSwitchQuirkTicks = 0;
173
        }
174
        lastSlotSwitchTickMap.put(p.getUniqueId(), slotSwitchTick);
175
176
        //Calculate discrepancy.
177
        Discrepancy discrepancy; //This is the one that will be used for final comparison. It is the value of either discrepancyBase or discrepancyNoItemUse.
178
        Discrepancy discrepancyBase; //Used for pretty much 99.99% of moves.
179
        Discrepancy discrepancyNoItemUse; //Similar to discrepancyBase, but doesn't consider item-use slowdown.
180
181
        discrepancyBase = new Discrepancy(expected, speed);
182
        discrepancyNoItemUse = new Discrepancy(expectedNoItemUse, speed);
183
        if((pp.isBlocking() || pp.isConsumingItem() || pp.isPullingBow()) && Math.abs(discrepancyNoItemUse.value) < Math.abs(discrepancyBase.value)) {
184
            //This means that they're using an item, but they're moving at normal speed. This COULD be due to that
185
            //dumb item switch quirk, so we'll grant them only one extra tick. It resets when they switch their slot.
186
            if(slotSwitchQuirkTicks < 1) {
187
                //Allow them to move at normal speed for 1 tick.
188
                discrepancy = discrepancyNoItemUse;
189
                slotSwitchQuirkTicks++;
190
            } else {
191
                discrepancy = discrepancyBase;
192
            }
193
        } else {
194
            discrepancy = discrepancyBase;
195
        }
196
197
        //Client told server that it updated its position. Checking time.
198
        if (event.isUpdatePos()) {
199
            double haltDistanceExpected = negativeDiscrepanciesCumulative.getOrDefault(p.getUniqueId(), 0D);
200
            lastNegativeDiscrepancies.put(p.getUniqueId(), 0D);
201
            if(discrepancy.value < 0 || speed > haltDistanceExpected)
202
                discrepancies.put(p.getUniqueId(), Math.max(discrepancies.getOrDefault(p.getUniqueId(), 0D) + discrepancy.value, 0));
203
            double totalDiscrepancy = discrepancies.getOrDefault(p.getUniqueId(), 0D);
204
205
            if(DEBUG) {
206
                p.sendMessage((totalDiscrepancy > DISCREPANCY_THRESHOLD ? ChatColor.RED : ChatColor.GREEN) + "" + totalDiscrepancy);
207
            }
208
209
            if(discrepancy.value > 0 && totalDiscrepancy > DISCREPANCY_THRESHOLD && !event.isPossiblePistonPush()) {
210
                punishAndTryRubberband(pp, discrepancy.value * VL_FAIL_DISCREPANCY_FACTOR, event);
211
                if(RESET_DISCREPANCY_ON_FAIL)
212
                    discrepancies.put(p.getUniqueId(), 0D);
213
                if(RELEASE_ITEM_OVER_VL > -1 && (pp.isPullingBow() || pp.isConsumingItem() || pp.isBlocking()) && pp.getVL(this) > RELEASE_ITEM_OVER_VL)
214
                    pp.releaseItem();
215
            }
216
            else {
217
                reward(pp);
218
            }
219
220
            lastNegativeDiscrepancies.put(p.getUniqueId(), 0D);
221
            negativeDiscrepanciesCumulative.put(p.getUniqueId(), 0D);
222
        }
223
        //Client sent a flying packet, but didn't update position.
224
        //The move might have not been significant enough, so we need
225
        //to prepare for when the client decides it's time to update
226
        //position.
227
        else {
228
            lastNegativeDiscrepancies.put(p.getUniqueId(), discrepancy.value);
229
230
            //TODO improve these two lines...
231
            double val = negativeDiscrepanciesCumulative.getOrDefault(p.getUniqueId(), 0D);
232
            negativeDiscrepanciesCumulative.put(p.getUniqueId(), Math.min(val + speed, MAX_NO_MOVE_DISTANCE + speed));
233
            //negativeDiscrepanciesCumulative.put(p.getUniqueId(), negativeDiscrepanciesCumulative.getOrDefault(p.getUniqueId(), 0D) + speed);
234
        }
235
236
        slotSwitchQuirkTicksMap.put(p.getUniqueId(), slotSwitchQuirkTicks);
237
        prepareNextMove(pp, noMoves, speed, touchedBlocks);
238
    }
239
240
    private void prepareNextMove(HawkPlayer pp, int noMoves, double currentSpeed, Set<Material> touchedBlocks) {
241
        if(touchedBlocks.contains(Material.WEB) && !pp.isFlying()) {
242
            currentSpeed = 0;
243
        }
244
        UUID uuid = pp.getUuid();
245
        prevSpeed.put(uuid, currentSpeed);
246
        noMovesMap.put(uuid, noMoves);
247
    }
248
249
    public void removeData(Player p) {
250
        UUID uuid = p.getUniqueId();
251
        prevSpeed.remove(uuid);
252
        discrepancies.remove(uuid);
253
        noMovesMap.remove(uuid);
254
        lastNegativeDiscrepancies.remove(uuid);
255
        negativeDiscrepanciesCumulative.remove(uuid);
256
        slotSwitchQuirkTicksMap.remove(uuid);
257
        lastSlotSwitchTickMap.remove(uuid);
258
    }
259
260
    //speed potions do not affect swimming
261
    private Discrepancy waterMapping(double lastSpeed, double currentSpeed, double waterFlowForce) {
262
        double expected = 0.800001 * lastSpeed + 0.020001 + waterFlowForce;
263
        return new Discrepancy(expected, currentSpeed);
264
    }
265
266
    private Discrepancy lavaMapping(double lastSpeed, double currentSpeed) {
267
        double expected = 0.500001 * lastSpeed + 0.020001;
268
        return new Discrepancy(expected, currentSpeed);
269
    }
270
271
    private class Discrepancy {
272
273
        double value;
274
275
        Discrepancy(double expectedSpeed, double currentSpeed) {
276
            value = currentSpeed - expectedSpeed;
277
        }
278
279
    }
280
}

How it counteracts this module

Hawk's Speed check is the server-side realization of the heuristic the module's author left commented out. It predicts each move from the previous speed, friction, jump/step state, knockback acceptance, and touched-block multipliers (soul sand, hit slowdown, item-use force limits), and accumulates the discrepancy between predicted and actual movement; when totalDiscrepancy exceeds DISCREPANCY_THRESHOLD (default 0.1) and the move is not a possible piston push, the player fails (lines 203-209). The position-only path even clamps stale speeds to MAX_NO_MOVE_DISTANCE so that a player who stopped updating position cannot bank speed (lines 92-96).

The module's dead code approximated the same idea with a 1-block-per-tick threshold over non-ice ground - vastly cruder, missing friction, knockback, pistons, and vertical movement entirely, and it was never enabled. The honest framing is that even if the author had finished it, the check would only have duplicated, at lower fidelity, what Speed already does server-side against the same movement packets. Like the pitch check, it would have consumed zero additional packets, so the module's detectability remains nil; the countering value of Speed here is as the reference implementation the client's stub was reaching toward.

← Back to Analysis Hub