HoleSnap module

HoleSnap: Minecraft 26.3 cheat module, full source for every implementation (2 clients: MelaHack (ThunderHack fork), OfflineClient).

2 implementationsMOVEMENT

Full module source: 2 implementations

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

MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/HoleSnap.javaJava · 202 lines · 7.6 KB

Helps you get into the safe hole.

SettingsModeSearch RangeSearch FOVUse TimerTimer ValueAuto DisableOn DeathIn HoleNo Holes
HoleSnap.javaJava · Minecraft 26.2 · 202 lines · 7.6 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import meteordevelopment.orbit.EventHandler;
4
import meteordevelopment.orbit.EventPriority;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.util.Mth;
7
import net.minecraft.world.phys.Vec3;
8
import org.jetbrains.annotations.NotNull;
9
import org.jetbrains.annotations.Nullable;
10
import thunder.hack.ThunderHack;
11
import thunder.hack.events.impl.EventKeyboardInput;
12
import thunder.hack.events.impl.EventMove;
13
import thunder.hack.events.impl.EventPlayerJump;
14
import thunder.hack.events.impl.EventPlayerTravel;
15
import thunder.hack.features.modules.Module;
16
import thunder.hack.setting.Setting;
17
import thunder.hack.setting.impl.SettingGroup;
18
import thunder.hack.utility.player.InteractionUtility;
19
import thunder.hack.utility.player.MovementUtility;
20
import thunder.hack.utility.world.HoleUtility;
21
22
import java.util.ArrayList;
23
24
import static thunder.hack.features.modules.client.ClientSettings.isRu;
25
26
public class HoleSnap extends Module {
27
    public HoleSnap() {
28
        super("HoleSnap", Category.MOVEMENT);
29
    }
30
31
    private final Setting<Mode> mode = new Setting<>("Mode", Mode.Yaw);
32
    private final Setting<Integer> searchRange = new Setting<>("Search Range", 5, 1, 20);
33
    private final Setting<Integer> searchFOV = new Setting<>("Search FOV", 360, 1, 360);
34
    private final Setting<Boolean> useTimer = new Setting<>("Use Timer", false);
35
    private final Setting<Float> timerValue = new Setting<>("Timer Value", 1f, 0f, 20f);
36
37
    private final Setting<SettingGroup> autoDisable = new Setting<>("Auto Disable", new SettingGroup(false, 0));
38
    private final Setting<Boolean> onDeath = new Setting<>("On Death", true).addToGroup(autoDisable);
39
    private final Setting<Boolean> onInHole = new Setting<>("In Hole", true).addToGroup(autoDisable);
40
    private final Setting<Boolean> onNoHoleFound = new Setting<>("No Holes", false).addToGroup(autoDisable);
41
42
    private BlockPos hole;
43
    private float prevClientYaw;
44
45
    @Override
46
    public void onEnable() {
47
        hole = findHole();
48
        if (useTimer.getValue()) {
49
            ThunderHack.TICK_TIMER = timerValue.getValue();
50
        }
51
    }
52
53
    @Override
54
    public void onDisable() {
55
        hole = null;
56
        if (useTimer.getValue()) {
57
            ThunderHack.TICK_TIMER = 1;
58
        }
59
    }
60
61
    @Override
62
    public void onUpdate() {
63
        if (onDeath.getValue() && mc.player != null
64
                && (mc.player.getHealth() + mc.player.getAbsorptionAmount() <= 0 || mc.player.isDeadOrDying()))
65
            disable(isRu() ? "Вы умерли! Выключаюсь..." : "You died! Disabling...");
66
        if (mc.player != null && mc.player.blockPosition().equals(hole) && onInHole.getValue())
67
            disable(isRu() ? "Ты в холке! Отключаю.." : "You're in a hole already! Disabling..");
68
    }
69
70
    @EventHandler(priority = EventPriority.LOWEST)
71
    @SuppressWarnings("unused")
72
    private void onMove(EventMove event) {
73
        if (mc.player == null) return;
74
75
        BlockPos bp = BlockPos.containing(mc.player.position());
76
77
        for (int i = 1; i < 5; i++) {
78
            if (!HoleUtility.isSingleHole(bp.below(i))) continue;
79
80
            Vec3 center = new Vec3(
81
                    Math.floor(mc.player.getX()) + 0.5,
82
                    mc.player.getY(),
83
                    Math.floor(mc.player.getZ()) + 0.5
84
            );
85
            if (center.distanceTo(mc.player.position()) < 0.15f) {
86
                event.setX(0);
87
                event.setZ(0);
88
                event.cancel();
89
            }
90
91
            break;
92
        }
93
94
        if (mc.player != null && mc.player.horizontalCollision && mc.player.onGround())
95
            mc.player.jumpFromGround();
96
97
        if (mode.getValue() == Mode.Move && hole != null) {
98
            final double newYaw = Math.cos(Math.toRadians(getNewYaw(net.minecraft.world.phys.Vec3.atBottomCenterOf(hole)) + 90.0f));
99
            final double newPitch = Math.sin(Math.toRadians(getNewYaw(net.minecraft.world.phys.Vec3.atBottomCenterOf(hole)) + 90.0f));
100
            final double diffX = net.minecraft.world.phys.Vec3.atBottomCenterOf(hole).x() - mc.player.getX();
101
            final double diffZ = net.minecraft.world.phys.Vec3.atBottomCenterOf(hole).z() - mc.player.getZ();
102
            final double x = 0.29 * newYaw;
103
            final double z = 0.29 * newPitch;
104
105
            event.setX(Math.abs(x) < Math.abs(diffX) ? x : diffX);
106
            event.setZ(Math.abs(z) < Math.abs(diffZ) ? z : diffZ);
107
            event.cancel();
108
        }
109
    }
110
111
    @EventHandler
112
    @SuppressWarnings("unused")
113
    public void modifyVelocity(EventPlayerTravel event) {
114
        if (mc.player == null) return;
115
        if (mc.player.tickCount % 10 == 0) hole = findHole();
116
117
        doYawModeLogic(event.isPre());
118
    }
119
120
    @EventHandler
121
    @SuppressWarnings("unused")
122
    public void modifyJump(EventPlayerJump event) {
123
        if (mc.player == null) return;
124
125
        doYawModeLogic(event.isPre());
126
    }
127
128
    @EventHandler
129
    @SuppressWarnings("unused")
130
    public void onKeyboardInput(EventKeyboardInput e) {
131
        if (mc.player == null || mode.getValue() != Mode.Yaw || hole == null)
132
            return;
133
134
        MovementUtility.setMovementInputY(1f);
135
    }
136
137
    private @Nullable BlockPos findHole() {
138
        if (mc.player == null)
139
            return null;
140
141
        ArrayList<BlockPos> blocks = new ArrayList<>();
142
        BlockPos centerPos = mc.player.blockPosition();
143
144
        for (int i = centerPos.getX() - searchRange.getValue(); i < centerPos.getX() + searchRange.getValue(); i++) {
145
            for (int j = centerPos.getY() - 4; j < centerPos.getY() + 2; j++) {
146
                for (int k = centerPos.getZ() - searchRange.getValue(); k < centerPos.getZ() + searchRange.getValue(); k++) {
147
                    BlockPos pos = new BlockPos(i, j, k);;
148
                    if (HoleUtility.isSingleHole(pos) && InteractionUtility.isVecInFOV(net.minecraft.world.phys.Vec3.atBottomCenterOf(pos), searchFOV.getValue() / 2)) {
149
                        blocks.add(new BlockPos(pos));
150
                    }
151
                }
152
            }
153
        }
154
155
        float nearestDistance = 10;
156
        BlockPos fbp = null;
157
158
        for (BlockPos bp : blocks) {
159
            if (BlockPos.containing(mc.player.position()).equals(bp) && onInHole.getValue()) {
160
                disable(isRu() ? "Ты в холке! Отключаю.." : "You're in a hole already! Disabling..");
161
                return null;
162
            }
163
            if (mc.player.distanceToSqr(net.minecraft.world.phys.Vec3.atBottomCenterOf(bp)) < nearestDistance) {
164
                nearestDistance = (float) mc.player.distanceToSqr(net.minecraft.world.phys.Vec3.atBottomCenterOf(bp));
165
                fbp = bp;
166
            }
167
        }
168
169
        if (fbp == null && onNoHoleFound.getValue())
170
            disable(isRu() ? "Холка не найдена! Выключение..." : "Hole not found! Disabling...");
171
172
        return fbp;
173
    }
174
175
    private float getNewYaw(@NotNull Vec3 pos) {
176
        if (mc.player == null)
177
            return 0;
178
179
        return mc.player.getYRot() + Mth.wrapDegrees((float) Math.toDegrees(Math.atan2(pos.z() - mc.player.getZ(), pos.x() - mc.player.getX())) - mc.player.getYRot() - 90);
180
    }
181
182
    private void doYawModeLogic(boolean isPreEvent) {
183
        if (hole == null || mc.player == null || mode.getValue() != Mode.Yaw) return;
184
185
        if (isPreEvent) {
186
            prevClientYaw = mc.player.getYRot();
187
            mc.player.setYRot(InteractionUtility.calculateAngle(net.minecraft.world.phys.Vec3.atBottomCenterOf(hole))[0]);
188
        } else
189
            mc.player.setYRot(prevClientYaw);
190
    }
191
192
    private enum Mode {
193
        Move,
194
        Yaw
195
    }
196
197
    private enum JumpMode {
198
        Normal,
199
        Move
200
    }
201
}
202
OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/HoleSnap.javaJava · 141 lines · 5.2 KB

Stops your movement over a hole and drops you straight in.

SettingsHolesMax heightMin pitchPull downPull speedCancel jump
HoleSnap.javaJava · Minecraft 26.2 · 141 lines · 5.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.movement;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.TickEvent;
5
import com.jellypudding.offlineclient.module.Category;
6
import com.jellypudding.offlineclient.module.Module;
7
import com.jellypudding.offlineclient.setting.BoolSetting;
8
import com.jellypudding.offlineclient.setting.EnumSetting;
9
import com.jellypudding.offlineclient.setting.NumberSetting;
10
import com.jellypudding.offlineclient.util.BlockUtil;
11
import net.minecraft.core.BlockPos;
12
import net.minecraft.core.Direction;
13
import net.minecraft.util.Mth;
14
import net.minecraft.world.level.block.state.BlockState;
15
import net.minecraft.world.phys.Vec3;
16
17
// Stops you dead over a hole and drops you in. Meant for getting into a hole under fire.
18
// A hole is one block wide with a floor and four walls.
19
public final class HoleSnap extends Module {
20
21
    public enum Holes { BLAST_PROOF, ANY }
22
23
    // How hard one tick may pull towards the middle of the hole.
24
    private static final double CENTRE_PULL = 0.05;
25
26
    private final EnumSetting<Holes> holes = new EnumSetting<>("Holes",
27
        "Which holes count.", Holes.BLAST_PROOF)
28
        .describe(Holes.BLAST_PROOF, "Only holes walled with obsidian or bedrock. The ones a crystal cannot open.")
29
        .describe(Holes.ANY, "Any one block hole with solid walls and a floor.");
30
    private final NumberSetting maxHeight = new NumberSetting("Max height",
31
        "How far below you a hole is still snapped to.", 10, 1, 20, 1, " blocks");
32
    private final NumberSetting minPitch = new NumberSetting("Min pitch",
33
        "Only snaps whilst you look down at least this far. Zero is level.", 0, -90, 90, 5, " degrees");
34
    private final BoolSetting pull = new BoolSetting("Pull down",
35
        "Also pulls you down into the hole.", false);
36
    private final NumberSetting pullSpeed = new NumberSetting("Pull speed",
37
        "Blocks a tick the pull adds.", 0.3, 0.1, 5, 0.1, " blocks")
38
        .under(pull);
39
    private final BoolSetting cancelJump = new BoolSetting("Cancel jump",
40
        "Jumping is ignored whilst a hole is under you.", false);
41
42
    private boolean overHole;
43
    private BlockPos holeStoodIn;
44
45
    public HoleSnap() {
46
        super("HoleSnap", "Stops your movement over a hole and drops you straight in.",
47
            Category.MOVEMENT);
48
        addSettings(holes, maxHeight, minPitch, pull, pullSpeed, cancelJump);
49
        searchTags("anchor", "hole", "crystal pvp");
50
    }
51
52
    @Override
53
    public String getSuffix() {
54
        return overHole ? "over hole" : null;
55
    }
56
57
    @Override
58
    protected void onEnable() {
59
        overHole = false;
60
        holeStoodIn = null;
61
    }
62
63
    // Read by Speed. Nothing else may push the player whilst a hole has them.
64
    public boolean holdsMovement() {
65
        return isEnabled() && overHole;
66
    }
67
68
    // Read by LocalPlayerMixin before a jump.
69
    public boolean cancelsJump() {
70
        return isEnabled() && cancelJump.isOn() && overHole;
71
    }
72
73
    @Subscribe
74
    private void onTick(TickEvent event) {
75
        overHole = false;
76
        if (!inGame() || mc.player.isPassenger()) {
77
            return;
78
        }
79
        BlockPos feet = mc.player.blockPosition();
80
        if (isHole(feet)) {
81
            holeStoodIn = feet;
82
            return;
83
        }
84
        // Climbing out of the hole must not drag you straight back in.
85
        if (holeStoodIn != null) {
86
            if (holeStoodIn.getX() == feet.getX() && holeStoodIn.getZ() == feet.getZ()) {
87
                return;
88
            }
89
            holeStoodIn = null;
90
        }
91
        if (mc.player.getXRot() < minPitch.getValue()) {
92
            return;
93
        }
94
        BlockPos hole = holeBelow(feet);
95
        if (hole == null) {
96
            return;
97
        }
98
        overHole = true;
99
        Vec3 velocity = mc.player.getDeltaMovement();
100
        double dx = Mth.clamp(hole.getX() + 0.5 - mc.player.getX(), -CENTRE_PULL, CENTRE_PULL);
101
        double dz = Mth.clamp(hole.getZ() + 0.5 - mc.player.getZ(), -CENTRE_PULL, CENTRE_PULL);
102
        double dy = velocity.y - (pull.isOn() ? pullSpeed.getValue() : 0);
103
        mc.player.setDeltaMovement(dx, dy, dz);
104
    }
105
106
    // The first hole straight down through open air or null.
107
    private BlockPos holeBelow(BlockPos feet) {
108
        BlockPos pos = feet;
109
        for (int i = 0; i < maxHeight.getInt(); i++) {
110
            pos = pos.below();
111
            if (pos.getY() <= mc.level.getMinY() || BlockUtil.blocksMotion(BlockUtil.state(pos))) {
112
                return null;
113
            }
114
            if (isHole(pos)) {
115
                return pos;
116
            }
117
        }
118
        return null;
119
    }
120
121
    private boolean isHole(BlockPos pos) {
122
        if (BlockUtil.blocksMotion(BlockUtil.state(pos)) || !wall(pos.below())) {
123
            return false;
124
        }
125
        for (Direction side : Direction.Plane.HORIZONTAL) {
126
            if (!wall(pos.relative(side))) {
127
                return false;
128
            }
129
        }
130
        return true;
131
    }
132
133
    private boolean wall(BlockPos pos) {
134
        BlockState state = BlockUtil.state(pos);
135
        if (holes.is(Holes.ANY)) {
136
            return BlockUtil.blocksMotion(state);
137
        }
138
        return state.getBlock().getExplosionResistance() >= BlockUtil.BLAST_PROOF;
139
    }
140
}
141