TunnelEsp module

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

2 implementationsRENDER

Full module source: 2 implementations

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

MelaHack (ThunderHack fork)RENDERsrc/main/java/thunder/hack/features/modules/render/TunnelEsp.javaJava · 173 lines · 6.4 KB

Highlights tunnels.

SettingsColorBoxOutline
TunnelEsp.javaJava · Minecraft 26.2 · 173 lines · 6.4 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.render;
2
3
import thunder.hack.features.modules.Module;
4
import thunder.hack.setting.Setting;
5
import thunder.hack.setting.impl.ColorSetting;
6
import thunder.hack.utility.Timer;
7
import thunder.hack.utility.render.Render2DEngine;
8
import thunder.hack.utility.render.Render3DEngine;
9
import com.mojang.blaze3d.vertex.PoseStack;
10
import java.awt.*;
11
import java.util.ArrayList;
12
import java.util.List;
13
import java.util.function.Function;
14
import net.minecraft.core.BlockPos;
15
import net.minecraft.world.phys.AABB;
16
17
public class TunnelEsp extends Module {
18
    public TunnelEsp() {
19
        super("TunnelEsp", Category.RENDER);
20
    }
21
22
    private final Setting<ColorSetting> color = new Setting<>("Color", new ColorSetting(new Color(0xAE8A8AF6, true)));
23
    public Setting<Boolean> box = new Setting<>("Box", true);
24
    public Setting<Boolean> outline = new Setting<>("Outline", true);
25
    List<AABB> renderBoxes = new ArrayList<>();
26
    private Timer delayTimer = new Timer();
27
28
    public void onRender3D(PoseStack stack) {
29
        try {
30
            for (AABB box_ : renderBoxes) {
31
                // рандомные генерации
32
                if (box_.getZsize() < 5 && box_.getXsize() < 5)
33
                    continue;
34
35
                if (box.getValue()) Render3DEngine.FILLED_QUEUE.add(new Render3DEngine.FillAction(box_, color.getValue().getColorObject()));
36
                if (outline.getValue())
37
                    Render3DEngine.OUTLINE_QUEUE.add(new Render3DEngine.OutlineAction(box_, Render2DEngine.injectAlpha(color.getValue().getColorObject(), 255), 2));
38
            }
39
        } catch (Exception ignored) {
40
        }
41
    }
42
43
    @Override
44
    public void onEnable() {
45
        renderBoxes.clear();
46
    }
47
48
    @Override
49
    public void onThread() {
50
        if (delayTimer.passedMs(2000)) {
51
            for (int x = (int) (mc.player.getX() - 128); x < mc.player.getX() + 128; ++x) {
52
                for (int z = (int) (mc.player.getZ() - 128); z < mc.player.getZ() + 128; ++z) {
53
                    for (int y = 0; y < 121; ++y) {
54
                        BlockPos bp = new BlockPos(x, y, z);
55
56
                        if (one_two(bp) && !alreadyIn(new AABB(bp.getX(), bp.getY(), bp.getZ(), bp.getX() + 1, bp.getY() + 2, bp.getZ() + 1))) {
57
                            AABB renderBox = new AABB(bp.getX(), bp.getY(), bp.getZ(), bp.getX() + 1, bp.getY() + 2, bp.getZ() + 1);
58
                            renderBoxes.add(getFullBox(renderBox, x, y, z, 1));
59
                        }
60
61
                        if (one_one(bp) && !alreadyIn(new AABB(bp))) {
62
                            AABB renderBox = new AABB(bp);
63
                            renderBoxes.add(getFullBox(renderBox, x, y, z, 0));
64
                        }
65
66
                        /*
67
                        if (one_three(bp) && !alreadyIn(new Box(bp.getX(), bp.getY(), bp.getZ(), bp.getX() + 1, bp.getY() + 3, bp.getZ() + 1))) {
68
                            Box renderBox = new Box(bp.getX(), bp.getY(), bp.getZ(), bp.getX() + 1, bp.getY() + 3, bp.getZ() + 1);
69
                            renderBoxes.add(getFullBox(renderBox, x, y, z, 2));
70
                        }
71
                         */
72
                    }
73
                }
74
            }
75
            delayTimer.reset();
76
        }
77
    }
78
79
    private AABB getFullBox(AABB raw, int x, int y, int z, int mode) {
80
        BlockPos checkBp1 = new BlockPos(x, y, z + 1);
81
82
        Function<BlockPos, Boolean> check = getCheckByMode(mode);
83
84
        while (check.apply(checkBp1)) {
85
            raw = raw.setMaxZ(raw.maxZ + 1);
86
            checkBp1 = checkBp1.south();
87
        }
88
89
        BlockPos checkBp2 = new BlockPos(x + 1, y, z);
90
        while (check.apply(checkBp2)) {
91
            raw = raw.setMaxX(raw.maxX + 1);
92
            checkBp2 = checkBp2.east();
93
        }
94
95
        BlockPos checkBp3 = new BlockPos(x, y, z - 1);
96
        while (check.apply(checkBp3)) {
97
            raw = raw.setMinZ(raw.minZ - 1);
98
            checkBp3 = checkBp3.north();
99
        }
100
101
        BlockPos checkBp4 = new BlockPos(x - 1, y, z);
102
        while (check.apply(checkBp4)) {
103
            raw = raw.setMinX(raw.minX - 1);
104
            checkBp4 = checkBp4.west();
105
        }
106
107
        return raw;
108
    }
109
110
    private Function<BlockPos, Boolean> getCheckByMode(int mode) {
111
        return switch (mode) {
112
            case 1 -> TunnelEsp::one_two;
113
            case 2 -> TunnelEsp::one_three;
114
            default -> TunnelEsp::one_one;
115
        };
116
    }
117
118
    private boolean alreadyIn(AABB box) {
119
        for (AABB box2 : renderBoxes) {
120
            if (box.intersects(box2))
121
                return true;
122
        }
123
        return false;
124
    }
125
126
    //1 x 2 check
127
    private static boolean one_three(BlockPos pos) {
128
        if (!isAir(pos) || !isAir(pos.above()) || !isAir(pos.above().above())) return false;
129
        if (isAir(pos.below()) || isAir(pos.above().above().above())) return false;
130
131
        if (isAir(pos.above().north()) && isAir(pos.above().south()))
132
            return !isAir(pos.above().east()) && !isAir(pos.above().west());
133
134
        if (isAir(pos.above().east()) && isAir(pos.above().west()))
135
            return !isAir(pos.above().north()) && !isAir(pos.above().south());
136
137
        return false;
138
    }
139
140
    //1 x 2 check
141
    private static boolean one_two(BlockPos pos) {
142
        if (!isAir(pos) || !isAir(pos.above())) return false;
143
        if (isAir(pos.below()) || isAir(pos.above().above())) return false;
144
145
        if (isAir(pos.north()) && isAir(pos.south()) && isAir(pos.above().north()) && isAir(pos.above().south()))
146
            return !isAir(pos.east()) && !isAir(pos.west()) && !isAir(pos.above().east()) && !isAir(pos.above().west());
147
148
        if (isAir(pos.east()) && isAir(pos.west()) && isAir(pos.above().east()) && isAir(pos.above().west()))
149
            return !isAir(pos.north()) && !isAir(pos.south()) && !isAir(pos.above().north()) && !isAir(pos.above().south());
150
151
        return false;
152
    }
153
154
    //1 x 1 check
155
    private static boolean one_one(BlockPos pos) {
156
        if (!isAir(pos)) return false;
157
        if (isAir(pos.below()) || isAir(pos.above())) return false;
158
159
        if (isAir(pos.north()) && isAir(pos.south()))
160
            return !isAir(pos.east()) && !isAir(pos.west()) && !isAir(pos.above().east()) && !isAir(pos.above().west());
161
162
        if (isAir(pos.east()) && isAir(pos.west()))
163
            return !isAir(pos.north()) && !isAir(pos.south());
164
165
        return false;
166
    }
167
168
169
    private static boolean isAir(BlockPos bp) {
170
        return mc.level.isEmptyBlock(bp);
171
    }
172
}
173
OfflineClientRENDERsrc/main/java/com/jellypudding/offlineclient/modules/render/TunnelEsp.javaJava · 218 lines · 8.0 KB

Highlights hand dug tunnels underground.

SettingsRangeBottomTopBox heightConnected
TunnelEsp.javaJava · Minecraft 26.2 · 218 lines · 8.0 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.render;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.PacketReceiveEvent;
5
import com.jellypudding.offlineclient.event.events.Render3DEvent;
6
import com.jellypudding.offlineclient.event.events.TickEvent;
7
import com.jellypudding.offlineclient.module.Category;
8
import com.jellypudding.offlineclient.module.Module;
9
import com.jellypudding.offlineclient.render.BoxStyle;
10
import com.jellypudding.offlineclient.render.DrawBatch;
11
import com.jellypudding.offlineclient.setting.BoolSetting;
12
import com.jellypudding.offlineclient.setting.NumberSetting;
13
import com.jellypudding.offlineclient.util.BlockUtil;
14
import com.jellypudding.offlineclient.util.ChunkScanner;
15
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
16
import net.minecraft.core.BlockPos;
17
import net.minecraft.world.level.block.state.BlockState;
18
import net.minecraft.world.phys.AABB;
19
20
import java.util.List;
21
22
// Highlights one wide two high corridors. Natural caves almost never make that shape.
23
public final class TunnelEsp extends Module {
24
25
    // A box is only ankle high. It can only touch the four sideways.
26
    // How open a neighbouring column is.
27
    private enum Side {
28
        WALKABLE,
29
        PART_BLOCKED,
30
        BLOCKED
31
    }
32
33
    private record Spot(int x, int y, int z) {
34
    }
35
36
    private final NumberSetting range = new NumberSetting("Range",
37
        "Chunk radius to search around you.", 4, 1, 8, 1, " chunks").max(12);
38
    private final NumberSetting bottom = new NumberSetting("Bottom",
39
        "Lowest height to search.", -60, -64, 320, 4).min(-2048).max(2048);
40
    private final NumberSetting top = new NumberSetting("Top",
41
        "Highest height to search.", 62, -64, 320, 4).min(-2048).max(2048);
42
    private final NumberSetting height = new NumberSetting("Box height",
43
        "How tall the drawn box is.", 0.15, 0.05, 1, 0.05).min(0.01);
44
    private final BoolSetting connected = new BoolSetting("Connected",
45
        "Boxes that touch leave out the faces they share so a corridor draws as one strip.", true);
46
    private final BoxStyle style = new BoxStyle(BoxStyle.Shape.BOTH, 39);
47
48
    private final ChunkScanner<Spot> scanner = new ChunkScanner<>();
49
50
    // The spots the neighbour keys were built from.
51
    private List<Spot> known = List.of();
52
    private final LongOpenHashSet keys = new LongOpenHashSet();
53
54
    // The scan bounds the cached chunks were built with.
55
    private int lastLow = Integer.MIN_VALUE;
56
    private int lastHigh = Integer.MIN_VALUE;
57
58
    public TunnelEsp() {
59
        super("TunnelESP", "Highlights hand dug tunnels underground.", Category.RENDER);
60
        addSettings(range, bottom, top, height, connected);
61
        addSettings(style.settings());
62
        searchTags("tunnel", "base finder", "corridor");
63
    }
64
65
    @Override
66
    public String getSuffix() {
67
        return scanner.size() == 0 ? null : String.valueOf(scanner.size());
68
    }
69
70
    @Override
71
    protected void onEnable() {
72
        forget();
73
    }
74
75
    @Override
76
    protected void onDisable() {
77
        forget();
78
    }
79
80
    private void forget() {
81
        scanner.reset();
82
        known = List.of();
83
        keys.clear();
84
    }
85
86
    @Subscribe
87
    private void onPacketReceive(PacketReceiveEvent event) {
88
        scanner.markChanged(event.getPacket());
89
    }
90
91
    @Subscribe
92
    private void onTick(TickEvent event) {
93
        if (!inGame()) {
94
            return;
95
        }
96
        int low = bottom.getInt();
97
        int high = top.getInt();
98
        // The scan reads these once a chunk. A change has to throw the cache away.
99
        if (low != lastLow || high != lastHigh) {
100
            lastLow = low;
101
            lastHigh = high;
102
            scanner.reset();
103
        }
104
        scanner.update(range.getInt(), (view, out) -> {
105
            int baseX = view.pos().getMinBlockX();
106
            int baseZ = view.pos().getMinBlockZ();
107
            int from = Math.max(low, view.minY());
108
            int to = Math.min(high, view.maxY() - 2);
109
110
            boolean[][][] found = new boolean[16][16][Math.max(0, to - from + 1)];
111
            for (int x = 0; x < 16; x++) {
112
                for (int z = 0; z < 16; z++) {
113
                    for (int y = from; y <= to; y++) {
114
                        if (isTunnel(view, baseX + x, y, baseZ + z)) {
115
                            found[x][z][y - from] = true;
116
                        }
117
                    }
118
                }
119
            }
120
            // A single lonely spot is almost always a natural gap.
121
            for (int x = 0; x < 16; x++) {
122
                for (int z = 0; z < 16; z++) {
123
                    for (int i = 0; i < found[x][z].length; i++) {
124
                        if (found[x][z][i] && (onEdge(x, z) || hasNeighbour(found, x, z, i))) {
125
                            out.add(new Spot(baseX + x, from + i, baseZ + z));
126
                        }
127
                    }
128
                }
129
            }
130
        });
131
    }
132
133
    private static boolean onEdge(int x, int z) {
134
        return x == 0 || x == 15 || z == 0 || z == 15;
135
    }
136
137
    private static boolean hasNeighbour(boolean[][][] found, int x, int z, int i) {
138
        return found[x - 1][z][i] || found[x + 1][z][i]
139
            || found[x][z - 1][i] || found[x][z + 1][i];
140
    }
141
142
    // True for a spot that is open along one axis and walled on the other.
143
    private static boolean isTunnel(ChunkScanner.View view, int x, int y, int z) {
144
        if (!canStandIn(view, x, y, z)) {
145
            return false;
146
        }
147
        Side east = sideAt(view, x + 1, y, z);
148
        if (east == Side.PART_BLOCKED) {
149
            return false;
150
        }
151
        Side west = sideAt(view, x - 1, y, z);
152
        if (west == Side.PART_BLOCKED) {
153
            return false;
154
        }
155
        Side south = sideAt(view, x, y, z + 1);
156
        if (south == Side.PART_BLOCKED) {
157
            return false;
158
        }
159
        Side north = sideAt(view, x, y, z - 1);
160
        if (north == Side.PART_BLOCKED) {
161
            return false;
162
        }
163
        boolean alongX = east == Side.WALKABLE && west == Side.WALKABLE
164
            && south == Side.BLOCKED && north == Side.BLOCKED;
165
        boolean alongZ = south == Side.WALKABLE && north == Side.WALKABLE
166
            && east == Side.BLOCKED && west == Side.BLOCKED;
167
        return alongX || alongZ;
168
    }
169
170
    private static Side sideAt(ChunkScanner.View view, int x, int y, int z) {
171
        if (canStandIn(view, x, y, z)) {
172
            return Side.WALKABLE;
173
        }
174
        if (!passable(view, x, y, z) && !passable(view, x, y + 1, z)) {
175
            return Side.BLOCKED;
176
        }
177
        return Side.PART_BLOCKED;
178
    }
179
180
    // A floor to stand on with two clear blocks above and a ceiling on top.
181
    private static boolean canStandIn(ChunkScanner.View view, int x, int y, int z) {
182
        return solid(view, x, y - 1, z)
183
            && passable(view, x, y, z)
184
            && passable(view, x, y + 1, z)
185
            && !passable(view, x, y + 2, z);
186
    }
187
188
    private static boolean solid(ChunkScanner.View view, int x, int y, int z) {
189
        BlockState state = view.get(x, y, z);
190
        return BlockUtil.blocksMotion(state) && state.getFluidState().isEmpty();
191
    }
192
193
    private static boolean passable(ChunkScanner.View view, int x, int y, int z) {
194
        BlockState state = view.get(x, y, z);
195
        return !BlockUtil.blocksMotion(state) && state.getFluidState().isEmpty();
196
    }
197
198
    @Subscribe
199
    private void onRender3D(Render3DEvent event) {
200
        DrawBatch batch = event.getBatch();
201
        double boxHeight = height.getValue();
202
        List<Spot> spots = scanner.results();
203
        boolean join = connected.isOn();
204
        if (join && spots != known) {
205
            known = spots;
206
            keys.clear();
207
            for (Spot spot : spots) {
208
                keys.add(BlockPos.asLong(spot.x(), spot.y(), spot.z()));
209
            }
210
        }
211
        for (Spot spot : spots) {
212
            AABB box = new AABB(spot.x(), spot.y(), spot.z(),
213
                spot.x() + 1, spot.y() + boxHeight, spot.z() + 1);
214
            style.drawJoined(batch, box, join ? DrawBatch.sharedSides(keys, BlockPos.asLong(spot.x(), spot.y(), spot.z())) : 0, true);
215
        }
216
    }
217
}
218