AntiVoid module

AntiVoid: Minecraft 26.3 cheat module, full source for every implementation (3 clients: MelaHack (ThunderHack fork), OfflineClient, LiquidBounce (Kotlin)).

3 implementationsMOVEMENTPLAYER

Full module source: 3 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/AntiVoid.javaJava · 58 lines · 1.8 KB

Keeps you from falling into the void.

SettingsModeSendPacket
AntiVoid.javaJava · Minecraft 26.2 · 58 lines · 1.8 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.network.protocol.game.ServerboundMovePlayerPacket;
7
import thunder.hack.ThunderHack;
8
import thunder.hack.events.impl.EventMove;
9
import thunder.hack.features.modules.Module;
10
import thunder.hack.setting.Setting;
11
12
public class AntiVoid extends Module {
13
    public AntiVoid() {
14
        super("AntiVoid", Category.MOVEMENT);
15
    }
16
17
    private static final Setting<Mode> mode = new Setting<>("Mode", Mode.NCP);
18
    private final Setting<Boolean> sendPacket = new Setting<>("SendPacket", true, v -> mode.getValue() == Mode.NCP);
19
20
    private enum Mode {NCP, Timer}
21
22
    boolean timerFlag;
23
24
    @Override
25
    public void onDisable() {
26
        if (timerFlag)
27
            ThunderHack.TICK_TIMER = 1f;
28
    }
29
30
    @EventHandler(priority = EventPriority.LOWEST)
31
    public void onMove(EventMove e) {
32
        if (fullNullCheck())
33
            return;
34
35
        if (fallingToVoid()) {
36
            if (mode.getValue() == Mode.NCP) {
37
                e.cancel();
38
                e.setY(0);
39
                if (sendPacket.getValue())
40
                    sendPacket(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY(), mc.player.getZ(), true, mc.player.horizontalCollision));
41
            } else {
42
                ThunderHack.TICK_TIMER = 0.2f;
43
                timerFlag = true;
44
            }
45
        } else if (timerFlag) {
46
            ThunderHack.TICK_TIMER = 1f;
47
            timerFlag = false;
48
        }
49
    }
50
51
    private boolean fallingToVoid() {
52
        for (int i = (int) mc.player.getY(); i >= -64; i--)
53
            if (!mc.level.isEmptyBlock(BlockPos.containing(mc.player.getX(), i, mc.player.getZ())))
54
                return false;
55
        return mc.player.fallDistance > 0;
56
    }
57
}
58
OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/AntiVoid.javaJava · 202 lines · 7.0 KB

Stops you falling into the void.

SettingsModeDepthRotateSneak to sinkSink speed
AntiVoid.javaJava · Minecraft 26.2 · 202 lines · 7.0 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 com.jellypudding.offlineclient.util.HoverDip;
12
import com.jellypudding.offlineclient.util.InventoryUtil.SlotSwap;
13
import com.jellypudding.offlineclient.util.Modules;
14
import net.minecraft.core.BlockPos;
15
import net.minecraft.world.phys.AABB;
16
import net.minecraft.world.phys.Vec3;
17
18
public final class AntiVoid extends Module {
19
20
    public enum Mode { CATCH, PLACE_BLOCK, FLIGHT }
21
22
    // Fall speed that counts as a fall and not a step down.
23
    private static final double FALLING = -0.2;
24
25
    // The lift of a normal jump. Used for climbing out whilst caught.
26
    private static final double JUMP = 0.42;
27
28
    // Ticks between the dips that keep the flight kick away whilst caught.
29
    private static final int DIP_INTERVAL = 60;
30
31
    // Ticks of placing in a row before the catch takes over. Open void has
32
    // nothing to build against and every placement comes back as a ghost.
33
    private static final int PLACE_LIMIT = 20;
34
35
    private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
36
        "What to do once the fall is spotted.", Mode.CATCH)
37
        .describe(Mode.CATCH, "Holds you still in the air. Press jump to climb whilst caught.")
38
        .describe(Mode.PLACE_BLOCK, "Puts a block from your hotbar under your feet.")
39
        .describe(Mode.FLIGHT, "Switches Flight on until you are back over solid ground.");
40
    private final NumberSetting depth = new NumberSetting("Depth",
41
        "Empty blocks below you that count as a void fall.", 12, 3, 40, 1, " blocks")
42
        .min(2).max(64);
43
    private final BoolSetting rotate = new BoolSetting("Rotate",
44
        "Face the block being placed for the server to accept it.", true)
45
        .under(mode, Mode.PLACE_BLOCK);
46
    private final BoolSetting sneakToSink = new BoolSetting("Sneak to sink",
47
        "Hold sneak to sink slowly whilst caught. Let go and you are caught again.", true)
48
        .under(mode, Mode.CATCH);
49
    private final NumberSetting sinkSpeed = new NumberSetting("Sink speed",
50
        "Blocks a tick you sink whilst sneaking.", 0.2, 0.05, 1, 0.05, " blocks")
51
        .under(sneakToSink);
52
53
    private final SlotSwap slots = new SlotSwap();
54
    private final HoverDip dip = new HoverDip();
55
    private boolean catching;
56
    private int placeTries;
57
    private boolean flightStarted;
58
59
    public AntiVoid() {
60
        super("AntiVoid", "Stops you falling into the void.", Category.MOVEMENT);
61
        addSettings(mode, depth, rotate, sneakToSink, sinkSpeed);
62
        searchTags("void", "anti void", "no void");
63
    }
64
65
    @Override
66
    public String getSuffix() {
67
        return catching ? "catching" : null;
68
    }
69
70
    @Override
71
    protected void onDisable() {
72
        catching = false;
73
        placeTries = 0;
74
        stopFlight();
75
    }
76
77
    @Subscribe
78
    private void onTick(TickEvent event) {
79
        boolean wasCatching = catching;
80
        catching = false;
81
        if (!inGame() || mc.player.isSpectator()) {
82
            return;
83
        }
84
        if (flightStarted) {
85
            catching = true;
86
            if (mc.player.onGround() || !voidBelow()) {
87
                stopFlight();
88
                catching = false;
89
            }
90
            return;
91
        }
92
        if (mc.player.getAbilities().flying || mc.player.isFallFlying()
93
            || mc.player.isPassenger() || mc.player.onGround()) {
94
            placeTries = 0;
95
            return;
96
        }
97
        // A caught player hangs still. The speed only starts the catch.
98
        Vec3 motion = mc.player.getDeltaMovement();
99
        if ((!wasCatching && motion.y > FALLING) || !voidBelow()) {
100
            placeTries = 0;
101
            return;
102
        }
103
104
        catching = true;
105
        if (!wasCatching) {
106
            dip.reset();
107
        }
108
        if (mode.is(Mode.FLIGHT)) {
109
            startFlight();
110
            return;
111
        }
112
        if (mode.is(Mode.PLACE_BLOCK) && placeTries < PLACE_LIMIT && placeUnderfoot()) {
113
            placeTries++;
114
            return;
115
        }
116
        hold(motion);
117
    }
118
119
    // Hangs in place. A jump lets go and the fall after it is caught again.
120
    private void hold(Vec3 motion) {
121
        if (mc.player.input.keyPresses.jump()) {
122
            mc.player.setDeltaMovement(motion.x, JUMP, motion.z);
123
            catching = false;
124
            return;
125
        }
126
        if (sneakToSink.isOn() && mc.player.input.keyPresses.shift()) {
127
            mc.player.setDeltaMovement(motion.x, -sinkSpeed.getValue(), motion.z);
128
            return;
129
        }
130
        mc.player.setDeltaMovement(motion.x, 0, motion.z);
131
        dip.tick(DIP_INTERVAL);
132
    }
133
134
    // Flight stays on until the player is over ground again or this module goes off.
135
    private void startFlight() {
136
        Flight flight = Modules.get(Flight.class);
137
        if (flight == null || flight.isEnabled()) {
138
            return;
139
        }
140
        flight.setEnabled(true);
141
        flightStarted = true;
142
    }
143
144
    private void stopFlight() {
145
        if (!flightStarted) {
146
            return;
147
        }
148
        flightStarted = false;
149
        Flight flight = Modules.get(Flight.class);
150
        if (flight != null) {
151
            flight.setEnabled(false);
152
        }
153
    }
154
155
    private boolean voidBelow() {
156
        AABB box = mc.player.getBoundingBox();
157
        int bottom = mc.level.getMinY();
158
        int startY = (int) Math.floor(box.minY);
159
        int limit = depth.getInt();
160
161
        int minX = (int) Math.floor(box.minX);
162
        int maxX = (int) Math.floor(box.maxX);
163
        int minZ = (int) Math.floor(box.minZ);
164
        int maxZ = (int) Math.floor(box.maxZ);
165
166
        for (int x = minX; x <= maxX; x++) {
167
            for (int z = minZ; z <= maxZ; z++) {
168
                for (int i = 0; i <= limit; i++) {
169
                    int y = startY - i;
170
                    if (y < bottom) {
171
                        break;
172
                    }
173
                    if (BlockUtil.isSolid(new BlockPos(x, y, z))) {
174
                        return false;
175
                    }
176
                }
177
            }
178
        }
179
        return true;
180
    }
181
182
    private boolean placeUnderfoot() {
183
        int slot = BlockUtil.findBlockSlot();
184
        if (slot == -1) {
185
            return false;
186
        }
187
        BlockPos target = mc.player.blockPosition().below();
188
        if (!BlockUtil.isReplaceable(target)) {
189
            return false;
190
        }
191
        slots.select(slot);
192
        boolean placed = BlockUtil.placeAny(target, rotate.isOn(), true);
193
        slots.restore();
194
        if (!placed) {
195
            return false;
196
        }
197
        Vec3 motion = mc.player.getDeltaMovement();
198
        mc.player.setDeltaMovement(motion.x, 0, motion.z);
199
        return true;
200
    }
201
}
202
LiquidBounce (Kotlin)PLAYERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/player/antivoid/ModuleAntiVoid.ktKotlin · 154 lines · 5.8 KB

Protects you from falling into the void.

SettingsVoidLevel
ModuleAntiVoid.ktKotlin · Minecraft 26.2 · 154 lines · 5.8 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.player.antivoid
20
21
import net.ccbluex.liquidbounce.common.ShapeFlag
22
import net.ccbluex.liquidbounce.event.events.NotificationEvent
23
import net.ccbluex.liquidbounce.event.tickHandler
24
import net.ccbluex.liquidbounce.features.module.ClientModule
25
import net.ccbluex.liquidbounce.features.module.ModuleCategories
26
import net.ccbluex.liquidbounce.features.module.modules.player.antivoid.mode.AntiVoidBlinkMode
27
import net.ccbluex.liquidbounce.features.module.modules.player.antivoid.mode.AntiVoidFlagMode
28
import net.ccbluex.liquidbounce.features.module.modules.player.antivoid.mode.AntiVoidGhostBlockMode
29
import net.ccbluex.liquidbounce.features.module.modules.player.antivoid.mode.AntiVoidUseItemMode
30
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug
31
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug.debugGeometry
32
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleDebug.debugParameter
33
import net.ccbluex.liquidbounce.render.engine.type.Color4b
34
import net.ccbluex.liquidbounce.utils.client.notification
35
import net.ccbluex.liquidbounce.utils.entity.PlayerSimulationCache
36
import net.ccbluex.liquidbounce.utils.math.allEmpty
37
import net.minecraft.world.phys.Vec3
38
39
/**
40
 * AntiVoid module protects the player from falling into the void by simulating
41
 * future movements and taking action if necessary.
42
 */
43
object ModuleAntiVoid : ClientModule("AntiVoid", ModuleCategories.PLAYER) {
44
45
    val mode = choices(
46
        "Mode", AntiVoidGhostBlockMode, arrayOf(
47
            AntiVoidGhostBlockMode,
48
            AntiVoidFlagMode,
49
            AntiVoidBlinkMode,
50
            AntiVoidUseItemMode,
51
        )
52
    )
53
54
    // The height at which the void is deemed to begin.
55
    private val voidThreshold by int("VoidLevel", 0, -256..0)
56
57
    // Flags indicating if an action has been already taken or needs to be taken.
58
    var isLikelyFalling = false
59
    var rescuePosition: Vec3? = null
60
        private set
61
62
    // How many future ticks to simulate to ensure safety.
63
    private const val SAFE_TICKS_THRESHOLD = 10
64
65
    override fun onEnabled() {
66
        isLikelyFalling = false
67
        super.onDisabled()
68
    }
69
70
    /**
71
     * Executes periodically to check if an anti-void action is required, and triggers it if necessary.
72
     */
73
    @Suppress("unused")
74
    private val voidHandler = tickHandler {
75
        // Analyzes if the player might be falling into the void soon.
76
        try {
77
            ShapeFlag.noShapeChange = true
78
            isLikelyFalling = isPredictingFall()
79
        } finally {
80
            ShapeFlag.noShapeChange = false
81
        }
82
83
        val rescuePosition = mode.activeMode.discoverRescuePosition()
84
        if (rescuePosition != null) {
85
            this@ModuleAntiVoid.rescuePosition = rescuePosition
86
        }
87
88
        debugParameter("IsExempt") { mode.activeMode.isExempt }
89
        debugParameter("IsLikelyFalling") { isLikelyFalling }
90
        debugParameter("SafePosition") { ModuleAntiVoid.rescuePosition }
91
92
        if (mode.activeMode.isExempt || !isLikelyFalling) {
93
            return@tickHandler
94
        }
95
96
        if (ModuleAntiVoid.rescuePosition == null) {
97
            return@tickHandler
98
        }
99
100
        val boundingBox = player.boundingBox.setMinY(voidThreshold.toDouble())
101
102
        // If no collision is detected within a threshold beyond which falling
103
        // into void is likely, take the necessary action.
104
        val collisions = world.getBlockCollisions(player, boundingBox)
105
106
        if (collisions.allEmpty()) {
107
            if (mode.activeMode.rescue()) {
108
                notification(
109
                    "AntiVoid", "Action taken to prevent void fall",
110
                    NotificationEvent.Severity.INFO
111
                )
112
                ModuleAntiVoid.rescuePosition = null
113
            }
114
        }
115
    }
116
117
    /**
118
     * Checks if the player is likely to fall into the void within a certain threshold.
119
     */
120
    private fun isPredictingFall(): Boolean {
121
        for (tick in 0 until SAFE_TICKS_THRESHOLD) {
122
            val snapshot = PlayerSimulationCache.getSimulationForLocalPlayer().getSnapshotAt(tick)
123
            if (snapshot.fallDistance > 0.0) {
124
                return isSafeForRescue(snapshot.pos)
125
            }
126
        }
127
        return false
128
    }
129
130
    fun isSafeForRescue(pos: Vec3): Boolean {
131
        val boundingBox = player.boundingBox
132
            // Change position to the snapshot position
133
            .move(pos.subtract(player.position()))
134
            .setMinY(voidThreshold.toDouble())
135
136
        // If no collision is detected within a threshold beyond which falling
137
        // into void is likely, take the necessary action.
138
        val collisions = world.getBlockCollisions(player, boundingBox)
139
        val hasCollision = collisions.allEmpty()
140
        debugGeometry("BoundingBox") {
141
            ModuleDebug.DebuggedBox(
142
                boundingBox, if (hasCollision) {
143
                    Color4b.RED
144
                } else {
145
                    Color4b.GREEN
146
                }.alpha(150)
147
            )
148
        }
149
150
        return hasCollision
151
    }
152
153
}
154