Rise 5.99 Breaker module 2 files, 211 lines

Rise 5.99 Breaker: Full Source Analysis

Rise 5.99's Breaker is a C07 bed destroyer: every PreMotionEvent it scans an 11 by 11 by 11 cube around the player for bed blocks, optionally verifies line of sight with a 4.5-block ray trace…

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

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

Packets This Module Uses

Analysis

Overview

Rise 5.99's Breaker is a C07 bed destroyer: every PreMotionEvent it scans an 11 by 11 by 11 cube around the player for bed blocks, optionally verifies line of sight with a 4.5-block ray trace, rotates the outgoing C03 look onto the target, and destroys the block. The Instant toggle (default on) collapses the dig into a same-tick START_DESTROY_BLOCK plus STOP_DESTROY_BLOCK pair with the facing hardcoded to up, followed by a direct onPlayerDestroyBlock call, with no swing; the non-instant path swings, accumulates the block's hardness across ticks, and only sends STOP once the client-side damage passes 1. The Teleport handler remembers any teleport farther than 40 blocks as 'home', and the whitelist toggle refuses to break beds within 55 blocks of it.

Scan and target selection

The triple loop walks x, y and z from -5 to 5 relative to the player's position, reads each cell through PlayerUtil.getBlockRelativeToPlayer, and keeps only BlockBed cells while the Bed toggle is on. With Through Walls disabled, the module computes BlockUtil.getRotations toward the candidate, fires a 4.5-block rayTraceCustom along that look, and requires the hit block to equal the candidate by floor coordinates; with the toggle on (default), the ray trace is skipped entirely. The own-bed whitelist runs first: onTeleportEvent stamps 'home' whenever a teleport exceeds 40 blocks, and any candidate within 55 blocks of that point is rejected while Whitelist Own Bed is on. The first matching cell in scan order wins, so the target is a function of scan order, not of distance or direction.

Break mechanics

Instant mode sends C07PacketPlayerDigging with action START_DESTROY_BLOCK and then STOP_DESTROY_BLOCK, both against the same block position with EnumFacing.UP, and immediately calls mc.playerController.onPlayerDestroyBlock with EnumFacing.DOWN; the whole sequence happens inside one PreMotionEvent and no swingItem call precedes it. The non-instant path swings once, sends START on the first tick, reads the hardness via getPlayerRelativeBlockHardness, and accumulates it into the damage field; updateDamage also pushes the client-side crack through sendBlockBreakProgress with (int)(damage * 10 - 1). When damage passes 1 the module sends STOP and destroys the block through the controller. The damage counter resets whenever the target cell changes, which the three equals() overloads decide by comparing floored coordinates.

Rotation and packet order

rotate() writes BlockUtil.getRotations yaw and pitch into the PreMotionEvent, so the tick's C03PacketPlayer carries a look aimed at the bed before the C07 pair leaves the queue; with the Rotate toggle off, the dig goes out with the player's natural look. The wire order is therefore C03 with the aimed look followed by the two C07 packets, which is what makes the server accept the dig as an ordinary, faced interaction. Because the scan covers the whole cube, the module breaks beds behind and beside the player, and every dig claims the up face regardless of the block's real geometry relative to the player.

source Breaker.java

Breaker.java168 lines · JavaOriginal ↗
1
package dev.rise.module.impl.other;
2
3
import dev.rise.event.impl.motion.PreMotionEvent;
4
import dev.rise.event.impl.motion.TeleportEvent;
5
import dev.rise.module.Module;
6
import dev.rise.module.api.ModuleInfo;
7
import dev.rise.module.enums.Category;
8
import dev.rise.setting.impl.BooleanSetting;
9
import dev.rise.util.player.PacketUtil;
10
import dev.rise.util.player.PlayerUtil;
11
import dev.rise.util.player.RotationUtil;
12
import dev.rise.util.world.BlockUtil;
13
import net.minecraft.block.Block;
14
import net.minecraft.block.BlockBed;
15
import net.minecraft.network.play.client.C07PacketPlayerDigging;
16
import net.minecraft.util.*;
17
18
@ModuleInfo(name = "Breaker", description = "Breaks blocks", category = Category.PLAYER)
19
public class Breaker extends Module {
20
21
    public final BooleanSetting bed = new BooleanSetting("Bed", this, true);
22
23
    public final BooleanSetting instant = new BooleanSetting("Instant", this, true);
24
    public final BooleanSetting throughWalls = new BooleanSetting("Through Walls", this, true);
25
    public final BooleanSetting rotations = new BooleanSetting("Rotate", this, true);
26
    public final BooleanSetting whiteListOwnBed = new BooleanSetting("Whitelist Own Bed", this, true);
27
28
    private Vec3 block, lastBlock, home;
29
    private double damage;
30
31
    @Override
32
    public void onPreMotion(PreMotionEvent event) {
33
        lastBlock = block;
34
        block = this.block();
35
36
        if (block == null) {
37
            return;
38
        }
39
40
        if (this.rotations.isEnabled()) {
41
            this.rotate(event);
42
        }
43
44
        if (!equals(lastBlock, block)) {
45
            damage = 0;
46
        }
47
48
        this.destroy();
49
    }
50
51
    public void rotate(final PreMotionEvent event) {
52
        /* Rotate to get correct EnumFacing */
53
        final float[] rotations = BlockUtil.getRotations(block.xCoord, block.yCoord, block.zCoord);
54
55
        /* Setting rotations */
56
        event.setYaw(rotations[0]);
57
        event.setPitch(rotations[1]);
58
    }
59
60
    public Vec3 block() {
61
        if (home != null && mc.thePlayer.getDistanceSq(home.xCoord, home.yCoord, home.zCoord) < 55 * 55 && whiteListOwnBed.isEnabled()) {
62
            return null;
63
        }
64
65
        for (int x = -5; x <= 5; x++) {
66
            for (int y = -5; y <= 5; y++) {
67
                for (int z = -5; z <= 5; z++) {
68
69
                    /* Get block */
70
                    final Block block = PlayerUtil.getBlockRelativeToPlayer(x, y, z);
71
                    final Vec3 position = new Vec3(mc.thePlayer.posX + x, mc.thePlayer.posY + y, mc.thePlayer.posZ + z);
72
73
                    if (!(block instanceof BlockBed && bed.isEnabled())) {
74
                        continue;
75
                    }
76
77
                    if (!throughWalls.isEnabled()) {
78
79
                        /* Rotate to get correct EnumFacing */
80
                        final float[] rotations = BlockUtil.getRotations(mc.thePlayer.posX + x, mc.thePlayer.posY + y, mc.thePlayer.posZ + z);
81
82
                        /* Grab moving object position */
83
                        final MovingObjectPosition movingObjectPosition = mc.thePlayer.rayTraceCustom(4.5f, rotations[0], rotations[1]);
84
85
                        if (movingObjectPosition == null) {
86
                            continue;
87
                        }
88
89
                        final BlockPos blockPos = movingObjectPosition.getBlockPos();
90
91
                        if (!equals(new Vec3(blockPos), position)) {
92
                            continue;
93
                        }
94
                    }
95
96
                    return position;
97
                }
98
            }
99
        }
100
101
        return null;
102
    }
103
104
    public void updateDamage(final BlockPos blockPos, final double hardness) {
105
        damage += hardness;
106
        mc.theWorld.sendBlockBreakProgress(mc.thePlayer.getEntityId(), blockPos, (int) (damage * 10 - 1));
107
    }
108
109
    public void destroy() {
110
        final BlockPos blockPos = new BlockPos(block.xCoord, block.yCoord, block.zCoord);
111
        final double hardness = mc.theWorld.getBlockState(blockPos).getBlock()
112
                .getPlayerRelativeBlockHardness(mc.thePlayer);
113
114
        if (instant.isEnabled()) {
115
            PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.UP));
116
            PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockPos, EnumFacing.UP));
117
            mc.playerController.onPlayerDestroyBlock(blockPos, EnumFacing.DOWN);
118
119
        } else {
120
            mc.thePlayer.swingItem();
121
122
            if (damage <= 0) {
123
                PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.UP));
124
125
                if (hardness >= 1) {
126
                    mc.playerController.onPlayerDestroyBlock(blockPos, EnumFacing.DOWN);
127
                    damage = 0;
128
                }
129
130
                this.updateDamage(blockPos, hardness);
131
            } else if (damage >= 1) {
132
                PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockPos, EnumFacing.UP));
133
                mc.playerController.onPlayerDestroyBlock(blockPos, EnumFacing.DOWN);
134
                damage = 0;
135
                this.updateDamage(blockPos, hardness);
136
            } else {
137
                this.updateDamage(blockPos, hardness);
138
            }
139
        }
140
    }
141
142
    @Override
143
    public void onTeleportEvent(TeleportEvent event) {
144
        final double distance = mc.thePlayer.getDistance(event.getPosX(), event.getPosY(), event.getPosZ());
145
146
        if (distance > 40) {
147
            home = new Vec3(event.getPosX(), event.getPosY(), event.getPosZ());
148
        }
149
    }
150
151
    public boolean equals(final Vector3d a, final Vector3d b) {
152
        return ((Math.floor(a.getX()) == Math.floor(b.getX()) &&
153
                Math.floor(a.getY()) == Math.floor(b.getY()) &&
154
                Math.floor(a.getZ()) == Math.floor(b.getZ())));
155
    }
156
157
    public boolean equals(final Vec3 a, final Vec3 b) {
158
        return (b != null && a != null && (Math.floor(a.xCoord) == Math.floor(b.xCoord) &&
159
                Math.floor(a.yCoord) == Math.floor(b.yCoord) &&
160
                Math.floor(a.zCoord) == Math.floor(b.zCoord)));
161
    }
162
163
    public boolean equals(final BlockPos a, final Vector3d b) {
164
        return ((Math.floor(a.getX()) == Math.floor(b.getX()) &&
165
                Math.floor(a.getY()) == Math.floor(b.getY()) &&
166
                Math.floor(a.getZ()) == Math.floor(b.getZ())));
167
    }
168
}

What this file does

The module file is the entire mechanism. onPreMotion chains block() (the cube scan, the ray-trace gate, the own-bed whitelist), rotate() (writes the aim into the pending C03), and destroy() (the same-tick C07 pair or the damage-accumulating path). The three equals() overloads compare floored coordinates so the damage counter resets only when the target cell changes, and updateDamage drives the client-side break progress. onTeleportEvent seeds 'home' from any teleport beyond 40 blocks, which the Whitelist Own Bed toggle then uses to spare the player's own bed within 55 blocks.

source PacketUtil.java (send path)

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

PacketUtil is the send wrapper every dig goes through. sendPacket calls addToSendQueue on the net handler, the same queue vanilla uses, so the C07 pair is delivered in order behind the tick's C03 look and is visible to the client's own outgoing-packet events; sendPacketWithoutEvent is the silent sibling that writes through addToSendQueueWithoutEvent and skips the event bus. The distinction matters for Breaker because the module relies on the normal path so its rotation and dig stay ordered on the wire, while other Rise modules that must hide traffic from their own hooks use the silent variant.

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 NoCheatPlus blockbreak FastBreak (zero-duration digs)

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

FastBreak runs from BlockBreakListener.onBlockBreak, so it only scores digs that end in a real harvest, which is the module's function. The check computes the expected breaking time from the block hardness and compares it with the elapsed time since the first damage packet; the Instant mode's same-tick START plus STOP pair presents an elapsed time of a few milliseconds against the bed's expected hand-dig time of roughly 300ms (hardness 0.2, no tool), so every harvested bed adds almost the full expected duration to the fastBreakPenalties bucket.

The bucket tolerates 2000ms of accumulated missing time (fastBreakGrace default) before violations start; a room with several beds in the cube exhausts the grace within a couple of ticks, and every later harvest pushes the level and its configured actions. The honest caveat is the event path: a server that rejects the instant dig never fires BlockBreakEvent, and then this check and the other Bukkit-gated blockbreak checks stay silent while the C07 stream is only visible to packet-level checks.

anticheat NoCheatPlus blockbreak NoSwing (digs without arm movement)

NoSwing.java63 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.checks.Check;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.players.IPlayerData;
22
23
/**
24
 * We require that the player moves their arm between block breaks, this is what gets checked here.
25
 */
26
public class NoSwing extends Check {
27
28
    /**
29
     * Instantiates a new no swing check.
30
     */
31
    public NoSwing() {
32
        super(CheckType.BLOCKBREAK_NOSWING);
33
    }
34
35
    /**
36
     * Checks a player.
37
     * 
38
     * @param player
39
     *            the player
40
     * @return true, if successful
41
     */
42
    public boolean check(final Player player, final BlockBreakData data,
43
            final IPlayerData pData) {
44
45
        boolean cancel = false;
46
47
        // Did they swing their arm before?
48
        if (++data.noSwingCount <= 1) {
49
            // Reward with lowering of the violation level.
50
            data.noSwingVL *= 0.9D;
51
        } else {
52
            // They failed, increase violation level.
53
            data.noSwingCount = 0;
54
            data.noSwingVL += 1D;
55
56
            // Execute whatever actions are associated with this check and the violation level and find out if we should
57
            // cancel the event.
58
            cancel = executeActions(player, data.noSwingVL, 1D, pData.getGenericInstance(BlockBreakConfig.class).noSwingActions).willCancel();
59
        }
60
61
        return cancel;
62
    }
63
}

How it counteracts this module

NCP requires one arm swing between breaks. NoSwing increments a per-player counter on every break check and decrements it when a C0A animation arrives, and a counter above 1 at break time is a violation. The Instant mode never calls swingItem, so the counter climbs on every consecutive harvest and the check flags from the second break onward, adding 1 to noSwingVL per pair; a single bed that takes several START/STOP pairs before the server harvests it accumulates the same way.

The non-instant path swings once per block, which keeps this check quiet, so the Instant toggle is the exposure. The check runs from the same Bukkit harvest event as FastBreak, so on servers that reject the instant dig it shares the same silence, and the packet-level counter for the stream is Hawk's dig-speed check.

anticheat Hawk BlockBreakSpeedSurvival (same-tick dig completion)

BlockBreakSpeedSurvival.java246 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.terrain;
20
21
import me.islandscout.hawk.Hawk;
22
import me.islandscout.hawk.HawkPlayer;
23
import me.islandscout.hawk.check.CustomCheck;
24
import me.islandscout.hawk.event.BlockDigEvent;
25
import me.islandscout.hawk.event.Event;
26
import me.islandscout.hawk.event.MoveEvent;
27
import me.islandscout.hawk.util.MathPlus;
28
import me.islandscout.hawk.util.Placeholder;
29
import me.islandscout.hawk.util.ServerUtils;
30
import me.islandscout.hawk.wrap.block.WrappedBlock;
31
import me.islandscout.hawk.wrap.itemstack.WrappedItemStack;
32
import org.bukkit.GameMode;
33
import org.bukkit.Location;
34
import org.bukkit.Material;
35
import org.bukkit.block.Block;
36
import org.bukkit.enchantments.Enchantment;
37
import org.bukkit.entity.Player;
38
import org.bukkit.potion.PotionEffectType;
39
import org.bukkit.util.Vector;
40
41
import java.util.HashMap;
42
import java.util.Map;
43
import java.util.UUID;
44
45
public class BlockBreakSpeedSurvival extends CustomCheck {
46
47
    private final Map<UUID, Long> interactTick;
48
    private final Map<UUID, Block> targetBlockMap;
49
    private final Map<UUID, Float> blockDamageCumulativeMap;
50
    private boolean CHECK_ON_GROUND;
51
    private final boolean PREVENT_SAME_TICK;
52
53
    public BlockBreakSpeedSurvival() {
54
        super("blockbreakspeedsurvival", true, 5, 10, 0.99, 5000, "%player% failed block break speed. Block: %block%, Speed: %speed%, VL: %vl%", null);
55
        interactTick = new HashMap<>();
56
        targetBlockMap = new HashMap<>();
57
        blockDamageCumulativeMap = new HashMap<>();
58
        CHECK_ON_GROUND = (boolean) customSetting("checkOnGround", "", false);
59
        PREVENT_SAME_TICK = (boolean)customSetting("flagSameTick", "", true);
60
    }
61
62
    @Override
63
    protected void check(Event event) {
64
        if(event instanceof MoveEvent && event.getHawkPlayer().isDigging())
65
            tickDig(event.getHawkPlayer());
66
        else if(event instanceof BlockDigEvent)
67
            checkEvent((BlockDigEvent) event);
68
    }
69
70
    private void tickDig(HawkPlayer pp) {
71
        Block target = targetBlockMap.get(pp.getUuid());
72
        if(target != null && pp.getPlayer().getGameMode() == GameMode.SURVIVAL) {
73
            float accumulatedDamage = blockDamageCumulativeMap.getOrDefault(pp.getUuid(), 0F);
74
            float damage = getDamage(target, pp);
75
            blockDamageCumulativeMap.put(pp.getUuid(), accumulatedDamage + damage);
76
        }
77
    }
78
79
    private void checkEvent(BlockDigEvent e) {
80
        Player p = e.getPlayer();
81
        HawkPlayer pp = e.getHawkPlayer();
82
        if(p.getGameMode() == GameMode.CREATIVE)
83
            return;
84
85
        if (e.getDigAction() == BlockDigEvent.DigAction.START) {
86
            targetBlockMap.put(p.getUniqueId(), e.getBlock());
87
            blockDamageCumulativeMap.put(p.getUniqueId(), 0F);
88
            interactTick.put(p.getUniqueId(), pp.getCurrentTick());
89
            tickDig(pp);
90
            return;
91
        }
92
93
        if (e.getDigAction() == BlockDigEvent.DigAction.COMPLETE) {
94
            float totalDamage = blockDamageCumulativeMap.getOrDefault(p.getUniqueId(), 0F);
95
96
            if(totalDamage < 1 || (PREVENT_SAME_TICK && pp.getCurrentTick() == interactTick.getOrDefault(p.getUniqueId(), 0L))) {
97
                double speedFactor = 1 / totalDamage;
98
                double vl = Math.min((speedFactor - 1) * 10, 10);
99
                Block b = e.getBlock();
100
                punish(pp, vl, true, e, new Placeholder("block", b.getType()), new Placeholder("speed", MathPlus.round(speedFactor, 2) + "x"));
101
                e.resync();
102
            }
103
            else {
104
                reward(pp);
105
            }
106
107
            targetBlockMap.put(p.getUniqueId(), null);
108
            blockDamageCumulativeMap.put(p.getUniqueId(), 0F);
109
        }
110
    }
111
112
    @Override
113
    public void removeData(Player p) {
114
        UUID uuid = p.getUniqueId();
115
        targetBlockMap.remove(uuid);
116
        blockDamageCumulativeMap.remove(uuid);
117
        interactTick.remove(uuid);
118
    }
119
120
    //Yes, I skidded this from NMS. plz don't sue me ;-;
121
    //I'm only trying to make this game more enjoyable for us players.
122
    //I'm pasting a bunch of methods here because I can't be bothered
123
    //to abstract AND synchronize all of this with the network thread
124
    //(and no, I'm not talking about the "synchronized" keyword).
125
126
    private float getDamage(Block block, HawkPlayer pp) {
127
        if(block == null || ServerUtils.getBlockAsync(block.getLocation()) == null)
128
            return 0;
129
        WrappedBlock wBlock = WrappedBlock.getWrappedBlock(block, pp.getClientVersion());
130
        float strength = wBlock.getStrength();
131
        return strength < 0.0F ? 0.0F : (!isDestroyableByHeldItem(wBlock, pp) ? getCurrentPlayerStrVsBlock(wBlock, false, pp) / strength / 100.0F : getCurrentPlayerStrVsBlock(wBlock, true, pp) / strength / 30.0F);
132
    }
133
134
    private boolean isDestroyableByHeldItem(WrappedBlock wBlock, HawkPlayer pp) {
135
        if (wBlock.isMaterialAlwaysDestroyable()) {
136
            return true;
137
        } else {
138
            WrappedItemStack itemstack = WrappedItemStack.getWrappedItemStack(pp.getHeldItem());
139
            return itemstack.canDestroySpecialBlock(wBlock.getBukkitBlock());
140
        }
141
    }
142
143
    private float getCurrentPlayerStrVsBlock(WrappedBlock wBlock, boolean flag, HawkPlayer pp) {
144
        float destroySpeed = getDestroySpeedOfHeldItem(wBlock, pp);
145
        if (destroySpeed > 1.0F && pp.getHeldItem() != null) {
146
            int enchLvl = pp.getHeldItem().getEnchantmentLevel(Enchantment.DIG_SPEED);
147
            WrappedItemStack itemstack = WrappedItemStack.getWrappedItemStack(pp.getHeldItem());
148
            if (enchLvl > 0) {
149
                float f1 = (float)(enchLvl * enchLvl + 1);
150
                if (!itemstack.canDestroySpecialBlock(wBlock.getBukkitBlock()) && destroySpeed <= 1.0F) {
151
                    destroySpeed += f1 * 0.08F;
152
                } else {
153
                    destroySpeed += f1;
154
                }
155
            }
156
        }
157
158
        for(org.bukkit.potion.PotionEffect potionEffect : pp.getPlayer().getActivePotionEffects()) {
159
160
            if(potionEffect.getType().equals(PotionEffectType.FAST_DIGGING)) {
161
                destroySpeed *= 1.0F + (potionEffect.getAmplifier() + 1) * 0.2F;
162
            }
163
164
            if(Hawk.getServerVersion() == 8) {
165
                if(potionEffect.getType().equals(PotionEffectType.SLOW_DIGGING)) {
166
                    float f1;
167
                    switch(potionEffect.getAmplifier()) {
168
                        case 0:
169
                            f1 = 0.3F;
170
                            break;
171
                        case 1:
172
                            f1 = 0.09F;
173
                            break;
174
                        case 2:
175
                            f1 = 0.0027F;
176
                            break;
177
                        case 3:
178
                        default:
179
                            f1 = 8.1E-4F;
180
                    }
181
182
                    destroySpeed *= f1;
183
                }
184
            }
185
            else {
186
                if(potionEffect.getType().equals(PotionEffectType.SLOW_DIGGING)) {
187
                    destroySpeed *= 1.0F - (potionEffect.getAmplifier() + 1) * 0.2F;
188
                }
189
            }
190
        }
191
192
        boolean waterWorkerEnch = pp.getHeldItem() != null && pp.getHeldItem().getEnchantmentLevel(Enchantment.WATER_WORKER) > 0;
193
        if (this.a(pp) && !waterWorkerEnch) {
194
            destroySpeed /= 5.0F;
195
        }
196
197
        if (CHECK_ON_GROUND && !pp.isOnGround()) {
198
            destroySpeed /= 5.0F;
199
        }
200
201
        return destroySpeed;
202
    }
203
204
    private float getDestroySpeedOfHeldItem(WrappedBlock wBlock, HawkPlayer pp) {
205
        float f = 1.0F;
206
        WrappedItemStack itemStack = WrappedItemStack.getWrappedItemStack(pp.getHeldItem());
207
        f *= itemStack.getDestroySpeed(wBlock.getBukkitBlock());
208
        return f;
209
    }
210
211
    private boolean a(HawkPlayer pp) {
212
        Vector position = pp.getPosition();
213
        double d0 = position.getY() + 1.62;
214
        int i = floor(position.getX());
215
        int j = (int)d((float)floor(d0));
216
        int k = floor(position.getZ());
217
        Block block = ServerUtils.getBlockAsync(new Location(pp.getWorld(), i, j, k));
218
        if(block == null)
219
            return false;
220
        if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) {
221
            float f = b(block.getData()) - 0.11111111F;
222
            float f1 = (float)(j + 1) - f;
223
            return d0 < (double)f1;
224
        } else {
225
            return false;
226
        }
227
    }
228
229
    private int floor(double var0) {
230
        int var2 = (int)var0;
231
        return var0 < (double)var2 ? var2 - 1 : var2;
232
    }
233
234
    private long d(double var0) {
235
        long var2 = (long)var0;
236
        return var0 < (double)var2 ? var2 - 1L : var2;
237
    }
238
239
    private float b(int i) {
240
        if (i >= 8) {
241
            i = 0;
242
        }
243
        return (i + 1) / 9.0F;
244
    }
245
246
}

How it counteracts this module

Hawk tracks the dig lifecycle per player. On START it records the target block and the current tick and resets the accumulated damage; on every subsequent MoveEvent while digging it adds the expected per-tick damage computed from the held item's dig speed against the block strength; on COMPLETE it punishes when the accumulated total is below 1 or when the complete lands on the same tick as the start (PREVENT_SAME_TICK default true), with a violation of min((1/totalDamage - 1) * 10, 10) and a resync.

The Instant mode sends START and STOP in the same tick and no move event ever elapses, so both conditions hold at once: totalDamage is 0 and the tick stamps match, and the player is resynced on every bed. The check is packet-level, so it works on servers that reject instant digs where the NCP Bukkit path is silent, which makes it the decisive counter for the Instant configuration.

anticheat Hawk BlockBreakDirection (dig against the look ray)

BlockBreakDirection.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.terrain;
20
21
import me.islandscout.hawk.HawkPlayer;
22
import me.islandscout.hawk.check.BlockDigCheck;
23
import me.islandscout.hawk.event.BlockDigEvent;
24
import me.islandscout.hawk.util.*;
25
import org.bukkit.GameMode;
26
import org.bukkit.Location;
27
import org.bukkit.entity.Player;
28
import org.bukkit.util.Vector;
29
30
public class BlockBreakDirection extends BlockDigCheck {
31
32
    private final boolean DEBUG_HITBOX;
33
    private final boolean DEBUG_RAY;
34
    private final boolean CHECK_DIG_START;
35
    private final boolean CHECK_DIG_CANCEL;
36
    private final boolean CHECK_DIG_COMPLETE;
37
38
    public BlockBreakDirection() {
39
        super("blockbreakdirection", true, 5, 10, 0.9, 5000, "%player% failed block break direction, VL: %vl%", null);
40
        DEBUG_HITBOX = (boolean) customSetting("hitbox", "debug", false);
41
        DEBUG_RAY = (boolean) customSetting("ray", "debug", false);
42
        CHECK_DIG_START = (boolean) customSetting("checkDigStart", "", false);
43
        CHECK_DIG_CANCEL = (boolean) customSetting("checkDigCancel", "", false);
44
        CHECK_DIG_COMPLETE = (boolean) customSetting("checkDigComplete", "", true);
45
    }
46
47
    @Override
48
    protected void check(BlockDigEvent e) {
49
        Player p = e.getPlayer();
50
        HawkPlayer pp = e.getHawkPlayer();
51
        Location bLoc = e.getBlock().getLocation();
52
        Vector pos;
53
        if(pp.isInVehicle()) {
54
            pos = hawk.getLagCompensator().getHistoryLocation(ServerUtils.getPing(p), p).toVector();
55
            pos.setY(pos.getY() + p.getEyeHeight());
56
        }
57
        else {
58
            pos = pp.getHeadPosition();
59
        }
60
        Vector dir = MathPlus.getDirection(pp.getYaw(), pp.getPitch()); //TODO remember to get correct yaw pitch values
61
        Vector extraDir = MathPlus.getDirection(pp.getYaw() + pp.getDeltaYaw(), pp.getPitch() + pp.getDeltaPitch());
62
63
        switch (e.getDigAction()) {
64
            case START:
65
                if(CHECK_DIG_START || (p.getGameMode() == GameMode.CREATIVE && CHECK_DIG_COMPLETE))
66
                    break;
67
                return;
68
            case CANCEL:
69
                if(CHECK_DIG_CANCEL)
70
                    break;
71
                return;
72
            case COMPLETE:
73
                if(CHECK_DIG_COMPLETE)
74
                    break;
75
                return;
76
        }
77
78
        Vector min = bLoc.toVector();
79
        Vector max = bLoc.toVector().add(new Vector(1, 1, 1));
80
        AABB targetAABB = new AABB(min, max);
81
82
        if (DEBUG_HITBOX)
83
            targetAABB.highlight(hawk, p.getWorld(), 0.25);
84
        if (DEBUG_RAY)
85
            new Ray(pos, extraDir).highlight(hawk, p.getWorld(), 6F, 0.3);
86
87
        if(targetAABB.betweenRays(pos, dir, extraDir)) {
88
            reward(pp);
89
        }
90
        else {
91
            punish(pp, true, e);
92
            e.resync();
93
        }
94
    }
95
}

How it counteracts this module

BlockBreakDirection validates the dig against the player's look on COMPLETE (checkDigComplete default true; START is only checked in creative). It builds the target block's AABB and requires the ray from the head position along the current yaw and pitch (plus the tick's delta) to intersect it, punishing and resyncing otherwise.

Breaker's Rotate toggle is the deciding factor: with Rotate on, the tick's C03 look is aimed at the bed before the C07, so the ray lands and the check passes; with Rotate off, or when the last C03 look does not face the bed the scan picked, the dig misses the ray and is punished. Because the module breaks exactly one block per tick but the cube scan is 11 blocks wide, any bed chosen outside the view cone while Rotate is off produces a clean flag, which makes the honest framing a conditional counter: direction checks are defeated by the built-in rotation and bite when it is disabled.

← Back to Analysis Hub