Memeware 7.3 TP Aura module 2 files, 329 lines

Memeware 7.3 TP Aura: Full Source Analysis

Memeware 7.3 TP Aura is a teleport attack module: on a CPS-gated clock it streams C04 position packets along a computed path to every player within 218 blocks, swings, sends C02 attacks…

me/memewaredevs/client/module/combat/TPAura.java · GitHub source ↗

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

Packets This Module Uses

Analysis

Overview

Memeware 7.3 TP Aura is a teleport attack module: on a CPS-gated clock it streams C04 position packets along a computed path to every player within 218 blocks, swings, sends C02 attacks from the faked position, then streams the path in reverse to return. The path is built by the client's A* PathFinder with waypoints no more than 5 blocks apart, each carried with onGround true, so the vanilla moved-too-quickly gate (which tolerates position jumps up to 100 blocks) accepts every hop while the server-side position silently relocates next to each target. An optional NoHitDelay Breaker multiplies the attack to 10 C02 packets per target.

Path construction

computePath walks the PathFinder node list and collapses it into dash waypoints: the endpoints are always kept, and an interior node is only kept when the swept AABB between the last dash point and the candidate contains an invalid block or the segment exceeds 5 blocks (squareDistanceTo greater than 25). Each kept waypoint is shifted by 0.5 on x and z so the stream lands on block centers rather than corners, and if the starting block is solid the path origin is lifted one block first. The result is a chain whose hops are all at most 5 blocks, which is exactly the maximum the dash compression allows.

Attack sequence and clock

One shared Timer gates the whole sweep: when 1000 divided by the CPS setting has elapsed, every target returned by CombatUtil.getTargets(false, Targets, true, true, 218.0, true) is attacked in sequence. The target scan only accepts EntityPlayer instances, includes invisible players, skips dead and zero-health entities, and filters the client's bot list. Per target the module streams the forward C04 chain, swings, sends the C02 (or 10 C02s when NoHitDelay Breaker is on), then streams the chain backwards, so the entire round trip happens inside one timer fire and the server sees the player snap out to the victim and back.

Range and vanilla acceptance

The range argument is 218.0, widened to 220.0 for targets whose feet sit more than one block above the player (CombatUtil adds 2 in that case). All C04s carry onGround true even over open air, and vanilla processPlayer only rejects position deltas above 100 blocks per packet, so each 5-block hop passes the vanilla gate. The module never rotates toward the target, so the attack direction is wherever the player happens to face at fire time.

source TPAura.java

TPAura.java136 lines · JavaOriginal ↗
1
/*
2
 * Decompiled with CFR 0.145.
3
 *
4
 * Could not load the following classes:
5
 *  com.google.common.collect.Lists
6
 */
7
package me.memewaredevs.client.module.combat;
8
9
import com.google.common.collect.Lists;
10
import me.hippo.api.lwjeb.annotation.Handler;
11
import me.memewaredevs.client.event.events.UpdateEvent;
12
import me.memewaredevs.client.module.Module;
13
import me.memewaredevs.client.util.combat.CombatUtil;
14
import me.memewaredevs.client.util.misc.Timer;
15
import me.memewaredevs.client.util.pathfinding.Vec3;
16
import me.memewaredevs.client.util.pathfinding.PathFinder;
17
import net.minecraft.block.Block;
18
import net.minecraft.block.material.Material;
19
import net.minecraft.client.Minecraft;
20
import net.minecraft.entity.EntityLivingBase;
21
import net.minecraft.init.Blocks;
22
import net.minecraft.network.play.client.C02PacketUseEntity;
23
import net.minecraft.network.play.client.C03PacketPlayer;
24
import net.minecraft.util.BlockPos;
25
26
import java.util.ArrayList;
27
import java.util.List;
28
import java.util.function.Consumer;
29
30
public class TPAura extends Module {
31
32
    private Timer timer = new Timer();
33
34
    public TPAura() {
35
        super("TP Aura", 24, Module.Category.COMBAT);
36
        addInt("Targets", 1, 1, 250);
37
        addInt("CPS", 1, 1, 20);
38
        addBoolean("NoHitDelay Breaker", false);
39
    }
40
41
    private boolean canPassThrough(BlockPos pos) {
42
        Block block = Minecraft.getMinecraft().theWorld
43
                .getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ())).getBlock();
44
        return block.getMaterial() == Material.air || block.getMaterial() == Material.plants
45
                || block.getMaterial() == Material.vine || block == Blocks.ladder || block == Blocks.water
46
                || block == Blocks.flowing_water || block == Blocks.wall_sign || block == Blocks.standing_sign;
47
    }
48
49
    private ArrayList<Vec3> computePath(Vec3 topFrom, Vec3 to) {
50
        if (!canPassThrough(new BlockPos(topFrom.mc()))) {
51
            topFrom = topFrom.addVector(0.0, 1.0, 0.0);
52
        }
53
        PathFinder pathfinder = new PathFinder(topFrom, to);
54
        pathfinder.compute();
55
        int i = 0;
56
        Vec3 lastLoc = null;
57
        Vec3 lastDashLoc = null;
58
        ArrayList<Vec3> path = new ArrayList<>();
59
        ArrayList<Vec3> pathFinderPath = pathfinder.getPath();
60
        for (Vec3 pathElm : pathFinderPath) {
61
            if (i == 0 || i == pathFinderPath.size() - 1) {
62
                if (lastLoc != null) {
63
                    path.add(lastLoc.addVector(0.5, 0.0, 0.5));
64
                }
65
                path.add(pathElm.addVector(0.5, 0.0, 0.5));
66
                lastDashLoc = pathElm;
67
            } else {
68
                boolean canContinue = true;
69
                if (pathElm.squareDistanceTo(lastDashLoc) > 5 * 5) {
70
                    canContinue = false;
71
                } else {
72
                    double smallX = Math.min(lastDashLoc.getX(), pathElm.getX());
73
                    double smallY = Math.min(lastDashLoc.getY(), pathElm.getY());
74
                    double smallZ = Math.min(lastDashLoc.getZ(), pathElm.getZ());
75
                    double bigX = Math.max(lastDashLoc.getX(), pathElm.getX());
76
                    double bigY = Math.max(lastDashLoc.getY(), pathElm.getY());
77
                    double bigZ = Math.max(lastDashLoc.getZ(), pathElm.getZ());
78
                    int x = (int) smallX;
79
                    block1:
80
                    while (x <= bigX) {
81
                        int y2 = (int) smallY;
82
                        while (y2 <= bigY) {
83
                            int z = (int) smallZ;
84
                            while (z <= bigZ) {
85
                                if (!PathFinder.isValid(x, y2, z, false)) {
86
                                    canContinue = false;
87
                                    break block1;
88
                                }
89
                                ++z;
90
                            }
91
                            ++y2;
92
                        }
93
                        ++x;
94
                    }
95
                }
96
                if (!canContinue) {
97
                    path.add(lastLoc.addVector(0.5, 0.0, 0.5));
98
                    lastDashLoc = lastLoc;
99
                }
100
            }
101
            lastLoc = pathElm;
102
            ++i;
103
        }
104
        return path;
105
    }
106
107
    @Handler
108
    public Consumer<UpdateEvent> eventConsumer0 = event -> {
109
        if (timer.delay(1000L / getDouble("CPS").intValue())) {
110
            for (EntityLivingBase e : CombatUtil.getTargets(false, getDouble("Targets").intValue(), true, true, 218.0, true)) {
111
                ArrayList<Vec3> list = computePath(
112
                        new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ),
113
                        new Vec3(e.posX, e.posY, e.posZ));
114
115
                List<Vec3> backwards = Lists.reverse(list);
116
117
                for (Vec3 vec : list) {
118
                    mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(vec.getX(),
119
                            vec.getY(), vec.getZ(), true));
120
                }
121
122
                mc.thePlayer.swingItem();
123
                if (getBool("NoHitDelay Breaker"))
124
                    for (int i : new int[10])
125
                        mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(e, C02PacketUseEntity.Action.ATTACK));
126
                else
127
                    mc.thePlayer.sendQueue.addToSendQueue(new C02PacketUseEntity(e, C02PacketUseEntity.Action.ATTACK));
128
                for (Vec3 vec : backwards) {
129
                    mc.thePlayer.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(vec.getX(),
130
                            vec.getY(), vec.getZ(), true));
131
                }
132
            }
133
            timer.reset();
134
        }
135
    };
136
}

What this file does

The module file contains the whole mechanism: the waypoint compressor, the path validation loop, and the single UpdateEvent handler that runs the sweep. The handler reads the CPS setting through the shared Timer, iterates the target list, and for each target sends the forward C04 chain, the swing, the C02 attack (with the 10-packet variant behind the NoHitDelay Breaker toggle), and the reversed chain back. The canPassThrough predicate defines which materials a waypoint may sit in (air, plants, vine, ladder, water and signs), and it is the only place the module consults world state beyond the target scan. The packet sends go through addToSendQueue, so every C04 and C02 is visible to the client's own outgoing-packet events.

source PathFinder.java (path search)

PathFinder.java193 lines · JavaOriginal ↗
1
2
package me.memewaredevs.client.util.pathfinding;
3
4
import net.minecraft.block.*;
5
import net.minecraft.client.Minecraft;
6
import net.minecraft.util.BlockPos;
7
8
import java.util.ArrayList;
9
import java.util.Collections;
10
import java.util.Comparator;
11
12
/**
13
 * totally not from a gitlab repo LOL
14
 */
15
public class PathFinder {
16
    private Vec3 startVec3;
17
    private Vec3 endVec3;
18
    private ArrayList<Vec3> path = new ArrayList();
19
    private ArrayList<PathHub> pathHubs = new ArrayList();
20
    private ArrayList<PathHub> workingPathHubList = new ArrayList();
21
    private double minDistanceSquared = 9.0;
22
    private boolean nearest = true;
23
    private static Vec3[] directions = new Vec3[]{new Vec3(1.0, 0.0, 0.0), new Vec3(-1.0, 0.0, 0.0),
24
            new Vec3(0.0, 0.0, 1.0), new Vec3(0.0, 0.0, -1.0)};
25
26
    public PathFinder(Vec3 startVec3, Vec3 endVec3) {
27
        this.startVec3 = startVec3.addVector(0.0, 0.0, 0.0).floor();
28
        this.endVec3 = endVec3.addVector(0.0, 0.0, 0.0).floor();
29
    }
30
31
    public ArrayList<Vec3> getPath() {
32
        return this.path;
33
    }
34
35
    public void compute() {
36
        this.compute(1000, 4);
37
    }
38
39
    public void compute(int loops, int depth) {
40
        this.path.clear();
41
        this.workingPathHubList.clear();
42
        ArrayList<Vec3> initPath = new ArrayList<>();
43
        initPath.add(this.startVec3);
44
        this.workingPathHubList
45
                .add(new PathHub(this.startVec3, null, initPath, this.startVec3.squareDistanceTo(this.endVec3), 0.0, 0.0));
46
        block0:
47
        for (int i = 0; i < loops; ++i) {
48
            Collections.sort(this.workingPathHubList, new CompareHub());
49
            int j = 0;
50
            if (this.workingPathHubList.size() == 0) {
51
                break;
52
            }
53
            for (PathHub pathHub : new ArrayList<>(this.workingPathHubList)) {
54
                Vec3 loc2;
55
                if (++j > depth) {
56
                    continue block0;
57
                }
58
                this.workingPathHubList.remove(pathHub);
59
                this.pathHubs.add(pathHub);
60
                for (Vec3 direction : directions) {
61
                    Vec3 loc = pathHub.getLoc().add(direction).floor();
62
                    if (PathFinder.isValid(loc, false) && this.putHub(pathHub, loc, 0.0)) {
63
                        break block0;
64
                    }
65
                }
66
                Vec3 loc1 = pathHub.getLoc().addVector(0.0, 1.0, 0.0).floor();
67
                if (PathFinder.isValid(loc1, false) && this.putHub(pathHub, loc1, 0.0)
68
                        || PathFinder
69
                        .isValid(loc2 = pathHub.getLoc().addVector(0.0, -1.0, 0.0).floor(), false)
70
                        && this.putHub(pathHub, loc2, 0.0)) {
71
                    break block0;
72
                }
73
            }
74
        }
75
        if (this.nearest) {
76
            Collections.sort(this.pathHubs, new CompareHub());
77
            this.path = this.pathHubs.get(0).getPathway();
78
        }
79
    }
80
81
    public static boolean isValid(Vec3 loc, boolean checkGround) {
82
        return PathFinder.isValid((int) loc.getX(), (int) loc.getY(), (int) loc.getZ(),
83
                checkGround);
84
    }
85
86
    public static boolean isValid(int x, int y, int z, boolean checkGround) {
87
        BlockPos block1 = new BlockPos(x, y, z);
88
        BlockPos block2 = new BlockPos(x, y + 1, z);
89
        BlockPos block3 = new BlockPos(x, y - 1, z);
90
        return !PathFinder.isNotPassable(block1) && !PathFinder.isNotPassable(block2)
91
                && (PathFinder.isNotPassable(block3) || !checkGround)
92
                && PathFinder.canWalkOn(block3);
93
    }
94
95
    private static boolean isNotPassable(BlockPos block) {
96
        return Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(), block.getZ()).isSolidFullCube()
97
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
98
                block.getZ()) instanceof BlockSlab
99
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
100
                block.getZ()) instanceof BlockStairs
101
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
102
                block.getZ()) instanceof BlockCactus
103
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
104
                block.getZ()) instanceof BlockChest
105
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
106
                block.getZ()) instanceof BlockEnderChest
107
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
108
                block.getZ()) instanceof BlockSkull
109
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
110
                block.getZ()) instanceof BlockPane
111
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
112
                block.getZ()) instanceof BlockFence
113
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
114
                block.getZ()) instanceof BlockWall
115
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
116
                block.getZ()) instanceof BlockGlass
117
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
118
                block.getZ()) instanceof BlockPistonBase
119
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
120
                block.getZ()) instanceof BlockPistonExtension
121
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
122
                block.getZ()) instanceof BlockPistonMoving
123
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
124
                block.getZ()) instanceof BlockStainedGlass
125
                || Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
126
                block.getZ()) instanceof BlockTrapDoor;
127
    }
128
129
    private static boolean canWalkOn(BlockPos block) {
130
        return !(Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
131
                block.getZ()) instanceof BlockFence)
132
                && !(Minecraft.getMinecraft().theWorld.getBlock(block.getX(), block.getY(),
133
                block.getZ()) instanceof BlockWall);
134
    }
135
136
    public PathHub doesHubExistAt(Vec3 loc) {
137
        for (PathHub pathHub : this.pathHubs) {
138
            if (pathHub.getLoc().getX() != loc.getX() || pathHub.getLoc().getY() != loc.getY()
139
                    || pathHub.getLoc().getZ() != loc.getZ()) {
140
                continue;
141
            }
142
            return pathHub;
143
        }
144
        for (PathHub pathHub : this.workingPathHubList) {
145
            if (pathHub.getLoc().getX() != loc.getX() || pathHub.getLoc().getY() != loc.getY()
146
                    || pathHub.getLoc().getZ() != loc.getZ()) {
147
                continue;
148
            }
149
            return pathHub;
150
        }
151
        return null;
152
    }
153
154
    public boolean putHub(PathHub parent, Vec3 loc, double cost) {
155
        PathHub existingPathHub = this.doesHubExistAt(loc);
156
        double totalCost = cost;
157
        if (parent != null) {
158
            totalCost += parent.getMaxCost();
159
        }
160
        if (existingPathHub == null) {
161
            if (loc.getX() == this.endVec3.getX() && loc.getY() == this.endVec3.getY()
162
                    && loc.getZ() == this.endVec3.getZ()
163
                    || this.minDistanceSquared != 0.0
164
                    && loc.squareDistanceTo(this.endVec3) <= this.minDistanceSquared) {
165
                this.path.clear();
166
                this.path = parent.getPathway();
167
                this.path.add(loc);
168
                return true;
169
            }
170
            ArrayList<Vec3> path = new ArrayList<>(parent.getPathway());
171
            path.add(loc);
172
            this.workingPathHubList.add(new PathHub(loc, parent, path, loc.squareDistanceTo(this.endVec3), cost, totalCost));
173
        } else if (existingPathHub.getCurrentCost() > cost) {
174
            ArrayList<Vec3> path = new ArrayList<>(parent.getPathway());
175
            path.add(loc);
176
            existingPathHub.setLoc(loc);
177
            existingPathHub.setParentPathHub(parent);
178
            existingPathHub.setPathway(path);
179
            existingPathHub.setSqDist(loc.squareDistanceTo(this.endVec3));
180
            existingPathHub.setCurrentCost(cost);
181
            existingPathHub.setMaxCost(totalCost);
182
        }
183
        return false;
184
    }
185
186
    public class CompareHub implements Comparator<PathHub> {
187
        @Override
188
        public int compare(PathHub o1, PathHub o2) {
189
            return (int) (o1.getSqDist() + o1.getMaxCost()
190
                    - (o2.getSqDist() + o2.getMaxCost()));
191
        }
192
    }
193
}

What this file does

PathFinder is the A* search the module runs between the player and each target. The module calls compute() and then walks getPath() to obtain the raw node chain that computePath compresses into dash waypoints, and it calls the static isValid() during the swept-box validation of each candidate segment. The search is block-grid based and returns node positions that the module recenters with a 0.5 offset on x and z before serializing them into C04 packets. The 5-block dash limit in computePath is what keeps the hop count bounded on long paths.

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 Reach (attack distance from the tracked position)

Reach.java372 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
18
import org.bukkit.GameMode;
19
import org.bukkit.Location;
20
import org.bukkit.entity.EnderDragon;
21
import org.bukkit.entity.Entity;
22
import org.bukkit.entity.Giant;
23
import org.bukkit.entity.LivingEntity;
24
import org.bukkit.entity.Player;
25
import org.bukkit.util.Vector;
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.checks.combined.Improbable;
32
import fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace.ITraceEntry;
33
import fr.neatmonster.nocheatplus.permissions.Permissions;
34
import fr.neatmonster.nocheatplus.players.IPlayerData;
35
import fr.neatmonster.nocheatplus.utilities.StringUtil;
36
import fr.neatmonster.nocheatplus.utilities.TickTask;
37
import fr.neatmonster.nocheatplus.utilities.math.TrigUtil;
38
39
/**
40
 * The Reach check will find out if a player interacts with something that's too far away.
41
 */
42
public class Reach extends Check {
43
44
    /** The maximum distance allowed to interact with an entity in creative mode. */
45
    public static final double CREATIVE_DISTANCE = 6D;
46
47
48
    /** Additum for distance, based on entity. */
49
    private static double getDistMod(final Entity damaged) {
50
        // Handle the EnderDragon differently.
51
        if (damaged instanceof EnderDragon)
52
            return 6.5D;
53
        else if (damaged instanceof Giant){
54
            return 1.5D;
55
        }
56
        else return 0;
57
    }
58
59
60
    /**
61
     * Instantiates a new reach check.
62
     */
63
    public Reach() {
64
        super(CheckType.FIGHT_REACH);
65
    }
66
67
68
    /**
69
     * "Classic" check.
70
     * 
71
     * @param player
72
     *            the player
73
     * @param damaged
74
     *            the damaged
75
     * @return true, if successful
76
     */
77
    public boolean check(final Player player, final Location pLoc, 
78
                         final Entity damaged, final boolean damagedIsFake, final Location dRef, 
79
                         final FightData data, final FightConfig cc, final IPlayerData pData) {
80
81
        boolean cancel = false;
82
        // The maximum distance allowed to interact with an entity in survival mode.
83
        final double SURVIVAL_DISTANCE = cc.reachSurvivalDistance; 
84
        // Amount which can be reduced by reach adaption.
85
        final double DYNAMIC_RANGE = cc.reachReduceDistance; 
86
        // Adaption amount for dynamic range.
87
        final double DYNAMIC_STEP = cc.reachReduceStep / SURVIVAL_DISTANCE; 
88
        final double distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : SURVIVAL_DISTANCE + getDistMod(damaged);
89
        final double distanceMin = (distanceLimit - DYNAMIC_RANGE) / distanceLimit;
90
        final double height = damagedIsFake ? (damaged instanceof LivingEntity ? ((LivingEntity) damaged).getEyeHeight() : 1.75) : mcAccess.getHandle().getHeight(damaged);
91
        final double width = damagedIsFake ? 0.6 : mcAccess.getHandle().getWidth(damaged);
92
        double centertoedge = 0.0;
93
        
94
        if (cc.reachPrecision) {
95
            centertoedge = getinset(pLoc, dRef, width / 2, 0.0);
96
        }
97
98
        // Refine y position.
99
        final double pY = pLoc.getY() + player.getEyeHeight();
100
        final double dY = dRef.getY();
101
        if (pY <= dY) {
102
            // Keep the foot level y.
103
        } 
104
        // Highest ref y
105
        else if (pY >= dY + height) {
106
             dRef.setY(dY + height);
107
        }
108
        // Level with damaged.
109
        else dRef.setY(pY);
110
111
        final Vector pRel = dRef.toVector().subtract(pLoc.toVector().setY(pY)); // TODO: Run calculations on numbers only :p.
112
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
113
        // than allowed, the difference will be assigned to "distance".
114
        final double lenpRel = pRel.length() - centertoedge;
115
        double violation = lenpRel - distanceLimit;
116
        final double reachMod = data.reachMod; 
117
118
119
        if (violation > 0) {
120
            if (TickTask.getLag(1000, true) < 1.5f){ // Do not increase the vl in case of server lag (1.5 is a magic value)
121
                data.reachVL += violation;
122
                final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
123
                vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
124
                // Execute whatever actions are associated with this check and the violation level and find out if we should
125
                // cancel the event.
126
                cancel = executeActions(vd).willCancel();
127
            }
128
129
            if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), "fight.reach", pData)){
130
                cancel = true;
131
            }
132
133
            if (cancel && cc.reachPenalty > 0){
134
                // Apply an attack penalty time.
135
                data.attackPenalty.applyPenalty(cc.reachPenalty);
136
            }
137
        }
138
        else if (lenpRel - distanceLimit * reachMod > 0){
139
            // Silent cancel.
140
            if (cc.reachPenalty > 0) {
141
                data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
142
            }
143
            cancel = true;
144
            Improbable.feed(player, (float) (lenpRel - distanceLimit * reachMod) / 4f, System.currentTimeMillis());
145
        }
146
        else data.reachVL *= 0.8D; // Player passed the check, reward them.
147
            
148
149
        if (!cc.reachReduce){
150
            data.reachMod = 1d;
151
        }
152
        else if (lenpRel > distanceLimit - DYNAMIC_RANGE){
153
            data.reachMod = Math.max(distanceMin, data.reachMod - DYNAMIC_STEP);
154
        }
155
        else data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
156
157
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
158
            player.sendMessage("NC+: Attack/reach " + damaged.getType()+ " height="+ StringUtil.fdec3.format(height) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(reachMod));
159
        }
160
161
        return cancel;
162
    }
163
164
    /**
165
     * Data context for iterating over ITraceEntry instances.
166
     * @param player
167
     * @param pLoc
168
     * @param damaged
169
     * @param damagedLoc
170
     * @param data
171
     * @param cc
172
     * @return
173
     */
174
    public ReachContext getContext(final Player player, final Location pLoc, 
175
                                   final Entity damaged, final Location damagedLoc, 
176
                                   final FightData data, final FightConfig cc) {
177
178
        final ReachContext context = new ReachContext();
179
        context.distanceLimit = player.getGameMode() == GameMode.CREATIVE ? CREATIVE_DISTANCE : cc.reachSurvivalDistance + getDistMod(damaged);
180
        context.distanceMin = (context.distanceLimit - cc.reachReduceDistance) / context.distanceLimit;
181
        //context.eyeHeight = player.getEyeHeight();
182
        context.pY = pLoc.getY() + player.getEyeHeight();
183
        return context;
184
    }
185
186
    /**
187
     * Check if the player fails the reach check, no change of FightData.
188
     * @param player
189
     * @param pLoc
190
     * @param damaged
191
     * @param dRef
192
     * @param context
193
     * @param data
194
     * @param cc
195
     * @return
196
     */
197
    public boolean loopCheck(final Player player, final Location pLoc, final Entity damaged, 
198
                             final ITraceEntry dRef, final ReachContext context, 
199
                             final FightData data, final FightConfig cc) {
200
201
        boolean cancel = false;
202
203
        // Refine y position.
204
        final double dY = dRef.getY();
205
        double y = dRef.getY();
206
207
        if (context.pY <= dY) {
208
            // Keep the foot level y.
209
        }
210
        else if (context.pY >= dY + dRef.getBoxMarginVertical()) {
211
            y = dY + dRef.getBoxMarginVertical(); // Highest ref y.
212
        }
213
        else {
214
            y = context.pY; // Level with damaged.
215
        }
216
217
        double centertoedge = 0.0;
218
        if (cc.reachPrecision) centertoedge = getinset(pLoc, new Location(null, dRef.getX(), dRef.getY(), dRef.getZ()), dRef.getBoxMarginHorizontal(), y - context.pY);
219
        
220
        // Distance is calculated from eye location to center of targeted. If the player is further away from their target
221
        // than allowed, the difference will be assigned to "distance".
222
        // TODO: Run check on squared distances (quite easy to change to stored boundary-sq values).
223
        final double lenpRel = TrigUtil.distance(dRef.getX(), y, dRef.getZ(), pLoc.getX(), context.pY, pLoc.getZ()) - centertoedge;
224
        double violation = lenpRel - context.distanceLimit;
225
226
        if (violation > 0 || lenpRel - context.distanceLimit * data.reachMod > 0){
227
            // TODO: The silent cancel parts should be sen as "no violation" ?
228
            // Set minimum violation in context
229
            context.minViolation = Math.min(context.minViolation, lenpRel);
230
            cancel = true;
231
        }
232
        context.minResult = Math.min(context.minResult, lenpRel);
233
234
        return cancel;
235
236
    }
237
238
    /**
239
     * Apply changes to FightData according to check results (context), trigger violations.
240
     * @param player
241
     * @param pLoc
242
     * @param damaged
243
     * @param context
244
     * @param forceViolation
245
     * @param data
246
     * @param cc
247
     * @return
248
     */
249
    public boolean loopFinish(final Player player, final Location pLoc, final Entity damaged, 
250
                              final ReachContext context, final ITraceEntry traceEntry, final boolean forceViolation, 
251
                              final FightData data, final FightConfig cc, final IPlayerData pData) {
252
253
        final double lenpRel = forceViolation && context.minViolation != Double.MAX_VALUE ? context.minViolation : context.minResult;
254
255
        if (lenpRel == Double.MAX_VALUE) {
256
            return false;
257
        }
258
259
        double violation = lenpRel - context.distanceLimit;
260
        boolean cancel = false;
261
262
        if (violation > 0) {    
263
            if (TickTask.getLag(1000, true) < 1.5f){
264
                data.reachVL += violation;
265
                final ViolationData vd = new ViolationData(this, player, data.reachVL, violation, cc.reachActions);
266
                vd.setParameter(ParameterName.REACH_DISTANCE, StringUtil.fdec3.format(lenpRel));
267
                // Execute whatever actions are associated with this check and the violation level and find out if we should
268
                // cancel the event.
269
                cancel = executeActions(vd).willCancel();
270
            }
271
            
272
            //if (Improbable.check(player, (float) violation / 2f, System.currentTimeMillis(), 
273
            //        "fight.reach", pData)){
274
            //    cancel = true;
275
            //}
276
            // TODO: New improbable weight calculations so that weight is not inverse to config weight
277
            if (cc.reachImprobableWeight > 0.0f) {
278
                if (!cc.reachImprobableFeedOnly && Improbable.check(player, (float) violation / cc.reachImprobableWeight, System.currentTimeMillis(), "fight.reach", pData)) {
279
                    cancel = true;
280
                }
281
            }
282
283
            if (cancel && cc.reachPenalty > 0){
284
                // Apply an attack penalty time.
285
                data.attackPenalty.applyPenalty(cc.reachPenalty);
286
            }
287
        }
288
        else if (lenpRel - context.distanceLimit * data.reachMod > 0){
289
            // Silent cancel.
290
            if (cc.reachPenalty > 0) {
291
                data.attackPenalty.applyPenalty(cc.reachPenalty / 2);
292
            }
293
294
            cancel = true;
295
296
            if (cc.reachImprobableWeight > 0.0f) {
297
                Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / cc.reachImprobableWeight, System.currentTimeMillis());
298
            }
299
            // Improbable.feed(player, (float) (lenpRel - context.distanceLimit * data.reachMod) / 4f, System.currentTimeMillis());
300
        }
301
        else {
302
            // Player passed the check, reward them.
303
            data.reachVL *= 0.8D;
304
305
        }
306
307
        // Adaption amount for dynamic range.
308
        final double DYNAMIC_STEP = cc.reachReduceStep / cc.reachSurvivalDistance;
309
310
        if (!cc.reachReduce){
311
            data.reachMod = 1d;
312
        }
313
        else if (lenpRel > context.distanceLimit - cc.reachReduceDistance){
314
            data.reachMod = Math.max(context.distanceMin, data.reachMod - DYNAMIC_STEP);
315
        }
316
        else {
317
            data.reachMod = Math.min(1.0, data.reachMod + DYNAMIC_STEP);
318
        }
319
320
        if (pData.isDebugActive(type) && pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)){
321
            // TODO: Height: remember successful ITraceEntry
322
            player.sendMessage("NC+: Attack/reach " + damaged.getType()+ (traceEntry == null ? "" : (" height=" + traceEntry.getBoxMarginVertical())) + " dist=" + StringUtil.fdec3.format(lenpRel) +" @" + StringUtil.fdec3.format(data.reachMod));
323
        }
324
325
        return cancel;
326
    }
327
328
329
    private boolean isSameXZ(final Location loc1, final Location loc2) {
330
        return loc1.getX() == loc2.getX() && loc1.getZ() == loc2.getZ();
331
    }
332
333
334
    /**
335
     *
336
     * @param pLoc
337
     *            the player location
338
     * @param dRef
339
     *            the target location
340
     * @param damagedBoxMarginHorizontal
341
     *            the target Width / 2
342
     * @param diffY the Y different
343
     * @return the double represent for the distance from target location to the edge of target hitbox
344
     */
345
    private double getinset(final Location pLoc, final Location dRef, final double damagedBoxMarginHorizontal, final double diffY) {
346
347
        if (!isSameXZ(pLoc, dRef)) {
348
            final Location dRefc = dRef.clone();
349
            final Vector vec1 = new Vector(pLoc.getX() - dRef.getX(), diffY , pLoc.getZ() - dRef.getZ());
350
            if (vec1.length() < damagedBoxMarginHorizontal * Math.sqrt(2)) return 0.0;
351
            if (vec1.getZ() > 0.0) {
352
                dRefc.setZ(dRefc.getZ() + damagedBoxMarginHorizontal);
353
            } 
354
            else if (vec1.getZ() < 0.0) {
355
                dRefc.setZ(dRefc.getZ() - damagedBoxMarginHorizontal);
356
            } 
357
            else if (vec1.getX() > 0.0) {
358
                dRefc.setX(dRefc.getX() + damagedBoxMarginHorizontal);
359
            } 
360
            else dRefc.setX(dRefc.getX() - damagedBoxMarginHorizontal);
361
362
            final Vector vec2 = new Vector(dRefc.getX() - dRef.getX(), 0.0 , dRefc.getZ() - dRef.getZ());
363
            double angle = TrigUtil.angle(vec1, vec2);
364
            // Require < 45deg, if not 90deg-angel
365
            if (angle > Math.PI / 4) angle = Math.PI / 2 - angle;
366
            if (angle >= 0.0 && angle <= Math.PI / 4) { // TODO: Dose this one necessary?
367
                return damagedBoxMarginHorizontal / Math.cos(angle);
368
            }
369
        }
370
        return 0.0;
371
    }
372
}

How it counteracts this module

The attack is only in range because the C04 stream relocates the server-side player next to the victim, and that relocation is exactly what NCP rejects. The SurvivalFly envelope, which runs per move in the same pipeline, rebuilds the allowed distance from the physics model: each 5-block hop with onGround true exceeds the predicted sprint distance of about 0.28 blocks by a wide margin, so the first C04 of the stream triggers a violation and a set-back to the stored location. By the time the C02 arrives, the tracked position is the reverted origin, and the reach check measures the attack from there: hundreds of blocks against the 4.02 survival distance (DefaultConfig line 366).

The reachMod adaption cannot forgive this. The reduce band (reachReduceDistance 0.8, reachReduceStep 0.14) only steps reachMod down for hits between roughly 3.22 and 4.02 blocks, and the silent-cancel path only fires while the distance stays under the limit times reachMod. A 218-block attack is orders of magnitude past both, so reachVL grows by the full violation on every sweep and the first cancel tier (vl greater than 1) stops the attacks. The honest caveat is config-shaped: on a server that disables the movement envelope, the C04s are accepted, the attack measures from the faked position, and this check passes by design. The module's reach claim is only as good as the teleports that precede it.

anticheat EntityInteractDirection (facing cone)

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

The module never rotates toward its victims, and Hawk scores the interaction against the direction the server actually observed. EntityInteractDirection builds the direction ray from the player's server-side yaw and pitch (the 1.8 fork updates cursor yaw per tick, so no extrapolation is needed) and requires the victim's AABB, expanded by the 0.2 boxExpand setting, to sit between the current and previous direction vectors. A target that the player is not facing fails the cone test no matter how close the teleport brought the attacker.

In practice the module attacks every player in range in one sweep, so only victims that happen to lie inside the current facing cone pass; everyone behind or off to the side of the fixed yaw adds a violation. The one honest escape is directional: a player who aims at the crowd before each fire keeps the cone over at least some targets, and those particular attacks pass. The check also inherits the 1.8 attack-before-yaw ordering (the C02 precedes the look update that describes it), which is exactly the ordering this module produces.

anticheat EntityInteractReach (lag-compensated AABB distance)

EntityInteractReach.java88 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.GameMode;
27
import org.bukkit.Location;
28
import org.bukkit.entity.Entity;
29
import org.bukkit.entity.Player;
30
import org.bukkit.util.Vector;
31
32
public class EntityInteractReach extends EntityInteractionCheck {
33
34
    //PASSED (6/24/2019)
35
36
    private final double MAX_REACH;
37
    private final double MAX_REACH_CREATIVE;
38
    private final int PING_LIMIT;
39
    private final boolean LAG_COMPENSATION;
40
    private final boolean CHECK_OTHER_ENTITIES;
41
42
    public EntityInteractReach() {
43
        super("entityinteractreach", "%player% failed entity interact reach. Reach: %distance%m VL: %vl%");
44
        MAX_REACH = (double) customSetting("maxReach", "", 3.1);
45
        MAX_REACH_CREATIVE = (double) customSetting("maxReachCreative", "", 5.0);
46
        PING_LIMIT = (int) customSetting("pingLimit", "", -1);
47
        LAG_COMPENSATION = (boolean) customSetting("lagCompensation", "", true);
48
        CHECK_OTHER_ENTITIES = (boolean) customSetting("checkOtherEntities", "", false);
49
    }
50
51
    @Override
52
    protected void check(InteractEntityEvent e) {
53
        Entity victimEntity = e.getEntity();
54
        if (!(victimEntity instanceof Player) && !CHECK_OTHER_ENTITIES)
55
            return;
56
        int ping = ServerUtils.getPing(e.getPlayer());
57
        if (PING_LIMIT > -1 && ping > PING_LIMIT)
58
            return;
59
        Player p = e.getPlayer();
60
        HawkPlayer att = e.getHawkPlayer();
61
62
        Location victimLocation;
63
        if (LAG_COMPENSATION)
64
            victimLocation = hawk.getLagCompensator().getHistoryLocation(ping, victimEntity);
65
        else
66
            victimLocation = victimEntity.getLocation();
67
68
        AABB victimAABB = WrappedEntity.getWrappedEntity(victimEntity).getHitbox(victimLocation.toVector());
69
70
        Vector attackerPos;
71
        if(att.isInVehicle()) {
72
            attackerPos = hawk.getLagCompensator().getHistoryLocation(ServerUtils.getPing(p), p).toVector();
73
            attackerPos.setY(attackerPos.getY() + p.getEyeHeight());
74
        }
75
        else {
76
            attackerPos = att.getHeadPosition();
77
        }
78
79
        double maxReach = att.getPlayer().getGameMode() == GameMode.CREATIVE ? MAX_REACH_CREATIVE : MAX_REACH;
80
        double dist = victimAABB.distanceToPosition(attackerPos);
81
82
        if (dist > maxReach) {
83
            punish(att, 1, true, e, new Placeholder("distance", MathPlus.round(dist, 2)));
84
        } else {
85
            reward(att);
86
        }
87
    }
88
}

How it counteracts this module

Hawk's reach check compares the victim AABB distance against maxReach 3.1 using the player's position history, with lag compensation enabled by default. Because the C04 stream precedes the C02 in the same tick, the history contains the teleported position, so the measured distance is the sub-block gap between the faked spot and the victim and the attack passes. This entry documents the boundary rather than a catch: a purely geometric reach check validates whatever position the movement layer just accepted.

The check only bites when the teleports are reverted or dropped. If the movement layer rejects the C04s and the server keeps the origin position, the history never contains a spot near the victim and the measured distance is the full 218 blocks, which flags instantly. The two Hawk checks therefore split along the same fault line as NCP: geometry alone is blind to the module, and the movement envelope is what makes the geometry checks see it.

anticheat Angle (attack-stream window)

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

Angle scores the attack stream in a 1000ms window (maxTimeDiff) against four signals: average movement between attacks, average time between attacks, average yaw change, and target-switch speed. The module's sweep pattern maximizes every signal: all targets are attacked from the same position within one timer fire, so avgmove sits near zero, the 50ms gaps at 20 CPS sit far under the 150ms time threshold, yaw never changes between attacks, and switching victims without turning feeds the switch signal.

The honest limitation is the stock configuration. The thresholds in this tree (move 100, time 150, yaw 60, switch 50) dwarf the per-call signal scores, which cap at 20-30, and angleVL decays at 0.98 per tick, so at defaults the check never fires. Detection configs that lower the thresholds turn the module's deterministic sweep into a constant flag source, which is the standard deployment this analysis assumes.

← Back to Analysis Hub