Rise 5.99 Nuker module 2 files, 256 lines

Rise 5.99 Nuker: Full Source Analysis

Rise 5.99's Nuker is an instant-dig block destroyer with three modes.

dev/rise/module/impl/other/Nuker.java · GitHub source ↗

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

Packets This Module Uses

Analysis

Overview

Rise 5.99's Nuker is an instant-dig block destroyer with three modes. Normal mode sweeps a cubic shell around the player every Tick setting ticks (default every tick) and, for every non-air block inside it, fires a C07PacketPlayerDigging START_DESTROY_BLOCK plus STOP_DESTROY_BLOCK pair with EnumFacing.UP hardcoded, so each block is reported as an instant harvest. Teleport and Area modes replace the sweep origin: they compute an A* path with MainPathFinder, stream C04 teleport packets along it to reach the target position, run the same dig pair spam there, and stream the reversed path back, all from a background thread through PacketUtil.sendPacketWithoutEvent. A receive-side handler cancels the S02 line 'You can't build outside the plot!', hiding plot-protection failures so the user keeps digging blind. At the default range 4 the sweep covers 216 blocks per pass; at the maximum range 7 it covers 1728, each block costing two C07 packets plus an optional swing.

Architecture

The module is one UpdateEvent handler plus a receive handler. Settings are Mode (Normal, Teleport, Area), Delay (0-5000ms), Range (1-7, step 0.5), Tick (1-20), Instant Only, Scatter and Swing. The effective sweep radius is range minus 1, and the Normal mode gate is ticksExisted modulo Tick with the default 1 meaning a full sweep every tick. A world-change guard toggles the module off within the first 5 ticks, and the GUI visibility wiring hides Delay unless Teleport or Area is active and Tick unless Normal is active. The single TimeUtil field acts as the Teleport and Area cycle clock through hasReached plus reset.

Instant dig stream

nuke() runs three nested loops over x from -radius to radius - 1, y from radius down to -radius + 1, and z likewise, building a BlockPos per cell. Air blocks are skipped, and with Instant Only enabled any block with hardness above 0 is skipped too, so only instantly breakable blocks are attacked. For every surviving cell the module sends START_DESTROY_BLOCK followed immediately by STOP_DESTROY_BLOCK with EnumFacing.UP, the instant-dig pair that in vanilla reports a completed harvest without any progress phase, then optionally calls swingItem() on the local player (the Swing setting, default on). The Scatter setting skips alternating columns by testing the parity of ticksExisted against x and z, halving the packet rate at the cost of coverage. Every send goes through PacketUtil.sendPacketWithoutEvent, which dispatches straight into NetworkManager and bypasses Rise's own event bus.

Teleport and area modes

Teleport mode arms on the use-item key and a Delay gate, ray-traces up to 999 blocks for the target block, and refuses to run when the traced block is air. Area mode picks a random point inside the bounding box recorded by the SetArea command. Both modes then compute a path with MainPathFinder.computePath from the player position (or from Freecam.startX/startY/startZ when Freecam is enabled), stream every waypoint as a C04 position packet with onGround true to reach the target, run nuke() there, reverse the path and stream it back, all on a fresh Thread per activation. The receive-side handler is the anti-detection tell: it cancels the S02 chat line 'You can't build outside the plot!' when the packet is not a normal chat message, so the server's rejection of out-of-bounds digs is never shown, while the dig packets themselves were already refused by the server.

source Nuker.java

Nuker.java213 lines · JavaOriginal ↗
1
/*
2
 Copyright Alan Wood 2021
3
 None of this code to be reused without my written permission
4
 Intellectual Rights owned by Alan Wood
5
 */
6
package dev.rise.module.impl.other;
7
8
import dev.rise.Rise;
9
import dev.rise.command.impl.SetArea;
10
import dev.rise.event.impl.other.UpdateEvent;
11
import dev.rise.event.impl.packet.PacketReceiveEvent;
12
import dev.rise.module.Module;
13
import dev.rise.module.api.ModuleInfo;
14
import dev.rise.module.enums.Category;
15
import dev.rise.module.impl.render.Freecam;
16
import dev.rise.setting.impl.BooleanSetting;
17
import dev.rise.setting.impl.ModeSetting;
18
import dev.rise.setting.impl.NumberSetting;
19
import dev.rise.util.math.TimeUtil;
20
import dev.rise.util.pathfinding.MainPathFinder;
21
import dev.rise.util.pathfinding.Vec3;
22
import dev.rise.util.player.PacketUtil;
23
import net.minecraft.block.Block;
24
import net.minecraft.block.BlockAir;
25
import net.minecraft.network.Packet;
26
import net.minecraft.network.play.client.C03PacketPlayer;
27
import net.minecraft.network.play.client.C07PacketPlayerDigging;
28
import net.minecraft.network.play.server.S02PacketChat;
29
import net.minecraft.util.BlockPos;
30
import net.minecraft.util.EnumFacing;
31
32
import java.util.ArrayList;
33
import java.util.Collections;
34
import java.util.Objects;
35
import java.util.Random;
36
37
@ModuleInfo(name = "Nuker", description = "Breaks blocks around you", category = Category.OTHER)
38
public final class Nuker extends Module {
39
40
    private final ModeSetting mode = new ModeSetting("Mode", this, "Normal", "Normal", "Teleport", "Area");
41
    private final NumberSetting delay = new NumberSetting("Delay", this, 100, 0, 5000, 50);
42
    private final NumberSetting range = new NumberSetting("Range", this, 4, 1, 7, 0.5);
43
    private final NumberSetting tick = new NumberSetting("Tick", this, 1, 1, 20, 1);
44
    private final BooleanSetting instantOnly = new BooleanSetting("Instant Only", this, false);
45
    private final BooleanSetting scatter = new BooleanSetting("Scatter", this, false);
46
    private final BooleanSetting swing = new BooleanSetting("Swing", this, true);
47
48
    private final TimeUtil timer = new TimeUtil();
49
50
    @Override
51
    public void onUpdateAlwaysInGui() {
52
        delay.hidden = !(mode.is("Teleport") || mode.is("Area"));
53
54
        tick.hidden = !mode.is("Normal");
55
    }
56
57
    @Override
58
    public void onUpdate(final UpdateEvent event) {
59
        final double radius = this.range.getValue() - 1;
60
61
        if (mc.thePlayer.ticksExisted < 5) {
62
            this.toggleModule();
63
            this.registerNotification("Disabled " + this.getModuleInfo().name() + " due to world change.");
64
            return;
65
        }
66
67
        if (mc.thePlayer.ticksExisted % tick.getValue() == 0 || !mode.is("Normal")) {
68
            switch (mode.getMode()) {
69
                case "Normal": {
70
                    nuke(radius, mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ);
71
                    break;
72
                }
73
74
                case "Teleport": {
75
                    if (mc.gameSettings.keyBindUseItem.isKeyDown() && timer.hasReached((long) delay.getValue())) {
76
                        final boolean freecamEnabled = Objects.requireNonNull(Rise.INSTANCE.getModuleManager().getModule("Freecam")).isEnabled();
77
78
                        final BlockPos pos = mc.thePlayer.rayTrace(999, 1).getBlockPos();
79
80
                        if (mc.theWorld.getBlockState(pos).getBlock() instanceof BlockAir)
81
                            return;
82
83
                        new Thread(() -> {
84
                            double x = mc.thePlayer.posX;
85
                            double y = mc.thePlayer.posY;
86
                            double z = mc.thePlayer.posZ;
87
88
                            if (freecamEnabled) {
89
                                x = Freecam.startX;
90
                                y = Freecam.startY;
91
                                z = Freecam.startZ;
92
                            }
93
94
                            final ArrayList<Vec3> path = MainPathFinder.computePath(new Vec3(x, y, z), new Vec3(pos.getX(), pos.getY(), pos.getZ()));
95
96
                            for (final Vec3 vec : path)
97
                                PacketUtil.sendPacketWithoutEvent(new C03PacketPlayer.C04PacketPlayerPosition(vec.getX(), vec.getY(), vec.getZ(), true));
98
99
                            nuke(radius, pos.getX(), pos.getY(), pos.getZ());
100
                            Collections.reverse(path);
101
102
                            for (final Vec3 vec : path)
103
                                PacketUtil.sendPacketWithoutEvent(new C03PacketPlayer.C04PacketPlayerPosition(vec.getX(), vec.getY(), vec.getZ(), true));
104
                        }).start();
105
106
                        timer.reset();
107
                    }
108
                    break;
109
                }
110
111
                case "Area": {
112
                    final Vec3 pos1 = SetArea.pos1;
113
                    final Vec3 pos2 = SetArea.pos2;
114
115
                    if (pos1 == null || pos2 == null) {
116
                        this.registerNotification("Set a position for Area Nuker by doing .setarea <1/2/reset> at the positions.");
117
                        this.toggleModule();
118
                        return;
119
                    }
120
121
                    if (timer.hasReached((long) delay.getValue())) {
122
                        final boolean freecamEnabled = Objects.requireNonNull(Rise.INSTANCE.getModuleManager().getModule("Freecam")).isEnabled();
123
                        final double nukeX = randomPoint(pos1.getX(), pos2.getX());
124
                        final double nukeY = randomPoint(pos1.getY(), pos2.getY());
125
                        final double nukeZ = randomPoint(pos1.getZ(), pos2.getZ());
126
127
                        new Thread(() -> {
128
                            double x = mc.thePlayer.posX;
129
                            double y = mc.thePlayer.posY;
130
                            double z = mc.thePlayer.posZ;
131
132
                            if (freecamEnabled) {
133
                                x = Freecam.startX;
134
                                y = Freecam.startY;
135
                                z = Freecam.startZ;
136
                            }
137
138
                            final ArrayList<Vec3> path = MainPathFinder.computePath(new Vec3(x, y, z), new Vec3(nukeX, nukeY, nukeZ));
139
140
                            for (final Vec3 vec : path)
141
                                PacketUtil.sendPacketWithoutEvent(new C03PacketPlayer.C04PacketPlayerPosition(vec.getX(), vec.getY(), vec.getZ(), true));
142
143
                            nuke(radius, nukeX, nukeY, nukeZ);
144
                            Collections.reverse(path);
145
146
                            for (final Vec3 vec : path)
147
                                PacketUtil.sendPacketWithoutEvent(new C03PacketPlayer.C04PacketPlayerPosition(vec.getX(), vec.getY(), vec.getZ(), true));
148
                        }).start();
149
                    }
150
                    break;
151
                }
152
            }
153
        }
154
    }
155
156
    @Override
157
    public void onPacketReceive(final PacketReceiveEvent event) {
158
        final Packet<?> p = event.getPacket();
159
160
        if (p instanceof S02PacketChat) {
161
            final S02PacketChat packetChat = (S02PacketChat) p;
162
            final String message = packetChat.getChatComponent().getUnformattedText();
163
            if (!packetChat.isChat() && message.equals("You can't build outside the plot!"))
164
                event.setCancelled(true);
165
        }
166
    }
167
168
    private void nuke(final double range, final double xPos, final double yPos, final double zPos) {
169
        if (range == 0) {
170
            final BlockPos blockPos = new BlockPos(xPos, yPos, zPos);
171
            final Block block = mc.theWorld.getBlockState(blockPos).getBlock();
172
173
            if (block instanceof BlockAir || (block.getBlockHardness() > 0 && instantOnly.isEnabled()))
174
                return;
175
176
            PacketUtil.sendPacketWithoutEvent(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.UP));
177
            PacketUtil.sendPacketWithoutEvent(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockPos, EnumFacing.UP));
178
179
            if (swing.isEnabled())
180
                mc.thePlayer.swingItem();
181
        } else {
182
            for (double x = -range; x < range; x++) {
183
                for (double y = range; y > -range; y--) {
184
                    for (double z = -range; z < range; z++) {
185
                        if (scatter.isEnabled() && !((mc.thePlayer.ticksExisted % 2 == 0 ? x : z) % 2 == 0))
186
                            continue;
187
188
                        final BlockPos blockPos = new BlockPos(xPos + x, yPos + y, zPos + z);
189
                        final Block block = mc.theWorld.getBlockState(blockPos).getBlock();
190
191
                        if (block instanceof BlockAir || (block.getBlockHardness() > 0 && instantOnly.isEnabled()))
192
                            continue;
193
194
                        PacketUtil.sendPacketWithoutEvent(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.UP));
195
                        PacketUtil.sendPacketWithoutEvent(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockPos, EnumFacing.UP));
196
197
                        if (swing.isEnabled())
198
                            mc.thePlayer.swingItem();
199
                    }
200
                }
201
            }
202
        }
203
    }
204
205
    private double randomPoint(final double one, final double two) {
206
        if (one == two)
207
            return one;
208
209
        final double delta = two - one;
210
        final double offset = new Random().nextFloat() * delta;
211
        return one + offset;
212
    }
213
}

What this file does

The full module: onUpdate drives the mode switch and the tick gate, nuke() emits the C07 START/STOP pairs from the three nested loops with the EnumFacing.UP constant, scatter parity and Instant Only filter, and onPacketReceive cancels the S02 plot message. The Teleport and Area branches contain the whole pathfinding flow, including the thread-per-activation pattern and the Freecam anchor read. The range-derived radius, the Delay timer reset and the world-change disable all live here.

source PacketUtil.java (event-bus bypass sender)

PacketUtil.java43 lines · JavaOriginal ↗
1
package dev.rise.util.player;
2
3
import lombok.experimental.UtilityClass;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.network.Packet;
6
7
@UtilityClass
8
public final class PacketUtil {
9
    private final Minecraft mc = Minecraft.getMinecraft();
10
11
    public void sendPacket(final Packet<?> packet) {
12
        mc.getNetHandler().addToSendQueue(packet);
13
    }
14
15
    public void sendPacketWithoutEvent(final Packet<?> packet) {
16
        mc.getNetHandler().addToSendQueueWithoutEvent(packet);
17
    }
18
19
    public void receivePacket(final Packet<?> packet) {
20
        mc.getNetHandler().addToReceiveQueue(packet);
21
    }
22
23
    public void receivePacketWithoutEvent(final Packet<?> packet) {
24
        mc.getNetHandler().addToReceiveQueueWithoutEvent(packet);
25
    }
26
    public class TimedPacket {
27
        private final Packet<?> packet;
28
        private final long time;
29
30
        public TimedPacket(final Packet<?> packet, final long time) {
31
            this.packet = packet;
32
            this.time = time;
33
        }
34
35
        public Packet<?> getPacket() {
36
            return packet;
37
        }
38
39
        public long getTime() {
40
            return time;
41
        }
42
    }
43
}

What this file does

sendPacketWithoutEvent wraps the raw NetworkManager dispatch so every C07 pair and every C04 waypoint bypasses Rise's outgoing event bus. The module never uses the event-visible send path, which is why no other Rise module can react to the stream and why the only observers are server-side. The same helper backs the Rise Blink flush and Disabler re-sends, so the bypass pattern here is the shared lineage rather than Nuker-specific code.

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 FastBreak (dig-time check)

FastBreak.java135 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.blockbreak;
16
17
import org.bukkit.Material;
18
import org.bukkit.block.Block;
19
import org.bukkit.entity.Player;
20
import org.bukkit.inventory.ItemStack;
21
22
import fr.neatmonster.nocheatplus.actions.ParameterName;
23
import fr.neatmonster.nocheatplus.checks.Check;
24
import fr.neatmonster.nocheatplus.checks.CheckType;
25
import fr.neatmonster.nocheatplus.checks.ViolationData;
26
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
27
import fr.neatmonster.nocheatplus.compat.Bridge1_9;
28
import fr.neatmonster.nocheatplus.compat.bukkit.BridgePotionEffect;
29
import fr.neatmonster.nocheatplus.permissions.Permissions;
30
import fr.neatmonster.nocheatplus.players.IPlayerData;
31
import fr.neatmonster.nocheatplus.utilities.TickTask;
32
import fr.neatmonster.nocheatplus.utilities.entity.PotionUtil;
33
import fr.neatmonster.nocheatplus.utilities.map.BlockProperties;
34
35
/**
36
 * A check used to verify if the player is breaking blocks faster than possible.
37
 */
38
public class FastBreak extends Check {
39
40
    /**
41
     * Instantiates a new fast break check.
42
     */
43
    public FastBreak() {
44
        super(CheckType.BLOCKBREAK_FASTBREAK);
45
    }
46
47
    /**
48
     * Checks a player for fastbreak. This is NOT for creative mode.
49
     * @return true, if successful
50
     */
51
    public boolean check(final Player player, final Block block, final AlmostBoolean isInstaBreak, final BlockBreakConfig cc, final BlockBreakData data, final IPlayerData pData) {
52
        final long now = System.currentTimeMillis();
53
        boolean cancel = false;
54
        // Determine expected breaking time by block type.
55
        final Material blockType = block.getType();
56
        final long expectedBreakingTime = Math.max(0, Math.round((double) BlockProperties.getBreakingDuration(blockType, player) * (double) cc.fastBreakModSurvival / 100D));
57
        final long elapsedTime;
58
        // Counting interact...break.
59
        // TODO: Concept for unbreakable blocks? Context: extreme VL.
60
        // TODO: Should it be breakingTime instead of 0 for inconsistencies?
61
        elapsedTime = cc.fastBreakStrict ? (data.fastBreakBreakTime > data.fastBreakfirstDamage) ? 0 : now - data.fastBreakfirstDamage
62
                                         // Counting break...break.
63
                                         : (data.fastBreakBreakTime > now) ? 0 : now - data.fastBreakBreakTime;
64
65
        // Check if the time spent is lower than expected.
66
        if (isInstaBreak.decideOptimistically()) {
67
            // Ignore these for now.
68
            // TODO: Find out why this was commented out long ago a) did not fix mcMMO b) exploits.
69
            // TODO: Maybe adjust time to min(time, SOMETHING) for MAYBE/YES.
70
        }
71
        else if (elapsedTime < 0) {
72
            // Ignore it. TODO: ?
73
        }
74
        else if (elapsedTime + cc.fastBreakDelay < expectedBreakingTime) {
75
            // Lag or cheat or Minecraft.
76
            // Count in server side lag, if desired.
77
            final float serverLagFactor = pData.getCurrentWorldDataSafe().shouldAdjustToLag(type) ? TickTask.getLag(expectedBreakingTime, true) : 1f;
78
            final long missingTime = expectedBreakingTime - (long)(serverLagFactor * elapsedTime);
79
            if (missingTime > 0) {
80
                // Add as penalty
81
                data.fastBreakPenalties.add(now, (float) missingTime);
82
                // Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
83
                if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakGrace) {
84
                    // TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
85
                    final double violation = (double) missingTime / 1000.0;
86
                    data.fastBreakVL += violation;
87
                    final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, violation, cc.fastBreakActions);
88
                    if (vd.needsParameters()) {
89
                        vd.setParameter(ParameterName.BLOCK_TYPE, blockType.toString());
90
                    }
91
                    cancel = executeActions(vd).willCancel();
92
                }
93
                // else: still within contention limits.
94
            }
95
        }
96
        else if (expectedBreakingTime > cc.fastBreakDelay) {
97
            // Fast breaking does not decrease violation level.
98
            data.fastBreakVL *= 0.9D;
99
        }
100
101
        // TODO: Rework to use (then hopefully completed) BlockBreakKey.
102
        if (pData.isDebugActive(type)) {
103
            detailDebugStats(player, isInstaBreak, blockType, elapsedTime, expectedBreakingTime, data, pData);
104
        }
105
        else {
106
            data.stats = null;
107
        }
108
        // (The break time is set in the listener).
109
        return cancel;
110
    }
111
112
    private void detailDebugStats(final Player player, final AlmostBoolean isInstaBreak,
113
                                  final Material blockType, final long elapsedTime, final long expectedBreakingTime,
114
                                  final BlockBreakData data, final IPlayerData pData) {
115
        if (pData.hasPermission(Permissions.ADMINISTRATION_DEBUG, player)) {
116
            // General stats:
117
            // TODO: Replace stats by new system (BlockBreakKey once complete), commands to inspect / auto-config.
118
            data.setStats();
119
            data.stats.addStats(data.stats.getId(blockType+ "/u", true), elapsedTime);
120
            data.stats.addStats(data.stats.getId(blockType + "/r", true), expectedBreakingTime);
121
            player.sendMessage(data.stats.getStatsStr(true));
122
            // Send info about current break:
123
            final ItemStack stack = Bridge1_9.getItemInMainHand(player);
124
            final boolean isValidTool = BlockProperties.isValidTool(blockType, stack);
125
            final double haste = PotionUtil.getPotionEffectAmplifier(player, BridgePotionEffect.HASTE);
126
            String msg = (isInstaBreak.decideOptimistically() ? ("[Insta=" + isInstaBreak + "]") : "[Normal]") + "[" + blockType + "] "+ elapsedTime + "u / " + expectedBreakingTime +"r (" + (isValidTool?"tool":"no-tool") + ")" + (Double.isInfinite(haste) ? "" : " haste=" + ((int) haste + 1));
127
            player.sendMessage(msg);
128
            //          net.minecraft.server.Item mcItem = net.minecraft.server.Item.byId[stack.getTypeId()];
129
            //          if (mcItem != null) {
130
            //              double x = mcItem.getDestroySpeed(((CraftItemStack) stack).getHandle(), net.minecraft.server.Block.byId[blockId]);
131
            //              player.sendMessage("mc speed: " + x);
132
            //          }
133
        }
134
    }
135
}

How it counteracts this module

NCP FastBreak is the time-based dig check: expectedBreakingTime is round of the block's breaking duration times fastBreakModSurvival divided by 100, and the elapsed time is measured from the first damage timestamp (fastBreakfirstDamage, strict mode) or from the start. When elapsed plus fastBreakDelay (10ms) is still below the expected time, the missing time is scored into the fastBreakPenalties bucket, and once the bucket scores past fastBreakGrace (2000ms) the check fires. The module's instant START/STOP pair presents an elapsed time of a few milliseconds against a stone expectation around 750ms, so each real harvest adds most of the expected duration as missing time and a handful of blocks exhausts the grace.

The honest boundary is the invocation path: every NCP blockbreak check runs from BlockBreakListener.onBlockBreak, a Bukkit BlockBreakEvent handler, so it only sees digs that end in real harvests. On a server that accepts the instant dig (the module's own function) the sweep is fully visible here; on a server that rejects it, the whole C07 stream is invisible to this check and the packet-level counters are the real pressure.

anticheat Frequency (harvest rate limit)

Frequency.java95 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.blockbreak;
16
17
import org.bukkit.GameMode;
18
import org.bukkit.entity.Player;
19
20
import fr.neatmonster.nocheatplus.checks.Check;
21
import fr.neatmonster.nocheatplus.checks.CheckType;
22
import fr.neatmonster.nocheatplus.players.IPlayerData;
23
import fr.neatmonster.nocheatplus.utilities.TickTask;
24
25
/**
26
 * This checks just limits the number of blocks broken per time frame.
27
 * @author asofold
28
 *
29
 */
30
public class Frequency extends Check {
31
32
    public Frequency() {
33
        super(CheckType.BLOCKBREAK_FREQUENCY);
34
    }
35
    
36
    /**
37
     * Checks a player
38
     * @param player
39
     * @param tick
40
     * @param cc
41
     * @param data
42
     * @param pData
43
     * @return true if cancelled.
44
     * 
45
     */
46
    public boolean check(final Player player, final int tick, final BlockBreakConfig cc, final BlockBreakData data, final IPlayerData pData) {
47
        final float interval = player.getGameMode() == GameMode.CREATIVE ? cc.frequencyIntervalCreative : cc.frequencyIntervalSurvival;
48
        data.frequencyBuckets.add(System.currentTimeMillis(), (float)interval);
49
        // Full period frequency.
50
        final float fullScore = data.frequencyBuckets.score(cc.frequencyBucketFactor);
51
        final long fullTime = cc.frequencyBucketDur * cc.frequencyBuckets;
52
        final boolean lag = pData.getCurrentWorldData().shouldAdjustToLag(type);
53
54
        // Short term limit.
55
        if (tick < data.frequencyShortTermTick) {
56
            // Tick task got reset.
57
            data.frequencyShortTermTick = tick;
58
            data.frequencyShortTermCount = 1;
59
        }
60
        else if (tick - data.frequencyShortTermTick < cc.frequencyShortTermTicks) {
61
            // Account for server side lag.
62
            if (!lag || TickTask.getLag(50L * (tick - data.frequencyShortTermTick), true) < 1.5f) {
63
                // Within range, add.
64
                data.frequencyShortTermCount ++;
65
            }
66
            else {
67
                // Too much lag, reset.
68
                data.frequencyShortTermTick = tick;
69
                data.frequencyShortTermCount = 1;
70
            }
71
        }
72
        else {
73
            data.frequencyShortTermTick = tick;
74
            data.frequencyShortTermCount = 1;
75
        }
76
77
        // Account for server side lag for the medium term check
78
        final float fullLag = lag ? TickTask.getLag(fullTime, true) : 1f;
79
        // Find if one or both are violations:
80
        final float fullViolation = (fullScore > fullTime * fullLag) ? (fullScore - fullTime * fullLag) : 0;
81
        final float shortTermWeight = 50f * cc.frequencyShortTermTicks / (float) cc.frequencyShortTermLimit; 
82
        final float shortTermViolation = data.frequencyShortTermCount > cc.frequencyShortTermLimit ? (data.frequencyShortTermCount - cc.frequencyShortTermLimit) * shortTermWeight : 0; 
83
        final float violation = Math.max(fullViolation, shortTermViolation);
84
        boolean cancel = false;
85
        if (violation > 0.0) {
86
            final double change = violation / 1000;
87
            data.frequencyVL += change;
88
            cancel = executeActions(player, data.frequencyVL, change, cc.frequencyActions).willCancel();
89
        }
90
        else if (data.frequencyVL > 0d && fullScore < fullTime * .75) {
91
            data.frequencyVL *= 0.95;
92
        }
93
        return cancel;
94
    }
95
}

How it counteracts this module

Frequency bounds how many blocks a player can break per time frame: two 1000ms buckets with a short-term limit of 7 harvests in 5 ticks, oriented upward by 45 in creative and 95 in survival. A single Normal-mode sweep at default range sends 216 instant pairs, and the maximum range sends 1728, so even the short-term window is crossed hundreds of times over in one tick whenever the server harvests the instant digs. The violation escalates quickly into the configured cancel or kick actions.

Like the rest of the NCP blockbreak package, Frequency only counts Bukkit BlockBreakEvent harvests, so a server that ignores the instant STOP pair keeps the check silent; the module's scatter mode reduces the count by half but still blows the short-term limit on the first sweep. The check is content-blind: it never inspects the dig face or the block type, only the rate.

anticheat Direction (dig face versus view ray)

Direction.java52 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.blockbreak;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.actions.ActionList;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.checks.generic.block.AbstractBlockDirectionCheck;
22
23
/**
24
 * The Direction check will find out if a player tried to interact with
25
 * something that's not in their field of view.
26
 */
27
public class Direction extends AbstractBlockDirectionCheck<BlockBreakData, BlockBreakConfig> {
28
29
    /**
30
     * Instantiates a new direction check.
31
     */
32
    public Direction() {
33
        super(CheckType.BLOCKBREAK_DIRECTION);
34
    }
35
36
    @Override
37
    protected double addVL(Player player, double distance, BlockBreakData data, BlockBreakConfig cc) {
38
        data.directionVL += distance;
39
        return data.directionVL;
40
    }
41
42
    @Override
43
    protected ActionList getActions(BlockBreakConfig cc) {
44
        return cc.directionActions;
45
    }
46
47
    @Override
48
    protected void cooldown(Player player, BlockBreakData data, BlockBreakConfig cc) {
49
        data.directionVL *= 0.9D;
50
    }
51
52
}

How it counteracts this module

Direction scores the geometric plausibility of the dig face: the distance between the face's normal ray and the player's actual view ray is added into directionVL, and a legitimately aimed hit decays the accumulator by 0.9. The module hardcodes EnumFacing.UP for every block in the sweep, so only the blocks sitting directly above the eye produce a zero-distance face; every side, floor and corner block accumulates the face-to-ray distance instead. Over a 216 or 1728 block sweep the accumulator has no chance to decay back down.

Because the check is Bukkit harvest-gated like its siblings, the accumulation only happens on servers that accept the instant digs. The module never rotates toward the blocks either, which keeps the view ray fixed while the sweep attacks all around the player, exactly the configuration the face-to-ray distance is designed to expose.

anticheat FastBreak (packet-level instant-dig detector)

FastBreak.java141 lines · Java
1
package ac.grim.grimac.checks.impl.breaking;
2
3
import ac.grim.grimac.api.storage.verbose.Verbose;
4
import ac.grim.grimac.checks.Check;
5
import ac.grim.grimac.checks.CheckData;
6
import ac.grim.grimac.checks.impl.verbose.VerboseCodecs;
7
import ac.grim.grimac.checks.type.BlockBreakListener;
8
import ac.grim.grimac.checks.type.PreViaPacketReceiveListener;
9
import ac.grim.grimac.player.GrimPlayer;
10
import ac.grim.grimac.utils.anticheat.update.BlockBreak;
11
import ac.grim.grimac.utils.math.GrimMath;
12
import ac.grim.grimac.utils.nmsutil.BlockBreakSpeed;
13
import ac.grim.grimac.utils.viaversion.ViaVersionUtil;
14
import com.github.retrooper.packetevents.PacketEvents;
15
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
16
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
17
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
18
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
19
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
20
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
21
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
22
import com.github.retrooper.packetevents.util.Vector3i;
23
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
24
25
import java.util.Set;
26
27
// Based loosely off of Hawk BlockBreakSpeedSurvival
28
// Also based loosely off of NoCheatPlus FastBreak
29
// Also based off minecraft wiki: https://minecraft.wiki/w/Breaking#Instant_breaking
30
@CheckData(name = "FastBreak", stableKey = "grim.breaking.fast_break", description = "Breaking blocks too quickly")
31
public class FastBreak extends Check implements BlockBreakListener, PreViaPacketReceiveListener {
32
    private static final Verbose V =
33
            Verbose.of("[delay={ulong}ms|diff={f64:%.1f}ms, balance={f64:%.1f}ms], type={block}");
34
35
    // For some reason these states flag and I don't know why.
36
    // Better to just exempt to not annoy legit players.
37
    private static final Set<StateType> EXEMPT_STATES = Set.of();
38
    private final boolean clientOlderThanServer = PacketEvents.getAPI().getServerManager().getVersion().getProtocolVersion() > player.getClientVersion().getProtocolVersion();
39
40
    public FastBreak(GrimPlayer player) {
41
        super(player);
42
    }
43
44
    // The block the player is currently breaking
45
    Vector3i targetBlockPosition = null;
46
    // The maximum amount of damage the player deals to the block
47
    //
48
    double maximumBlockDamage = 0;
49
    // The last time a finish digging packet was sent, to enforce 0.3-second delay after non-instabreak
50
    long lastFinishBreak = 0;
51
    // The time the player started to break the block, to know how long the player waited until they finished breaking the block
52
    long startBreak = 0;
53
54
    // The buffer to this check
55
    double blockBreakBalance = 0;
56
    double blockDelayBalance = 0;
57
58
    @Override
59
    public void onBlockBreak(BlockBreak blockBreak) {
60
        if (blockBreak.action == DiggingAction.START_DIGGING) {
61
            if (!ViaVersionUtil.isAvailable) {
62
                // Exempt all blocks that do not exist in the player version
63
                final WrappedBlockState defaultState = WrappedBlockState.getDefaultState(player.getClientVersion(), blockBreak.block.getType());
64
                if (defaultState.getType() == StateTypes.AIR || EXEMPT_STATES.contains(defaultState.getType())) {
65
                    return;
66
                }
67
            }
68
            // If client is older than the server, fetch block client actually sees from via
69
            // otherwise just return the server-side block (since if client is >= server version the block is guaranteed to exist in client version)
70
            // TODO this lazy loads PacketEvents mappings for older versions for clients on versions older than the servers, increasing memory usage
71
            //  * its the only thing we use non-native mappings for behind ViaVersion
72
            //  * can we translate back "up" to server version and run check against server version to avoid loading older registries?
73
            WrappedBlockState block = clientOlderThanServer ? WrappedBlockState.getByGlobalId(player.getClientVersion(), player.getViaTranslatedClientBlockID(blockBreak.block.getGlobalId())) : blockBreak.block;
74
75
            startBreak = System.currentTimeMillis() - (targetBlockPosition == null ? 50 : 0); // ???
76
            targetBlockPosition = blockBreak.position;
77
78
            // FIXME: getBlockDamage might not return the correct value if the player switched slots before this
79
            maximumBlockDamage = BlockBreakSpeed.getBlockDamage(player, block);
80
81
            double breakDelay = System.currentTimeMillis() - lastFinishBreak;
82
83
            if (breakDelay >= 275) { // Reduce buffer if "close enough"
84
                blockDelayBalance *= 0.9;
85
            } else { // Otherwise, increase buffer
86
                blockDelayBalance += 300 - breakDelay;
87
            }
88
89
            if (blockDelayBalance > 1000) { // If more than a second of advantage
90
                int type = VerboseCodecs.block(blockBreak.block.getType(), player.getClientVersion());
91
                if (flag(V.write(verbose()).bool(true).ulong((long) breakDelay).f64(0).f64(0).sint(type)) && shouldModifyPackets()) {
92
                    blockBreak.cancel();
93
                }
94
            }
95
96
            clampBalance();
97
        }
98
99
        if (blockBreak.action == DiggingAction.FINISHED_DIGGING && targetBlockPosition != null) {
100
            double predictedTime = Math.ceil(1 / maximumBlockDamage) * 50;
101
            double realTime = System.currentTimeMillis() - startBreak;
102
            double diff = predictedTime - realTime;
103
104
            clampBalance();
105
106
            if (diff < 25) {  // Reduce buffer if "close enough"
107
                blockBreakBalance *= 0.9;
108
            } else { // Otherwise, increase buffer
109
                blockBreakBalance += diff;
110
            }
111
112
            if (blockBreakBalance > 1000) { // If more than a second of advantage
113
                int type = VerboseCodecs.block(blockBreak.block.getType(), player.getClientVersion());
114
                if (flag(V.write(verbose()).bool(false).ulong(0).f64(diff).f64(blockBreakBalance).sint(type)) && shouldModifyPackets()) {
115
                    blockBreak.cancel();
116
                }
117
            }
118
119
            // also set start time because the breaking netcode is fucked on 1.14.4+
120
            lastFinishBreak = startBreak = System.currentTimeMillis();
121
        }
122
    }
123
124
    @Override
125
    public void onPreViaPacketReceive(PacketReceiveEvent event) {
126
        // Find the most optimal block damage using the animation packet, which is sent at least once a tick when breaking blocks
127
        // On 1.8 clients, via screws with this packet meaning we must fall back to the 1.8 idle flying packet
128
        //
129
        // listen for flying packets because some block breaks can happen before the next animation (somehow???), causing onGround desync
130
        boolean flying = WrapperPlayClientPlayerFlying.isFlying(event.getPacketType());
131
        if ((flying || (player.getClientVersion().isNewerThanOrEquals(ClientVersion.V_1_9) && event.getPacketType() == PacketType.Play.Client.ANIMATION)) && targetBlockPosition != null) {
132
            maximumBlockDamage = Math.max(maximumBlockDamage, BlockBreakSpeed.getBlockDamage(player, player.compensatedWorld.getBlock(targetBlockPosition)));
133
        }
134
    }
135
136
    private void clampBalance() {
137
        double balance = Math.max(1000, (player.getTransactionPing()));
138
        blockBreakBalance = GrimMath.clamp(blockBreakBalance, -balance, balance); // Clamp not Math.max in case other logic changes
139
        blockDelayBalance = GrimMath.clamp(blockDelayBalance, -balance, balance);
140
    }
141
}

How it counteracts this module

Grim's FastBreak operates directly on the digging packets rather than Bukkit events, which makes it the counter that still bites on servers rejecting instant harvests. A START_DIGGING arms startBreak and maintains blockDelayBalance, adding 300 minus the inter-break delay whenever a new dig starts under 275ms after the previous finish. A FINISHED_DIGGING computes predictedTime as ceil of 1 over the maximum block damage times 50ms and compares it against the real elapsed time; a difference of 25ms or more is added to blockBreakBalance, and once the balance passes 1000ms the check flags and cancels the break.

The module's instant pairs score on both accumulators: two pairs on a normal block add roughly 750ms each of missing time and cross the 1000ms balance in one or two blocks, and the sub-275ms spacing between consecutive finishes drives blockDelayBalance up at 300ms per pair. The start time is even backdated 50ms for the first dig (startBreak = now - 50), which does nothing to help a zero-elapsed instant pair. This is the check the NCP set cannot see on rejecting servers.

← Back to Analysis Hub