anchor module

anchor: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Meteor Client, LiquidBounce (Kotlin)).

2 implementationsMovementMOVEMENT

Full module source: 2 implementations

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

Meteor ClientMovementsrc/main/java/meteordevelopment/meteorclient/systems/modules/movement/Anchor.javaJava · 153 lines · 4.9 KB

Helps you get into holes by stopping your movement completely over a hole.

Settingsmax-heightmin-pitchcancel-jump-in-holepullpull-speed
Anchor.javaJava · Minecraft 26.2 · 153 lines · 4.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.movement;
7
8
import meteordevelopment.meteorclient.events.world.TickEvent;
9
import meteordevelopment.meteorclient.mixin.BlockBehaviourAccessor;
10
import meteordevelopment.meteorclient.mixininterface.IVec3;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.orbit.EventHandler;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.util.Mth;
17
import net.minecraft.world.level.block.Block;
18
import net.minecraft.world.level.block.Blocks;
19
20
public class Anchor extends Module {
21
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
22
23
    private final Setting<Integer> maxHeight = sgGeneral.add(new IntSetting.Builder()
24
        .name("max-height")
25
        .description("The maximum height Anchor will work at.")
26
        .defaultValue(10)
27
        .range(0, 255)
28
        .sliderMax(20)
29
        .build()
30
    );
31
32
    private final Setting<Integer> minPitch = sgGeneral.add(new IntSetting.Builder()
33
        .name("min-pitch")
34
        .description("The minimum pitch at which anchor will work.")
35
        .defaultValue(0)
36
        .range(-90, 90)
37
        .sliderRange(-90, 90)
38
        .build()
39
    );
40
41
    private final Setting<Boolean> cancelMove = sgGeneral.add(new BoolSetting.Builder()
42
        .name("cancel-jump-in-hole")
43
        .description("Prevents you from jumping when Anchor is active and Min Pitch is met.")
44
        .defaultValue(false)
45
        .build()
46
    );
47
48
    private final Setting<Boolean> pull = sgGeneral.add(new BoolSetting.Builder()
49
        .name("pull")
50
        .description("The pull strength of Anchor.")
51
        .defaultValue(false)
52
        .build()
53
    );
54
55
    private final Setting<Double> pullSpeed = sgGeneral.add(new DoubleSetting.Builder()
56
        .name("pull-speed")
57
        .description("How fast to pull towards the hole in blocks per second.")
58
        .defaultValue(0.3)
59
        .min(0)
60
        .sliderMax(5)
61
        .build()
62
    );
63
64
    private final BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
65
    private boolean wasInHole;
66
    private boolean foundHole;
67
    private int holeX, holeZ;
68
69
    public boolean cancelJump;
70
71
    public boolean controlMovement;
72
    public double deltaX, deltaZ;
73
74
    public Anchor() {
75
        super(Categories.Movement, "anchor", "Helps you get into holes by stopping your movement completely over a hole.");
76
    }
77
78
    @Override
79
    public void onActivate() {
80
        wasInHole = false;
81
        holeX = holeZ = 0;
82
    }
83
84
    @EventHandler
85
    private void onPreTick(TickEvent.Pre event) {
86
        cancelJump = foundHole && cancelMove.get() && mc.player.getXRot() >= minPitch.get();
87
    }
88
89
    @EventHandler
90
    private void onPostTick(TickEvent.Post event) {
91
        controlMovement = false;
92
93
        int x = Mth.floor(mc.player.getX());
94
        int y = Mth.floor(mc.player.getY());
95
        int z = Mth.floor(mc.player.getZ());
96
97
        if (isHole(x, y, z)) {
98
            wasInHole = true;
99
            holeX = x;
100
            holeZ = z;
101
            return;
102
        }
103
104
        if (wasInHole && holeX == x && holeZ == z) return;
105
        else if (wasInHole) wasInHole = false;
106
107
        if (mc.player.getXRot() < minPitch.get()) return;
108
109
        foundHole = false;
110
        double holeX = 0;
111
        double holeZ = 0;
112
113
        for (int i = 0; i < maxHeight.get(); i++) {
114
            y--;
115
            if (y <= mc.level.getMinY() || !isAir(x, y, z)) break;
116
117
            if (isHole(x, y, z)) {
118
                foundHole = true;
119
                holeX = x + 0.5;
120
                holeZ = z + 0.5;
121
                break;
122
            }
123
        }
124
125
        if (foundHole) {
126
            controlMovement = true;
127
            deltaX = Mth.clamp(holeX - mc.player.getX(), -0.05, 0.05);
128
            deltaZ = Mth.clamp(holeZ - mc.player.getZ(), -0.05, 0.05);
129
130
            ((IVec3) mc.player.getDeltaMovement()).meteor$set(deltaX, mc.player.getDeltaMovement().y - (pull.get() ? pullSpeed.get() : 0), deltaZ);
131
        }
132
    }
133
134
    private boolean isHole(int x, int y, int z) {
135
        return isHoleBlock(x, y - 1, z) &&
136
            isHoleBlock(x + 1, y, z) &&
137
            isHoleBlock(x - 1, y, z) &&
138
            isHoleBlock(x, y, z + 1) &&
139
            isHoleBlock(x, y, z - 1);
140
    }
141
142
    private boolean isHoleBlock(int x, int y, int z) {
143
        blockPos.set(x, y, z);
144
        Block block = mc.level.getBlockState(blockPos).getBlock();
145
        return block == Blocks.BEDROCK || block == Blocks.OBSIDIAN || block == Blocks.CRYING_OBSIDIAN;
146
    }
147
148
    private boolean isAir(int x, int y, int z) {
149
        blockPos.set(x, y, z);
150
        return !((BlockBehaviourAccessor) mc.level.getBlockState(blockPos).getBlock()).meteor$isHasCollision();
151
    }
152
}
153
LiquidBounce (Kotlin)MOVEMENTsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/movement/ModuleAnchor.ktKotlin · 176 lines · 5.9 KB

Pulls you into safe holes for crystal PvP.

SettingsMaxDistanceHorizontalSpeedVerticalSpeed
ModuleAnchor.ktKotlin · Minecraft 26.2 · 176 lines · 5.9 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.movement
20
21
import net.ccbluex.fastutil.weightedMinByOrNullAtMost
22
import net.ccbluex.liquidbounce.event.events.PlayerMoveEvent
23
import net.ccbluex.liquidbounce.event.handler
24
import net.ccbluex.liquidbounce.event.tickHandler
25
import net.ccbluex.liquidbounce.features.module.ClientModule
26
import net.ccbluex.liquidbounce.features.module.ModuleCategories
27
import net.ccbluex.liquidbounce.utils.block.hole.HoleManager
28
import net.ccbluex.liquidbounce.utils.block.hole.HoleManagerSubscriber
29
import net.ccbluex.liquidbounce.utils.block.hole.HoleTracker
30
import net.ccbluex.liquidbounce.utils.input.InputBind
31
import net.ccbluex.liquidbounce.utils.math.boundingBox
32
import net.ccbluex.liquidbounce.utils.math.centerOnSide
33
import net.ccbluex.liquidbounce.utils.math.copy
34
import net.ccbluex.liquidbounce.utils.math.sq
35
import net.minecraft.core.Direction
36
import net.minecraft.world.phys.Vec3
37
import kotlin.math.abs
38
import kotlin.math.ceil
39
import kotlin.math.max
40
41
/**
42
 * Module Anchor
43
 *
44
 * Pulls you into safe holes.
45
 *
46
 * @author ccetl
47
 */
48
object ModuleAnchor : ClientModule(
49
    "Anchor",
50
    ModuleCategories.MOVEMENT,
51
    bindAction = InputBind.BindAction.HOLD,
52
    disableOnQuit = true
53
), HoleManagerSubscriber {
54
55
    private val maxDistance by float("MaxDistance", 4f, 0.1f..6f)
56
    private val horizontalSpeed by float("HorizontalSpeed", 0.3f, 0f..10f)
57
    private val verticalSpeed by float("VerticalSpeed", 0.1f, 0f..10f)
58
59
    var goal: Vec3? = null
60
61
    override fun onEnabled() {
62
        HoleManager.subscribe(this)
63
        goal = null
64
    }
65
66
    override fun onDisabled() {
67
        HoleManager.unsubscribe(this)
68
    }
69
70
    @Suppress("unused")
71
    private val tickHandler = tickHandler {
72
        // if we're already in a hole, we should just center us in that
73
        val playerBB = player.boundingBox
74
        HoleTracker.holes.firstOrNull { hole -> playerBB.intersects(hole.positions.boundingBox) }?.let { hole ->
75
            goal = hole.positions.centerOnSide(Direction.DOWN)
76
            return@tickHandler
77
        }
78
79
        val playerPos = player.position()
80
        val maxDistanceSq = maxDistance.sq()
81
82
        // check if the current goal is still okay, don't update it then
83
        goal?.let { vec3d ->
84
            if (vec3d.distanceToSqr(playerPos) > maxDistanceSq) {
85
                return@let
86
            }
87
        }
88
89
        // not in a hole and no valid goal means we need to search one
90
        goal = HoleTracker.holes
91
            .filter { hole -> hole.positions.maxY() + 1 <= playerPos.y }
92
            .map { hole -> hole.positions.centerOnSide(Direction.DOWN) }
93
            .weightedMinByOrNullAtMost(maxDistanceSq.toDouble(), playerPos::distanceToSqr)
94
    }
95
96
    @Suppress("unused")
97
    private val moveHandler = handler<PlayerMoveEvent> { event ->
98
        val goal = goal ?: return@handler
99
100
        // determine the desired movement
101
        val delta = goal.subtract(player.position())
102
103
        // apply the movement
104
        modifyHorizontalSpeed(event, delta, goal)
105
        modifyVerticalSpeed(event, delta)
106
    }
107
108
    private fun modifyHorizontalSpeed(event: PlayerMoveEvent, delta: Vec3, goal: Vec3) {
109
        if (horizontalSpeed == 0f) {
110
            // only cancel the movement if the player would fall into the hole
111
            val playerBB = player.boundingBox
112
113
            // is the player bounding box within the hole (ignoring y)?
114
            if (playerBB.minX > goal.x - 0.5 &&
115
                playerBB.maxX < goal.x + 0.5 &&
116
                playerBB.minZ > goal.z - 0.5 &&
117
                playerBB.maxZ < goal.z + 0.5) {
118
                event.movement = event.movement.copy(x = 0.0, z = 0.0)
119
            }
120
121
            return
122
        }
123
124
        // determine the speed limit
125
        val horizontalSpeedLimit = if (horizontalSpeed == 0f) {
126
            0.0
127
        } else {
128
            max(horizontalSpeed.toDouble(), event.movement.horizontalDistance())
129
        }
130
131
        // clamp the speed
132
        val exceedsHSpeed = delta.horizontalDistance() > horizontalSpeedLimit
133
        val x: Double
134
        val z: Double
135
        if (exceedsHSpeed) {
136
            val adjusted = delta.normalize().multiply(horizontalSpeedLimit, 0.0, horizontalSpeedLimit)
137
            x = adjusted.x
138
            z = adjusted.z
139
        } else {
140
            x = delta.x
141
            z = delta.z
142
        }
143
144
        // modify the original movement
145
        event.movement = event.movement.copy(x = x, z = z)
146
    }
147
148
    private fun modifyVerticalSpeed(event: PlayerMoveEvent, delta: Vec3) {
149
        if (verticalSpeed == 0f) {
150
            return
151
        }
152
153
        // determine the speed limit
154
        val verticalSpeedLimit = max(verticalSpeed.toDouble(), abs(event.movement.y))
155
156
        // clamp the speed
157
        val exceedsVSpeed = abs(delta.y) > verticalSpeedLimit
158
        val y = if (exceedsVSpeed) {
159
            delta.normalize().y * verticalSpeedLimit
160
        } else {
161
            delta.y
162
        }
163
164
        // modify the original movement
165
        event.movement = event.movement.copy(y = y)
166
    }
167
168
    override val running: Boolean
169
        get() = super.running && !player.isFallFlying && !player.isSpectator && !player.isSwimming
170
171
    override fun horizontalDistance() = ceil(maxDistance).toInt()
172
173
    override fun verticalDistance() = ceil(maxDistance).toInt()
174
175
}
176