AutoTrap module

AutoTrap: Minecraft 26.3 cheat module, full source for every implementation (4 clients: MelaHack (ThunderHack fork), OfflineClient, Nicotine, …).

4 implementationsCOMBATCombatWORLD

Full module source: 4 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

MelaHack (ThunderHack fork)COMBATsrc/main/java/thunder/hack/features/modules/combat/AutoTrap.javaJava · 30 lines · 1.1 KB

Automatically traps players.

SettingsTarget ByMovingPlayers
AutoTrap.javaJava · Minecraft 26.2 · 30 lines · 1.1 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.combat;
2
3
import net.minecraft.world.entity.player.Player;
4
import org.jetbrains.annotations.Nullable;
5
import thunder.hack.core.Managers;
6
import thunder.hack.core.manager.player.CombatManager;
7
import thunder.hack.features.modules.base.TrapModule;
8
import thunder.hack.setting.Setting;
9
10
public final class AutoTrap extends TrapModule {
11
    private final Setting<CombatManager.TargetBy> targetBy = new Setting<>("Target By", CombatManager.TargetBy.Distance);
12
    private final Setting<Boolean> targetMovingPlayers = new Setting<>("MovingPlayers", false);
13
14
    public AutoTrap() {
15
        super("AutoTrap", Category.COMBAT);
16
    }
17
18
    @Override
19
    protected boolean needNewTarget() {
20
        return target == null
21
                || target.distanceTo(mc.player) > range.getValue()
22
                || target.getHealth() + target.getAbsorptionAmount() <= 0
23
                || target.isDeadOrDying();
24
    }
25
26
    @Override
27
    protected @Nullable Player getTarget() {
28
        return Managers.COMBAT.getTarget(range.getValue(), targetBy.getValue(), p -> p.getDeltaMovement().lengthSqr() < 0.08 || targetMovingPlayers.getValue());
29
    }
30
}
OfflineClientCOMBATsrc/main/java/com/jellypudding/offlineclient/modules/combat/AutoTrap.javaJava · 247 lines · 9.5 KB

Places blocks around an enemy to trap them.

SettingsTarget rangePlace rangeWalls rangeBlocksTopBottomDelayBlocks per tickRotateToggle off when doneShow blocks
AutoTrap.javaJava · Minecraft 26.2 · 247 lines · 9.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.combat;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.Render3DEvent;
5
import com.jellypudding.offlineclient.event.events.TickEvent;
6
import com.jellypudding.offlineclient.module.Category;
7
import com.jellypudding.offlineclient.module.Module;
8
import com.jellypudding.offlineclient.render.BoxStyle;
9
import com.jellypudding.offlineclient.setting.BoolSetting;
10
import com.jellypudding.offlineclient.setting.EnumSetting;
11
import com.jellypudding.offlineclient.setting.NumberSetting;
12
import com.jellypudding.offlineclient.setting.RegistryListSetting;
13
import com.jellypudding.offlineclient.util.BlockUtil;
14
import com.jellypudding.offlineclient.util.EntityUtil;
15
import com.jellypudding.offlineclient.util.InventoryUtil.SlotSwap;
16
import com.jellypudding.offlineclient.util.TargetPriority;
17
import net.minecraft.core.BlockPos;
18
import net.minecraft.core.Direction;
19
import net.minecraft.core.registries.BuiltInRegistries;
20
import net.minecraft.world.entity.player.Player;
21
import net.minecraft.world.level.block.Block;
22
import net.minecraft.world.level.block.Blocks;
23
import net.minecraft.world.phys.AABB;
24
import net.minecraft.world.phys.Vec3;
25
import net.minecraft.world.phys.shapes.CollisionContext;
26
27
import java.util.ArrayList;
28
import java.util.Comparator;
29
import java.util.LinkedHashSet;
30
import java.util.List;
31
import java.util.Set;
32
33
public final class AutoTrap extends Module {
34
35
    public enum Top { FULL, TOP, FACE, NONE }
36
37
    public enum Bottom { PLATFORM, SINGLE, FULL, NONE }
38
39
    // A corner sitting exactly on a block edge belongs to the block before it.
40
    private static final double EDGE = 1.0E-5;
41
42
    private final NumberSetting targetRange = new NumberSetting("Target range",
43
        "How far away enemies are considered.", 4, 1, 10, 0.5, " blocks");
44
    private final EnumSetting<TargetPriority> priority = TargetPriority.setting("Traps",
45
        TargetPriority.LOW_HEALTH);
46
    private final NumberSetting placeRange = new NumberSetting("Place range",
47
        "How far you can reach to place.", 4.5, 1, 6, 0.1, " blocks");
48
    private final NumberSetting wallsRange = new NumberSetting("Walls range",
49
        "Shorter reach for a spot you cannot see.", 4, 0, 6, 0.1, " blocks");
50
    private final RegistryListSetting<Block> blocks = new RegistryListSetting<>("Blocks",
51
        "Blocks the trap may be built from.", BuiltInRegistries.BLOCK,
52
        List.of(Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN));
53
    private final EnumSetting<Top> top = new EnumSetting<>("Top",
54
        "Which blocks go round their head.", Top.FULL)
55
        .describe(Top.FULL, "Seals their head and the four sides at head height.")
56
        .describe(Top.TOP, "Covers their head only.")
57
        .describe(Top.FACE, "Seals the four sides at head height and leaves the top open.")
58
        .describe(Top.NONE, "Places nothing at head height.");
59
    private final EnumSetting<Bottom> bottom = new EnumSetting<>("Bottom",
60
        "Which blocks go under and round their feet.", Bottom.PLATFORM)
61
        .describe(Bottom.PLATFORM, "The block under their feet and the four beside it.")
62
        .describe(Bottom.SINGLE, "The block under their feet only.")
63
        .describe(Bottom.FULL, "The block under their feet and the four sides at feet height.")
64
        .describe(Bottom.NONE, "Places nothing at their feet.");
65
    private final NumberSetting delay = new NumberSetting("Delay",
66
        "Ticks to wait between placing rounds.", 1, 0, 5, 1, " ticks");
67
    private final NumberSetting perTick = new NumberSetting("Blocks per tick",
68
        "How many blocks to place in one round.", 2, 1, 4, 1);
69
    private final BoolSetting rotate = new BoolSetting("Rotate",
70
        "Send a look packet towards each block.", true);
71
    private final BoolSetting toggleOff = new BoolSetting("Toggle off when done",
72
        "Turn off once the target is boxed in.", false);
73
    private final BoolSetting render = new BoolSetting("Show blocks",
74
        "Outline the spots still to fill.", true);
75
    private final BoxStyle style = new BoxStyle(BoxStyle.Shape.BOTH, 280f).under(render);
76
    private final BoxStyle nextStyle = new BoxStyle("Next", BoxStyle.Shape.BOTH, 205f).under(render);
77
78
    private int timer;
79
    private final SlotSwap slots = new SlotSwap();
80
    private String targetName;
81
    private boolean placed;
82
83
    // The spots the last tick found. The unobstructed test walks the entity list.
84
    private List<BlockPos> pending = List.of();
85
86
    public AutoTrap() {
87
        super("AutoTrap", "Places blocks around an enemy to trap them.", Category.COMBAT);
88
        addSettings(targetRange, priority, placeRange, wallsRange, blocks, top, bottom, delay,
89
            perTick, rotate, toggleOff, render);
90
        addSettings(style.settings());
91
        addSettings(nextStyle.settings());
92
        searchTags("obsidian", "trap", "box");
93
    }
94
95
    @Override
96
    public String getSuffix() {
97
        return targetName;
98
    }
99
100
    @Override
101
    protected void onEnable() {
102
        timer = 0;
103
        slots.forget();
104
        targetName = null;
105
        placed = false;
106
        pending = List.of();
107
    }
108
109
    @Override
110
    protected void onDisable() {
111
        slots.restore();
112
        targetName = null;
113
        pending = List.of();
114
    }
115
116
    @Subscribe
117
    private void onTick(TickEvent event) {
118
        pending = List.of();
119
        if (!inGame() || mc.player.isSpectator()) {
120
            return;
121
        }
122
        Player target = EntityUtil.bestEnemy(targetRange.getValue(), priority.getValue());
123
        targetName = EntityUtil.nameOf(target);
124
        if (target == null) {
125
            slots.restore();
126
            return;
127
        }
128
129
        List<BlockPos> missing = missingSpots(target);
130
        pending = missing;
131
        if (missing.isEmpty()) {
132
            slots.restore();
133
            if (toggleOff.isOn() && placed) {
134
                setEnabled(false);
135
            }
136
            return;
137
        }
138
        if (timer > 0) {
139
            timer--;
140
            return;
141
        }
142
143
        int slot = BlockUtil.findRankedBlockSlot(blocks.getValue(), block -> true);
144
        if (slot == -1) {
145
            slots.restore();
146
            return;
147
        }
148
        slots.select(slot);
149
150
        int done = 0;
151
        boolean rotated = false;
152
        for (BlockPos pos : missing) {
153
            if (done >= perTick.getInt()) {
154
                break;
155
            }
156
            boolean turn = rotate.isOn() && !rotated;
157
            rotated |= turn;
158
            boolean ok = BlockUtil.placeAny(pos, turn, true);
159
            if (ok) {
160
                done++;
161
                placed = true;
162
            }
163
        }
164
        if (done > 0) {
165
            timer = delay.getInt();
166
        }
167
        slots.restore();
168
    }
169
170
    // Furthest first. The near side is left open for as long as possible.
171
    private List<BlockPos> missingSpots(Player target) {
172
        Set<BlockPos> spots = new LinkedHashSet<>();
173
        for (BlockPos feet : columnsUnder(target)) {
174
            addTop(spots, feet);
175
            addBottom(spots, feet);
176
        }
177
        List<BlockPos> result = new ArrayList<>(spots);
178
        result.sort(Comparator.comparingDouble(BlockUtil::distanceTo).reversed());
179
        return result;
180
    }
181
182
    // Every block column the feet overlap. Standing across an edge gives two or four.
183
    private static Set<BlockPos> columnsUnder(Player target) {
184
        AABB box = target.getBoundingBox();
185
        Set<BlockPos> columns = new LinkedHashSet<>();
186
        columns.add(BlockPos.containing(box.minX, box.minY, box.minZ));
187
        columns.add(BlockPos.containing(box.minX, box.minY, box.maxZ - EDGE));
188
        columns.add(BlockPos.containing(box.maxX - EDGE, box.minY, box.minZ));
189
        columns.add(BlockPos.containing(box.maxX - EDGE, box.minY, box.maxZ - EDGE));
190
        return columns;
191
    }
192
193
    private void addTop(Set<BlockPos> spots, BlockPos feet) {
194
        if (top.isAny(Top.FULL, Top.TOP)) {
195
            addOpen(spots, feet.above(2));
196
        }
197
        if (top.isAny(Top.FULL, Top.FACE)) {
198
            for (Direction side : Direction.Plane.HORIZONTAL) {
199
                addOpen(spots, feet.above().relative(side));
200
            }
201
        }
202
    }
203
204
    private void addBottom(Set<BlockPos> spots, BlockPos feet) {
205
        if (bottom.is(Bottom.NONE)) {
206
            return;
207
        }
208
        addOpen(spots, feet.below());
209
        if (bottom.is(Bottom.PLATFORM)) {
210
            for (Direction side : Direction.Plane.HORIZONTAL) {
211
                addOpen(spots, feet.below().relative(side));
212
            }
213
        } else if (bottom.is(Bottom.FULL)) {
214
            for (Direction side : Direction.Plane.HORIZONTAL) {
215
                addOpen(spots, feet.relative(side));
216
            }
217
        }
218
    }
219
220
    // A spot only counts when a full block would fit in it and it is within reach.
221
    private void addOpen(Set<BlockPos> spots, BlockPos pos) {
222
        if (!BlockUtil.isReplaceable(pos) || !mc.level.isUnobstructed(
223
            Blocks.OBSIDIAN.defaultBlockState(), pos, CollisionContext.empty())) {
224
            return;
225
        }
226
        if (inReach(pos)) {
227
            spots.add(pos);
228
        }
229
    }
230
231
    private boolean inReach(BlockPos pos) {
232
        double reach = BlockUtil.canSee(Vec3.atCenterOf(pos)) ? placeRange.getValue() : wallsRange.getValue();
233
        return BlockUtil.distanceTo(pos) <= reach;
234
    }
235
236
    @Subscribe
237
    private void onRender3D(Render3DEvent event) {
238
        if (!render.isOn()) {
239
            return;
240
        }
241
        for (int i = 0; i < pending.size(); i++) {
242
            BoxStyle chosen = i < perTick.getInt() ? nextStyle : style;
243
            chosen.draw(event.getBatch(), pending.get(i), false);
244
        }
245
    }
246
}
247
NicotineCombatsrc/client/java/nicotine/mod/mods/combat/AutoTrap.javaJava · 143 lines · 5.2 KB

Traps the closest player with obsidian

SettingsLogoutSpot
AutoTrap.javaJava · Minecraft 26.3 · 143 lines · 5.2 KB · complete file, verbatimOriginal ↗
1
package nicotine.mod.mods.combat;
2
3
import com.mojang.blaze3d.platform.InputConstants;
4
import net.minecraft.client.player.AbstractClientPlayer;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.core.Direction;
7
import net.minecraft.world.entity.Entity;
8
import net.minecraft.world.entity.item.ItemEntity;
9
import net.minecraft.world.item.Items;
10
import net.minecraft.world.phys.AABB;
11
import net.minecraft.world.phys.BlockHitResult;
12
import net.minecraft.world.phys.Vec3;
13
import nicotine.events.ClientLevelTickEvent;
14
import nicotine.mod.Mod;
15
import nicotine.mod.ModCategory;
16
import nicotine.mod.mods.render.LogoutESP;
17
import nicotine.mod.option.ToggleOption;
18
import nicotine.util.EventBus;
19
import nicotine.util.Message;
20
import nicotine.util.Player;
21
import nicotine.util.math.BoxUtil;
22
23
import java.util.ArrayList;
24
import java.util.List;
25
26
import static nicotine.util.Common.mc;
27
28
public class AutoTrap extends Mod {
29
30
    private final ToggleOption logoutSpot = new ToggleOption("LogoutSpot");
31
32
    public AutoTrap() {
33
        super(ModCategory.Combat,"AutoTrap", "Traps the closest player with obsidian");
34
        this.keybind.keyCode = InputConstants.KEY_Y;
35
        this.addOptions(logoutSpot);
36
    }
37
38
    @Override
39
    protected void init() {
40
        EventBus.register(ClientLevelTickEvent.class, event -> {
41
            if (!this.enabled || Player.isBusy())
42
                return true;
43
44
            final double blockInteractionRange = mc.player.blockInteractionRange();
45
46
            AbstractClientPlayer target = Player.findNearestPlayer(true);
47
48
            if (logoutSpot.enabled) {
49
                for (AbstractClientPlayer loggedPlayer : LogoutESP.loggedPlayers.keySet()) {
50
                    if (mc.player.distanceTo(loggedPlayer) + 1 <= blockInteractionRange) {
51
                        target = loggedPlayer;
52
                        break;
53
                    }
54
                }
55
            }
56
57
            if (target == null)
58
                return true;
59
60
            if (mc.player.distanceTo(target) + 1 <= blockInteractionRange) {
61
                List<BlockPos> surroundBlocks = Player.getSurroundBlocks(target.blockPosition());
62
                surroundBlocks.addAll(Player.getSurroundBlocks(target.blockPosition(), 0));
63
64
                boolean alreadySurrounded = true;
65
66
                for (BlockPos surroundBlock : surroundBlocks) {
67
                    if (mc.level.getBlockState(surroundBlock.offset(0, 1, 0)).getBlock().defaultBlockState().canBeReplaced())
68
                        alreadySurrounded = false;
69
                }
70
71
                if (alreadySurrounded) {
72
                    this.toggle();
73
                    return true;
74
                }
75
76
                int targetSlot = -1;
77
78
                if (mc.player.getMainHandItem().getItem() != Items.OBSIDIAN) {
79
                    for (int i = 0; i < 9; i++) {
80
                        if (mc.player.getInventory().getItem(i).getItem() == Items.OBSIDIAN) {
81
                            targetSlot = i;
82
                            break;
83
                        }
84
                    }
85
86
                    if (targetSlot == -1) {
87
                        Message.sendWarning("No obsidian in hotbar!");
88
                        this.toggle();
89
                        return true;
90
                    }
91
                } else {
92
                    targetSlot = mc.player.getInventory().getSelectedSlot();
93
                }
94
95
                List<AABB> takenPositions = new ArrayList<>();
96
97
                for (Entity entity : mc.level.entitiesForRendering()) {
98
                    if (!(entity instanceof ItemEntity)) {
99
                        takenPositions.add(entity.getBoundingBox());
100
                    }
101
                }
102
103
                int size = surroundBlocks.size();
104
                for (int i = 0; i < size; i++) {
105
                    BlockPos surroundBlock = surroundBlocks.get(i);
106
107
                    if (mc.level.getBlockState(surroundBlock).getBlock().defaultBlockState().canBeReplaced() && !surroundBlocks.contains(surroundBlock.offset(0, -1, 0))) {
108
                        surroundBlocks.add(i, surroundBlock.offset(0, -1, 0));
109
                        surroundBlock = surroundBlocks.get(i);
110
                        size++;
111
                    }
112
113
                    if (!(mc.level.getBlockState(surroundBlock.offset(0, 1, 0)).getBlock().defaultBlockState().canBeReplaced())) {
114
                        continue;
115
                    }
116
117
                    boolean invalidPlacement = false;
118
119
                    Vec3 interSectionPos = new Vec3(surroundBlock.getX(), surroundBlock.getY() + 1, surroundBlock.getZ());
120
121
                    for (AABB takenPosition : takenPositions) {
122
                        if (BoxUtil.get1x1Box(interSectionPos).intersects(takenPosition)) {
123
                            invalidPlacement = true;
124
                            break;
125
                        }
126
                    }
127
128
                    if (invalidPlacement) {
129
                        continue;
130
                    }
131
132
                    BlockHitResult blockHitResult = new BlockHitResult(new Vec3(surroundBlock.getX(), surroundBlock.getY(), surroundBlock.getZ()), Direction.UP, surroundBlock, false);
133
                    Player.lookAndPlace(blockHitResult, targetSlot, true, false);
134
                }
135
136
                this.toggle();
137
            }
138
139
            return true;
140
        });
141
    }
142
}
143
LiquidBounce (Kotlin)WORLDsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/traps/ModuleAutoTrap.ktKotlin · 196 lines · 6.6 KB

Automatically sets targets on fire or traps them in cobwebs.

SettingsDelayIgnoreOpenInventory
ModuleAutoTrap.ktKotlin · Minecraft 26.2 · 196 lines · 6.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.world.traps
20
21
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
22
import net.ccbluex.liquidbounce.event.handler
23
import net.ccbluex.liquidbounce.event.tickHandler
24
import net.ccbluex.liquidbounce.event.waitTicks
25
import net.ccbluex.liquidbounce.features.module.ClientModule
26
import net.ccbluex.liquidbounce.features.module.ModuleCategories
27
import net.ccbluex.liquidbounce.features.module.modules.combat.killaura.ModuleKillAura
28
import net.ccbluex.liquidbounce.features.module.modules.combat.criticals.ModuleCriticals
29
import net.ccbluex.liquidbounce.features.module.modules.world.traps.traps.IgnitionTrapPlanner
30
import net.ccbluex.liquidbounce.features.module.modules.world.traps.traps.TrapPlayerSimulation
31
import net.ccbluex.liquidbounce.features.module.modules.world.traps.traps.WebTrapPlanner
32
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
33
import net.ccbluex.liquidbounce.utils.aiming.RotationsValueGroup
34
import net.ccbluex.liquidbounce.utils.block.doPlacement
35
import net.ccbluex.liquidbounce.utils.client.SilentHotbar
36
import net.ccbluex.liquidbounce.utils.combat.CombatManager
37
import net.ccbluex.liquidbounce.utils.combat.TargetTracker
38
import net.ccbluex.liquidbounce.utils.entity.rotation
39
import net.ccbluex.liquidbounce.utils.kotlin.Priority
40
import net.ccbluex.liquidbounce.utils.raytracing.traceFromPlayer
41
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
42
43
/**
44
 * Ignite & AutoWeb module
45
 *
46
 * Ignite: Automatically sets targets around you on fire.
47
 * AutoWeb: Automatically places cobwebs at targets around you.
48
 */
49
object ModuleAutoTrap : ClientModule("AutoTrap", ModuleCategories.WORLD, aliases = listOf("Ignite", "AutoWeb")) {
50
51
    private val range = floatRange("Range", 3.0f..4.5f, 2f..6f)
52
    private val delay by int("Delay", 20, 0..400, "ticks")
53
    private val ignoreOpenInventory by boolean("IgnoreOpenInventory", true)
54
55
    private val ignitionTrapPlanner = tree(IgnitionTrapPlanner(this))
56
    private val webTrapPlanner = tree(WebTrapPlanner(this))
57
    val targetTracker = tree(TargetTracker(range = range))
58
    private val rotations = tree(RotationsValueGroup(this))
59
60
    private var currentPlan: BlockChangeIntent<*>? = null
61
62
    private var timeout = false
63
64
    private var pendingCombatWaitTicks = 0
65
66
    override fun onEnabled() {
67
        resetState()
68
    }
69
70
    override fun onDisabled() {
71
        resetState()
72
        SilentHotbar.resetSlot(this)
73
    }
74
75
    private fun resetState() {
76
        timeout = false
77
        currentPlan = null
78
        pendingCombatWaitTicks = 0
79
        targetTracker.reset()
80
    }
81
82
    @Suppress("unused")
83
    private val rotationUpdateHandler = handler<RotationUpdateEvent> {
84
        if (timeout) {
85
            return@handler
86
        }
87
88
        if (!ignoreOpenInventory && mc.gui.screen() is AbstractContainerScreen<*>) {
89
            return@handler
90
        }
91
92
        targetTracker.validate()
93
94
        val enemies = targetTracker.targets()
95
        TrapPlayerSimulation.runSimulations(enemies)
96
97
        val newPlan = webTrapPlanner.plan(enemies) ?: ignitionTrapPlanner.plan(enemies)
98
        if (newPlan != null) {
99
            currentPlan = newPlan
100
        }
101
        currentPlan?.let { intent ->
102
            val blockChangeInfo = intent.blockChangeInfo
103
            if (blockChangeInfo !is BlockChangeInfo.PlaceBlock) {
104
                currentPlan = null
105
                return@handler
106
            }
107
108
            RotationManager.setRotationTarget(
109
                blockChangeInfo.blockPlacementTarget.rotation,
110
                considerInventory = !ignoreOpenInventory,
111
                valueGroup = rotations,
112
                Priority.IMPORTANT_FOR_PLAYER_LIFE,
113
                this
114
            )
115
        }
116
    }
117
118
    @Suppress("unused")
119
    private val placementHandler = tickHandler {
120
        if (!ignoreOpenInventory && mc.gui.screen() is AbstractContainerScreen<*>) {
121
            return@tickHandler
122
        }
123
124
        val plan = currentPlan ?: return@tickHandler
125
        if (plan.blockChangeInfo !is BlockChangeInfo.PlaceBlock) {
126
            currentPlan = null
127
            return@tickHandler
128
        }
129
130
        if (shouldWaitForTiming(plan)) {
131
            return@tickHandler
132
        }
133
134
        val rotation = RotationManager.currentRotation ?: player.rotation
135
        val raycast = traceFromPlayer(rotation)
136
        if (!plan.validate(raycast)) {
137
            return@tickHandler
138
        }
139
140
        CombatManager.pauseCombatForAtLeast(1)
141
        SilentHotbar.selectSlotSilently(this, plan.slot, 1)
142
143
        var successful = false
144
        val onSuccess = {
145
            plan.onIntentFulfilled()
146
            successful = true
147
            true
148
        }
149
150
        doPlacement(
151
            raycast,
152
            rotation,
153
            hand = plan.slot.useHand,
154
            onPlacementSuccess = onSuccess,
155
            onItemUseSuccess = onSuccess
156
        )
157
158
        if (!successful) {
159
            return@tickHandler
160
        }
161
162
        timeout = true
163
        pendingCombatWaitTicks = 0
164
        try {
165
            waitTicks(delay)
166
        } finally {
167
            timeout = false
168
        }
169
    }
170
171
    private fun shouldWaitForTiming(plan: BlockChangeIntent<*>): Boolean {
172
        return when (plan.timing) {
173
            IntentTiming.INSTANT -> false
174
175
            IntentTiming.NEXT_PROPITIOUS_MOMENT -> {
176
                val shouldWait = hasPendingCombatAction() && (
177
                    player.getAttackStrengthScale(0.5f) > 0.9f
178
                        || ModuleCriticals.wouldDoCriticalHit(ignoreSprint = true)
179
                    )
180
181
                if (!shouldWait) {
182
                    pendingCombatWaitTicks = 0
183
                } else {
184
                    pendingCombatWaitTicks++
185
                }
186
187
                pendingCombatWaitTicks < 40 && shouldWait
188
            }
189
        }
190
    }
191
192
    private fun hasPendingCombatAction(): Boolean {
193
        return ModuleKillAura.running && ModuleKillAura.targetTracker.target != null
194
    }
195
}
196