SelfTrap module

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

2 implementationsCOMBAT

Full module source: 2 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/SelfTrap.javaJava · 22 lines · 503 B

Automatically traps you.

SelfTrap.javaJava · Minecraft 26.2 · 22 lines · 503 B · 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.features.modules.base.TrapModule;
6
7
public final class SelfTrap extends TrapModule {
8
    public SelfTrap() {
9
        super("SelfTrap", Category.COMBAT);
10
    }
11
12
    @Override
13
    protected boolean needNewTarget() {
14
        return target == null;
15
    }
16
17
    @Override
18
    protected @Nullable Player getTarget() {
19
        return mc.player;
20
    }
21
}
22
OfflineClientCOMBATsrc/main/java/com/jellypudding/offlineclient/modules/combat/SelfTrap.javaJava · 125 lines · 4.6 KB

Places blocks above your head to stop crystals.

SettingsBlocksPlacementBottomDelayCentreRotateToggle off when doneShow blocks
SelfTrap.javaJava · Minecraft 26.2 · 125 lines · 4.6 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.InventoryUtil.SlotSwap;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.core.registries.BuiltInRegistries;
17
import net.minecraft.world.level.block.Block;
18
import net.minecraft.world.level.block.Blocks;
19
20
import java.util.List;
21
22
public final class SelfTrap extends Module {
23
24
    public enum Top { TOP, FULL, SIDES, NONE }
25
26
    private final RegistryListSetting<Block> blocks = new RegistryListSetting<>("Blocks",
27
        "Blocks to use in order of preference.", BuiltInRegistries.BLOCK,
28
        List.of(Blocks.OBSIDIAN, Blocks.NETHERITE_BLOCK));
29
    private final EnumSetting<Top> top = new EnumSetting<>("Placement",
30
        "Which blocks go round your upper half.", Top.TOP)
31
        .describe(Top.TOP, "Covers your head only.")
32
        .describe(Top.FULL, "Seals your head and the sides at head height.")
33
        .describe(Top.SIDES, "Seals the sides at head height and leaves your head open.")
34
        .describe(Top.NONE, "Nothing round your upper half.");
35
    private final BoolSetting bottom = new BoolSetting("Bottom",
36
        "Places a block under your feet as well.", false);
37
    private final NumberSetting delay = new NumberSetting("Delay",
38
        "Ticks to wait between placements.", 1, 0, 5, 1, " ticks");
39
    private final BoolSetting center = new BoolSetting("Centre",
40
        "Moves you to the middle of your block when the module turns on.", true);
41
    private final BoolSetting rotate = new BoolSetting("Rotate",
42
        "Send a look packet towards each block.", true);
43
    private final BoolSetting toggleOff = new BoolSetting("Toggle off when done",
44
        "Turn off once every spot is filled.", true);
45
    private final BoolSetting render = new BoolSetting("Show blocks",
46
        "Outline the spots still to fill.", true);
47
    private final BoxStyle style = new BoxStyle(BoxStyle.Shape.BOTH, 0).under(render);
48
49
    private int timer;
50
    private final SlotSwap slots = new SlotSwap();
51
    private boolean placed;
52
53
    // The spots the last tick found. The unobstructed test walks the entity list.
54
    private List<BlockPos> pending = List.of();
55
56
    public SelfTrap() {
57
        super("SelfTrap", "Places blocks above your head to stop crystals.", Category.COMBAT);
58
        addSettings(blocks, top, bottom, delay, center, rotate, toggleOff, render);
59
        addSettings(style.settings());
60
        searchTags("obsidian", "head", "crystal");
61
    }
62
63
    @Override
64
    protected void onEnable() {
65
        timer = 0;
66
        slots.forget();
67
        placed = false;
68
        pending = List.of();
69
        if (center.isOn() && inGame()) {
70
            BlockUtil.centerPlayer();
71
        }
72
    }
73
74
    @Override
75
    protected void onDisable() {
76
        slots.restore();
77
        pending = List.of();
78
    }
79
80
    @Subscribe
81
    private void onTick(TickEvent event) {
82
        pending = List.of();
83
        if (!inGame() || mc.player.isSpectator()) {
84
            return;
85
        }
86
        List<BlockPos> missing = BlockUtil.trapSpots(mc.player.blockPosition(),
87
            top.isAny(Top.TOP, Top.FULL), top.isAny(Top.FULL, Top.SIDES), bottom.isOn());
88
        pending = missing;
89
        if (missing.isEmpty()) {
90
            slots.restore();
91
            if (toggleOff.isOn() && placed) {
92
                setEnabled(false);
93
            }
94
            return;
95
        }
96
        if (timer > 0) {
97
            timer--;
98
            return;
99
        }
100
101
        int slot = BlockUtil.findRankedBlockSlot(blocks.getValue(), block -> true);
102
        if (slot == -1) {
103
            slots.restore();
104
            return;
105
        }
106
        slots.select(slot);
107
108
        BlockPos target = missing.getFirst();
109
        boolean ok = BlockUtil.placeAny(target, rotate.isOn(), true);
110
        if (ok) {
111
            placed = true;
112
            timer = delay.getInt();
113
        }
114
        slots.restore();
115
    }
116
117
    @Subscribe
118
    private void onRender3D(Render3DEvent event) {
119
        if (!render.isOn()) {
120
            return;
121
        }
122
        style.drawAll(event.getBatch(), pending, false);
123
    }
124
}
125