Tenacity 6.0 BedBreaker module 1 files, 41 lines

Tenacity 6.0 BedBreaker: Full Source Analysis

Tenacity 6.0's BedBreaker is a settings-only stub in this snapshot.

dev/tenacity/module/impl/player/BedBreakerModule.java · GitHub source ↗

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

Analysis

Overview

Tenacity 6.0's BedBreaker is a settings-only stub in this snapshot. The class registers a Mode setting (Through Walls by default, Around Walls as the alternative), a Distance setting from 1 to 7 blocks, and declares a TimerUtil, a List of Packet objects and a lastMovementYaw field, but it defines no event handler at all: onEnable and onDisable are empty and there is no IEventListener field for the EventSubscriberPool to bind. When the module is toggled, the bus subscribes the instance, scans its declared fields for IEventListener types and finds none, so nothing ever runs. The module appears in the client's module list in Tenacity.java and is toggleable, but it has no wire effect. The fields and settings are the skeleton of the intended bed destroyer, and the analysis below covers both the inert reality and the technique the vestigial code points at.

The stub and the subscription contract

Module.onEnable calls Tenacity.getInstance().getEventBus().subscribe(this), and EventSubscriberPool.subscribe iterates the instance's declared fields, binding every non-null IEventListener field by the event type from its generic signature. BedBreakerModule declares only setting fields, a TimerUtil, an unused ArrayList of Packet and a float, so the subscription binds nothing and the module idles forever. The unused packetList is the strongest clue to the missing design: a bed breaker that must dig through walls typically buffers the tick's C07 dig packets to re-order or re-send them, and lastMovementYaw is exactly the state an Around Walls mode needs to rotate the aim onto a bed it cannot see.

Latent design

The setting names reconstruct the intended mechanism. Through Walls skips the line-of-sight gate so the dig goes out against a bed cell the player cannot see, which requires the C03 look to be rotated toward the target or the server-side direction validation to be bypassed; Around Walls keeps a ray-trace gate and aims only at beds within view, which is where lastMovementYaw would be consumed to write the aim into the tick's C03. The Distance range 1-7 matches the scan radius of working bed breakers (Rise's Breaker scans an 11 by 11 by 11 cube, equivalent to a radius of 5, and optionally ray-traces 4.5 blocks). A complete implementation would emit C07 START_DESTROY_BLOCK plus STOP_DESTROY_BLOCK pairs against the bed cell, optionally with a swing and a same-tick pair for instant destruction.

Wire reality

The module emits nothing. The brief pins S0A and C07 as its packet surface: C07PacketPlayerDigging is the packet a working breaker would use for the instant dig, and S0APacketUseBed is the server's bed-interaction response, but this file never references either class. The honest statement for the page is that the analysis documents a dormant module: no server-side check can fire against it because there is no traffic, and the countering entries below describe what the intended C07 technique would face once the missing handler is reimplemented. This mirrors the Rise 5.99 Breaker, whose live same-tick C07 pairs and optional rotation are the reference behaviour for the Tenacity stub.

source BedBreakerModule.java

BedBreakerModule.java41 lines · JavaOriginal ↗
1
package dev.tenacity.module.impl.player;
2
3
import dev.tenacity.event.IEventListener;
4
import dev.tenacity.event.impl.player.MotionEvent;
5
import dev.tenacity.module.Module;
6
import dev.tenacity.module.ModuleCategory;
7
import dev.tenacity.setting.impl.ModeSetting;
8
import dev.tenacity.setting.impl.NumberSetting;
9
import net.minecraft.network.Packet;
10
import net.minecraft.util.Timer;
11
import dev.tenacity.util.misc.TimerUtil;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
public final class BedBreakerModule extends Module {
17
18
    private final TimerUtil timerUtil = new TimerUtil();
19
20
    private final List<Packet<?>> packetList = new ArrayList<>();
21
22
    private float lastMovementYaw;
23
24
    private final ModeSetting mode = new ModeSetting("Mode", "Through Walls", "Around Walls");
25
    private final NumberSetting distance = new NumberSetting("Distance", 1, 1, 7, 1);
26
27
    public BedBreakerModule() {
28
        super("BedBreaker", "Break beds through walls", ModuleCategory.PLAYER);
29
        initializeSettings(mode, distance);
30
    }
31
32
    @Override
33
    public void onEnable() {
34
        super.onEnable();
35
    }
36
37
    @Override
38
    public void onDisable() {
39
        super.onDisable();
40
    }
41
}

What this file does

The module file is the whole snapshot. The constructor registers the Mode and Distance settings, onEnable and onDisable are empty overrides, and the fields timerUtil, packetList and lastMovementYaw are declared but never referenced anywhere in the class. Because the EventSubscriberPool only binds IEventListener fields, the absence of any listener field is the mechanical proof of inertness: toggling the module subscribes an object with no bindable handlers. The file is 41 lines and contains no packet imports beyond the generic Packet class used by the unused packetList, which confirms the missing dig logic is not hidden in a helper.

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 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. The check computes the expected breaking time from the block's hardness and compares it with the elapsed time since the first damage packet, accumulating the missing time into a bucket that tolerates 2000ms of grace. The intended same-tick START plus STOP pair against a bed (hardness 0.2, no tool, roughly 300ms expected hand-dig time) would add almost the full expected duration to the bucket on every harvested bed, exhausting the grace within a couple of beds and pushing the violation level. The honest caveat applies to both sides: the Tenacity stub emits no C07 at all so nothing reaches the listener, and a server that rejects instant digs never fires BlockBreakEvent, leaving the stream to packet-level checks only.

anticheat 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. An instant-mode breaker that never calls swingItem would climb the counter on every consecutive harvest and flag 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 countering value against this module is conditional: the stub sends no C07 and no C0A, so the ledger is never touched, but the instant-dig design the settings imply would trip it, and a damage-accumulating path that swings once per bed would pass it cleanly.

anticheat 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 from the raw C07 stream, independent of Bukkit harvest events. 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 from the held item 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, with a violation of min((1/totalDamage - 1) * 10, 10) and a resync. The same-tick START/STOP pair of an instant bed breaker satisfies both conditions at once: totalDamage is 0 and the tick stamps match, so every harvested bed resyncs the player. This is the decisive packet-level counter for the intended technique, and it is the check that bites on servers where NCP's Bukkit-gated path is silent.

anticheat 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, building the target block's AABB and requiring the ray from the head along the current yaw and pitch to intersect it, punishing and resyncing otherwise. The intended Around Walls mode rotates the C03 look onto the bed before the C07 pair, which makes the ray land and the check pass; a Through Walls dig with rotation disabled, or a bed picked outside the view cone, misses the ray and is punished. The check is therefore a conditional counter decided by the rotation toggle, exactly as with Rise's Breaker: direction validation is defeated by the built-in aim and bites when it is off. Against the dormant Tenacity stub nothing fires at all, since no dig ever reaches the wire.

← Back to Analysis Hub