HoleFiller module

HoleFiller: Minecraft 26.3 cheat module, full source for every implementation (2 clients: OfflineClient, LiquidBounce (Kotlin)).

2 implementationsCOMBATWORLD

Full module source: 2 implementations

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

OfflineClientCOMBATsrc/main/java/com/jellypudding/offlineclient/modules/combat/HoleFiller.javaJava · 323 lines · 12.4 KB

Seals the holes around an enemy before they can hide in one.

SettingsRangeWalls rangeSearch radiusBlocksNear enemies onlyTarget rangePredictLead ticksIgnore safeOnly movingFill keyBlocks per tickDelayGenuine holesTwo wide holesKeep own holeRotateRenderNext colourLater colour
HoleFiller.javaJava · Minecraft 26.2 · 323 lines · 12.4 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.render.DrawBatch;
10
import com.jellypudding.offlineclient.setting.BoolSetting;
11
import com.jellypudding.offlineclient.setting.ColorSetting;
12
import com.jellypudding.offlineclient.setting.EnumSetting;
13
import com.jellypudding.offlineclient.setting.KeybindSetting;
14
import com.jellypudding.offlineclient.setting.NumberSetting;
15
import com.jellypudding.offlineclient.setting.RegistryListSetting;
16
import com.jellypudding.offlineclient.util.BlockUtil;
17
import com.jellypudding.offlineclient.util.EntityUtil;
18
import com.jellypudding.offlineclient.util.InventoryUtil.SlotSwap;
19
import com.jellypudding.offlineclient.util.SwingMode;
20
import net.minecraft.core.BlockPos;
21
import net.minecraft.core.Direction;
22
import net.minecraft.core.registries.BuiltInRegistries;
23
import net.minecraft.world.InteractionHand;
24
import net.minecraft.world.entity.player.Player;
25
import net.minecraft.world.level.block.Block;
26
import net.minecraft.world.level.block.Blocks;
27
import net.minecraft.world.phys.Vec3;
28
import net.minecraft.world.phys.shapes.CollisionContext;
29
30
import java.util.ArrayList;
31
import java.util.List;
32
33
// A hole with somebody already in it cannot be filled since the server
34
// refuses a block inside a player. This seals holes before an enemy reaches one.
35
public final class HoleFiller extends Module {
36
37
    private final NumberSetting range = new NumberSetting("Range",
38
        "How far you can reach to place.", 4.5, 1, 6, 0.1, " blocks");
39
    private final NumberSetting wallsRange = new NumberSetting("Walls range",
40
        "Shorter reach for a hole you cannot see.", 4.5, 0, 6, 0.1, " blocks");
41
    private final NumberSetting searchRadius = new NumberSetting("Search radius",
42
        "How far around you holes are looked for.", 5, 1, 6, 1, " blocks");
43
    private final RegistryListSetting<Block> blocks = new RegistryListSetting<>("Blocks",
44
        "Blocks to fill with in order of preference.", BuiltInRegistries.BLOCK,
45
        List.of(Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN, Blocks.NETHERITE_BLOCK,
46
            Blocks.RESPAWN_ANCHOR, Blocks.COBWEB));
47
    private final BoolSetting nearEnemies = new BoolSetting("Near enemies only",
48
        "Only fill holes an enemy could reach. Off fills every hole in range.", true);
49
    private final NumberSetting targetRange = new NumberSetting("Target range",
50
        "How close an enemy has to be to a hole for it to count.", 5, 1, 12, 0.5, " blocks")
51
        .under(nearEnemies);
52
    private final BoolSetting predict = new BoolSetting("Predict",
53
        "Fills the holes a moving enemy is heading for first.", true)
54
        .under(nearEnemies);
55
    private final NumberSetting leadTicks = new NumberSetting("Lead ticks",
56
        "How far ahead a moving enemy is projected.", 8, 1, 30, 1, " ticks")
57
        .under(predict);
58
    private final BoolSetting ignoreSafe = new BoolSetting("Ignore safe",
59
        "Skips enemies already walled in on every side.", true)
60
        .under(nearEnemies);
61
    private final BoolSetting onlyMoving = new BoolSetting("Only moving",
62
        "Skips enemies standing still.", false)
63
        .under(nearEnemies);
64
    private final KeybindSetting fillKey = new KeybindSetting("Fill key",
65
        "Fills every hole in range whilst this key is held.", KeybindSetting.UNBOUND);
66
    private final NumberSetting perTick = new NumberSetting("Blocks per tick",
67
        "How many blocks to place in one round.", 2, 1, 4, 1);
68
    private final NumberSetting delay = new NumberSetting("Delay",
69
        "Ticks to wait between placing rounds.", 1, 0, 10, 1, " ticks");
70
    private final BoolSetting genuineOnly = new BoolSetting("Genuine holes",
71
        "Only fill holes that are blast proof on every side.", true);
72
    private final BoolSetting doubles = new BoolSetting("Two wide holes",
73
        "Also count a hole whose one open side is the other half of a two wide hole.", true)
74
        .under(genuineOnly);
75
    private final BoolSetting ownHole = new BoolSetting("Keep own hole",
76
        "Never fill the hole you stand in or next to.", true);
77
    private final BoolSetting rotate = new BoolSetting("Rotate",
78
        "Send a look packet towards each block.", true);
79
    private final EnumSetting<SwingMode> swing = SwingMode.setting(SwingMode.BOTH);
80
    private final BoolSetting render = new BoolSetting("Render",
81
        "Draws the holes waiting to be filled.", true);
82
    private final BoxStyle boxStyle = BoxStyle.shapeOnly(BoxStyle.Shape.BOTH).under(render);
83
    private final ColorSetting nextColor = new ColorSetting("Next colour",
84
        "The holes going in this round.", 270, false).under(render);
85
    private final ColorSetting laterColor = new ColorSetting("Later colour",
86
        "The holes still waiting.", 270, 0.4f, 0.9f, false).under(render);
87
88
    private final List<Player> enemies = new ArrayList<>();
89
    private final List<BlockPos> holes = new ArrayList<>();
90
    private int timer;
91
    private final SlotSwap slots = new SlotSwap();
92
93
    public HoleFiller() {
94
        super("HoleFiller", "Seals the holes around an enemy before they can hide in one.", Category.COMBAT);
95
        addSettings(range, wallsRange, searchRadius, blocks, nearEnemies, targetRange, predict,
96
            leadTicks, ignoreSafe, onlyMoving, fillKey, perTick, delay, genuineOnly, doubles,
97
            ownHole, rotate, swing, render);
98
        addSettings(boxStyle.settings());
99
        addSettings(nextColor, laterColor);
100
        searchTags("hole", "obsidian", "crystal", "fill");
101
    }
102
103
    @Override
104
    public String getSuffix() {
105
        return count(holes.size());
106
    }
107
108
    @Override
109
    protected void onEnable() {
110
        timer = 0;
111
        slots.forget();
112
        enemies.clear();
113
        holes.clear();
114
    }
115
116
    @Override
117
    protected void onDisable() {
118
        slots.restore();
119
        enemies.clear();
120
        holes.clear();
121
    }
122
123
    @Subscribe
124
    private void onTick(TickEvent event) {
125
        holes.clear();
126
        if (!inGame() || mc.player.isSpectator()) {
127
            enemies.clear();
128
            return;
129
        }
130
        boolean everything = !nearEnemies.isOn() || fillKey.isHeld();
131
        collectEnemies();
132
        if (!everything && enemies.isEmpty()) {
133
            slots.restore();
134
            return;
135
        }
136
        collectHoles(everything);
137
        if (holes.isEmpty()) {
138
            slots.restore();
139
            return;
140
        }
141
        if (timer > 0) {
142
            timer--;
143
            return;
144
        }
145
146
        int slot = BlockUtil.findRankedBlockSlot(blocks.getValue(), block -> true);
147
        if (slot == -1) {
148
            slots.restore();
149
            return;
150
        }
151
        slots.select(slot);
152
153
        int placed = 0;
154
        for (BlockPos pos : holes) {
155
            if (placed >= perTick.getInt()) {
156
                break;
157
            }
158
            if (BlockUtil.placeAny(pos, rotate.isOn(), false)) {
159
                swing.getValue().swing(InteractionHand.MAIN_HAND);
160
                placed++;
161
            }
162
        }
163
        if (placed > 0) {
164
            timer = delay.getInt();
165
        }
166
        slots.restore();
167
    }
168
169
    private void collectEnemies() {
170
        enemies.clear();
171
        double reach = range.getValue() + targetRange.getValue();
172
        for (Player player : mc.level.players()) {
173
            if (!EntityUtil.isEnemy(player) || player.isCreative()) {
174
                continue;
175
            }
176
            if (mc.player.distanceTo(player) > reach) {
177
                continue;
178
            }
179
            if (onlyMoving.isOn() && EntityUtil.velocityOf(player).horizontalDistanceSqr() < 0.0004) {
180
                continue;
181
            }
182
            if (ignoreSafe.isOn() && walledIn(player)) {
183
                continue;
184
            }
185
            enemies.add(player);
186
        }
187
    }
188
189
    // True when the player already stands in a hole that is blast proof on every side.
190
    private boolean walledIn(Player player) {
191
        BlockPos feet = player.blockPosition();
192
        for (Direction side : Direction.Plane.HORIZONTAL) {
193
            if (!blastProof(feet.relative(side))) {
194
                return false;
195
            }
196
        }
197
        return blastProof(feet.below());
198
    }
199
200
    private void collectHoles(boolean everything) {
201
        BlockPos own = mc.player.blockPosition();
202
        // positionsWithin hands them back nearest first. Predicted holes are pulled forward.
203
        List<BlockPos> soon = new ArrayList<>();
204
        for (BlockPos pos : BlockUtil.positionsWithin(searchRadius.getValue())) {
205
            if (ownHole.isOn() && own.distManhattan(pos) <= 1) {
206
                continue;
207
            }
208
            if (!open(pos) || !floored(pos) || !inReach(pos)) {
209
                continue;
210
            }
211
            if (everything) {
212
                holes.add(pos.immutable());
213
            } else if (headedFor(pos)) {
214
                soon.add(pos.immutable());
215
            } else if (nearAnEnemy(pos)) {
216
                holes.add(pos.immutable());
217
            }
218
        }
219
        holes.addAll(0, soon);
220
    }
221
222
    private boolean inReach(BlockPos pos) {
223
        Vec3 top = Vec3.upFromBottomCenterOf(pos, 1);
224
        double reach = BlockUtil.canSee(top) ? range.getValue() : wallsRange.getValue();
225
        return BlockUtil.distanceTo(pos) <= reach;
226
    }
227
228
    // Open and empty. A hole with a player in it is not open.
229
    private boolean open(BlockPos pos) {
230
        if (!BlockUtil.isReplaceable(pos) || !BlockUtil.state(pos.above()).isAir()) {
231
            return false;
232
        }
233
        return mc.level.isUnobstructed(Blocks.OBSIDIAN.defaultBlockState(), pos, CollisionContext.empty());
234
    }
235
236
    // True when the spot is really a hole.
237
    private boolean floored(BlockPos pos) {
238
        if (!BlockUtil.isSolid(pos.below())) {
239
            return false;
240
        }
241
        if (!genuineOnly.isOn()) {
242
            return true;
243
        }
244
        if (!blastProof(pos.below())) {
245
            return false;
246
        }
247
        BlockPos gap = null;
248
        for (Direction side : Direction.Plane.HORIZONTAL) {
249
            BlockPos wall = pos.relative(side);
250
            if (blastProof(wall)) {
251
                continue;
252
            }
253
            if (gap != null || !doubles.isOn()) {
254
                return false;
255
            }
256
            gap = wall;
257
        }
258
        return gap == null || isOtherHalf(gap, pos);
259
    }
260
261
    // The far half of a two wide hole. Walled on its own three sides.
262
    private boolean isOtherHalf(BlockPos half, BlockPos pos) {
263
        if (!open(half) || !blastProof(half.below())) {
264
            return false;
265
        }
266
        for (Direction side : Direction.Plane.HORIZONTAL) {
267
            BlockPos wall = half.relative(side);
268
            if (!wall.equals(pos) && !blastProof(wall)) {
269
                return false;
270
            }
271
        }
272
        return true;
273
    }
274
275
    private boolean blastProof(BlockPos pos) {
276
        return BlockUtil.isSolid(pos)
277
            && BlockUtil.state(pos).getBlock().getExplosionResistance() >= BlockUtil.BLAST_PROOF;
278
    }
279
280
    private boolean nearAnEnemy(BlockPos pos) {
281
        Vec3 top = Vec3.upFromBottomCenterOf(pos, 1);
282
        for (Player enemy : enemies) {
283
            if (enemy.position().distanceTo(top) <= targetRange.getValue()) {
284
                return true;
285
            }
286
        }
287
        return false;
288
    }
289
290
    // True when a moving enemy will be standing on the spot shortly.
291
    private boolean headedFor(BlockPos pos) {
292
        if (!predict.isOn()) {
293
            return false;
294
        }
295
        Vec3 top = Vec3.upFromBottomCenterOf(pos, 1);
296
        double lead = leadTicks.getValue();
297
        for (Player enemy : enemies) {
298
            Vec3 pace = EntityUtil.velocityOf(enemy);
299
            if (pace.horizontalDistanceSqr() < 0.0004) {
300
                continue;
301
            }
302
            Vec3 ahead = enemy.position().add(pace.x * lead, 0, pace.z * lead);
303
            if (ahead.distanceTo(top) < 1.5) {
304
                return true;
305
            }
306
        }
307
        return false;
308
    }
309
310
    @Subscribe
311
    private void onRender3D(Render3DEvent event) {
312
        if (!render.isOn()) {
313
            return;
314
        }
315
        DrawBatch batch = event.getBatch();
316
        int next = perTick.getInt();
317
        for (int i = 0; i < holes.size(); i++) {
318
            int color = i < next ? nextColor.getColor() : laterColor.getColor();
319
            boxStyle.draw(batch, holes.get(i), color, false);
320
        }
321
    }
322
}
323
LiquidBounce (Kotlin)WORLDsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/world/ModuleHoleFiller.ktKotlin · 308 lines · 10.3 KB

Automatically fills safe spots for crystal PvP.

SettingsFeaturesAreaFilterBlocks
ModuleHoleFiller.ktKotlin · Minecraft 26.2 · 308 lines · 10.3 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
20
21
import it.unimi.dsi.fastutil.booleans.BooleanDoubleImmutablePair
22
import it.unimi.dsi.fastutil.doubles.DoubleLongPair
23
import net.ccbluex.liquidbounce.config.types.list.Tagged
24
import net.ccbluex.liquidbounce.event.events.RotationUpdateEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.utils.block.hole.Hole
29
import net.ccbluex.liquidbounce.utils.block.hole.HoleManager
30
import net.ccbluex.liquidbounce.utils.block.hole.HoleManagerSubscriber
31
import net.ccbluex.liquidbounce.utils.block.hole.HoleTracker
32
import net.ccbluex.liquidbounce.utils.block.placer.BlockPlacer
33
import net.ccbluex.liquidbounce.utils.collection.Filter
34
import net.ccbluex.liquidbounce.utils.collection.blockSortedSetOf
35
import net.ccbluex.liquidbounce.utils.collection.getSlot
36
import net.ccbluex.liquidbounce.utils.combat.shouldBeAttacked
37
import net.ccbluex.liquidbounce.utils.inventory.Slots
38
import net.ccbluex.liquidbounce.utils.item.getBlock
39
import net.ccbluex.liquidbounce.utils.kotlin.Priority
40
import net.ccbluex.liquidbounce.utils.math.expandToBoundingBox
41
import net.ccbluex.liquidbounce.utils.math.sq
42
import net.minecraft.core.BlockPos
43
import net.minecraft.world.entity.Entity
44
import net.minecraft.world.level.block.Blocks
45
import net.minecraft.world.level.levelgen.structure.BoundingBox
46
import org.joml.Vector2d
47
import kotlin.math.acos
48
import kotlin.math.ceil
49
import kotlin.math.max
50
51
/**
52
 * Module HoleFiller
53
 *
54
 * Automatically fills holes.
55
 *
56
 * @author ccetl
57
 */
58
object ModuleHoleFiller : ClientModule("HoleFiller", ModuleCategories.WORLD), HoleManagerSubscriber {
59
60
    private val features by multiEnumChoice("Features",
61
        Features.SMART,
62
        Features.PREVENT_SELF_FILL,
63
        Features.CHECK_MOVEMENT
64
    )
65
66
    /**
67
     * The area around entities' feet that will be checked for holes.
68
     */
69
    private val fillArea by int("Area", 2, 1..5)
70
71
    /**
72
     * How the blocklist is used.
73
     */
74
    private val filter by enumChoice("Filter", Filter.WHITELIST)
75
76
    /**
77
     * Blocks that are used to fill holes, by default just obsidian.
78
     */
79
    private val blocks by blocks("Blocks", blockSortedSetOf(Blocks.OBSIDIAN))
80
81
    /**
82
     * The core of the module, the placer.
83
     */
84
    private val placer = tree(BlockPlacer(
85
        "Placing",
86
        this,
87
        Priority.NORMAL,
88
        { filter.getSlot(blocks) },
89
        allowSupportPlacements = false
90
    ))
91
92
    private val range: Int get() = ceil(max(placer.range, placer.wallRange)).toInt()
93
94
    override fun horizontalDistance(): Int = range
95
    override fun verticalDistance(): Int = range
96
97
    override fun onEnabled() {
98
        HoleManager.subscribe(this)
99
    }
100
101
    override fun onDisabled() {
102
        HoleManager.unsubscribe(this)
103
        placer.disable()
104
    }
105
106
    @Suppress("unused")
107
    private val targetUpdater = handler<RotationUpdateEvent> {
108
        // all holes, if required 1x1 holes filtered out
109
        val holes = HoleTracker.holes.filter { Features.ONLY_ONE_BY_ONE !in features || it is Hole.OneByOne }
110
111
        val blockPos = player.blockPosition()
112
        val selfInHole = holes.any { it.contains(blockPos) }
113
        if (Features.ONLY_WHEN_SELF_IN_HOLE in features && !selfInHole) {
114
            return@handler
115
        }
116
117
        val selfRegion = blockPos.expandToBoundingBox(fillArea, fillArea, fillArea)
118
119
        val blocks = linkedSetOf<BlockPos>()
120
        val holeContext = HoleContext(holes, selfInHole, selfRegion, blocks)
121
122
        if (Features.SMART !in features) {
123
            collectHolesSimple(holeContext)
124
        } else {
125
            val availableItems = getAvailableItemsCount()
126
            if (availableItems == 0) {
127
                return@handler
128
            }
129
130
            // the range in which entities are considered as a target
131
            val range = this.range.sq() + 10.0
132
            collectHolesSmart(range, holeContext, availableItems)
133
        }
134
135
        placer.update(blocks)
136
    }
137
138
    private fun getAvailableItemsCount(): Int {
139
        var itemCount = 0
140
        Slots.OffhandWithHotbar.forEach { slot ->
141
            val block = slot.itemStack.getBlock() ?: return@forEach
142
            if (filter(block, blocks)) {
143
                itemCount += slot.itemStack.count
144
            }
145
        }
146
147
        return itemCount
148
    }
149
150
    @Suppress("ComplexCondition")
151
    private fun collectHolesSimple(holeContext: HoleContext) {
152
        holeContext.holes.forEach { hole ->
153
            val y = hole.pos.y + 1.0
154
            if (Features.PREVENT_SELF_FILL !in features
155
                || y > player.y
156
                || holeContext.selfInHole
157
                || !hole.positions.intersects(holeContext.selfRegion)
158
            ) {
159
                hole.asList().toCollection(holeContext.blocks)
160
            }
161
        }
162
    }
163
164
    private fun collectHolesSmart(range: Double, holeContext: HoleContext, availableItems: Int) {
165
        val checkedHoles = hashSetOf<Hole>()
166
        var remainingItems = availableItems
167
168
        world.entitiesForRendering().forEach { entity ->
169
            if (entity.distanceToSqr(player) > range || entity === player || !entity.shouldBeAttacked()) {
170
                return@forEach
171
            }
172
173
            val found = hashSetOf<DoubleLongPair>()
174
            remainingItems = iterateHoles(
175
                holeContext,
176
                checkedHoles,
177
                entity,
178
                remainingItems,
179
                found
180
            )
181
182
            found.sortedByDescending { it.leftDouble() }
183
                .mapTo(holeContext.blocks) { BlockPos.of(it.rightLong()) }
184
            if (remainingItems <= 0) {
185
                return
186
            }
187
        }
188
    }
189
190
    private fun iterateHoles(
191
        holeContext: HoleContext,
192
        checkedHoles: MutableSet<Hole>,
193
        entity: Entity,
194
        remainingItems: Int,
195
        found: MutableSet<DoubleLongPair>
196
    ): Int {
197
        var remainingItems1 = remainingItems
198
        val region = entity.blockPosition().expandToBoundingBox(fillArea, fillArea, fillArea)
199
200
        holeContext.holes.forEach { hole ->
201
            if (hole in checkedHoles) {
202
               return@forEach
203
            }
204
205
            val valid = isValidHole(hole, entity, region, holeContext.selfInHole, holeContext.selfRegion)
206
            if (!valid.firstBoolean()) {
207
                return@forEach
208
            }
209
210
            val holeSize = hole.size
211
            remainingItems1 -= holeSize
212
            if (remainingItems1 < 0 && !player.abilities.instabuild) {
213
                remainingItems1 += holeSize
214
                return@forEach
215
            }
216
217
            checkedHoles += hole
218
            hole.asList().mapTo(found) {
219
                DoubleLongPair.of(valid.rightDouble(), it.asLong())
220
            }
221
222
            if (remainingItems1 == 0 && !player.abilities.instabuild) {
223
                return 0
224
            }
225
        }
226
227
        return remainingItems
228
    }
229
230
    private fun isValidHole(
231
        hole: Hole,
232
        entity: Entity,
233
        region: BoundingBox,
234
        selfInHole: Boolean,
235
        selfRegion: BoundingBox
236
    ) : BooleanDoubleImmutablePair {
237
        val y = hole.pos.y + 1.0
238
        val movingTowardsHole = isMovingTowardsHole(hole, entity)
239
        val requirementsMet = movingTowardsHole.firstBoolean() && hole.positions.intersects(region) && y <= entity.y
240
241
        val noSelfFillViolation =
242
            Features.PREVENT_SELF_FILL !in features
243
            || y > player.y
244
            || selfInHole
245
            || !hole.positions.intersects(selfRegion)
246
247
        return BooleanDoubleImmutablePair(requirementsMet && noSelfFillViolation, movingTowardsHole.rightDouble())
248
    }
249
250
    private fun isMovingTowardsHole(hole: Hole, entity: Entity): BooleanDoubleImmutablePair {
251
        val holePos = hole.positions.center
252
        val velocity = entity.position().subtract(entity.xo, entity.yo, entity.zo)
253
        val playerPos = entity.position()
254
255
        val normalizedVelocity = Vector2d(velocity.x, velocity.z).normalize()
256
        val normalizedDelta = Vector2d(holePos.x - playerPos.x, holePos.z - playerPos.z).normalize()
257
        val angle = acos(normalizedDelta.dot(normalizedVelocity))
258
259
        if (Features.CHECK_MOVEMENT !in features) {
260
            return BooleanDoubleImmutablePair(true, angle)
261
        }
262
263
        // cos(30°) = 0.866
264
        return BooleanDoubleImmutablePair(angle >= 0.866, angle)
265
    }
266
267
    @JvmRecord
268
    private data class HoleContext(
269
        val holes: List<Hole>,
270
        val selfInHole: Boolean,
271
        val selfRegion: BoundingBox,
272
        val blocks: MutableSet<BlockPos>
273
    )
274
275
    private enum class Features(
276
        override val tag: String
277
    ) : Tagged {
278
        /**
279
         * When enabled, only places when entities are about to enter a hole, otherwise fills all holes.
280
         */
281
        SMART("Smart"),
282
283
        /**
284
         * Prevents the module from filling the hole you want to enter.
285
         * The criteria to allow filling are:
286
         * The hole is higher than you, the hole doesn't intersect your own fill area, or you are already in a hole.
287
         */
288
        PREVENT_SELF_FILL("PreventSelfFill"),
289
290
        /**
291
         * Only operate when you're in a hole yourself.
292
         */
293
        ONLY_WHEN_SELF_IN_HOLE("OnlyWhenSelfInHole"),
294
295
        /**
296
         * Checks the movement angle.
297
         * Won't fill holes that lie further away than 30° from the entities' velocity direction.
298
         * Only applies when smart is enabled.
299
         */
300
        CHECK_MOVEMENT("CheckMovement"),
301
302
        /**
303
         * Only fills 1x1 holes - ignores 2x2 and 2x1 holes.
304
         */
305
        ONLY_ONE_BY_ONE("Only1x1")
306
    }
307
}
308