portals module

portals: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Meteor Client, OfflineClient).

2 implementationsPlayerRENDER

Clients with this module

Full module source: 2 implementations

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

Meteor ClientPlayersrc/main/java/meteordevelopment/meteorclient/systems/modules/player/Portals.javaJava · 16 lines · 522 B

Allows you to use GUIs normally while in a Nether Portal.

Portals.javaJava · Minecraft 26.2 · 16 lines · 522 B · 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.player;
7
8
import meteordevelopment.meteorclient.systems.modules.Categories;
9
import meteordevelopment.meteorclient.systems.modules.Module;
10
11
public class Portals extends Module {
12
    public Portals() {
13
        super(Categories.Player, "portals", "Allows you to use GUIs normally while in a Nether Portal.");
14
    }
15
}
16
OfflineClientRENDERsrc/main/java/com/jellypudding/offlineclient/modules/render/Portals.javaJava · 192 lines · 7.1 KB

Highlights portals through walls.

SettingsRangeNether portalsNether colourEnd portalsEnd colourEnd portal framesFrame colourEnd gatewaysGateway colourTracers
Portals.javaJava · Minecraft 26.2 · 192 lines · 7.1 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.ColorSetting;
13
import com.jellypudding.offlineclient.setting.NumberSetting;
14
import com.jellypudding.offlineclient.util.ChunkScanner;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.core.Direction;
17
import net.minecraft.world.level.block.Block;
18
import net.minecraft.world.level.block.Blocks;
19
import net.minecraft.world.phys.AABB;
20
21
import java.util.ArrayDeque;
22
import java.util.ArrayList;
23
import java.util.Deque;
24
import java.util.HashMap;
25
import java.util.HashSet;
26
import java.util.List;
27
import java.util.Map;
28
import java.util.Set;
29
30
// Nearby chunks are scanned through the section palette on a background thread.
31
// Touching portal blocks are merged into one box per portal.
32
public final class Portals extends Module {
33
34
    private record Spot(BlockPos pos, Block block) {
35
    }
36
37
    private record Group(AABB box, int color) {
38
    }
39
40
    // Ticks between merges. The boxes only move when a portal is built or broken.
41
    private static final int MERGE_INTERVAL = 20;
42
43
    private final NumberSetting range = new NumberSetting("Range",
44
        "Chunk radius to scan around you. Only chunks the game has loaded can be scanned.", 6, 1, 8, 1, " chunks").max(64);
45
    private final BoxStyle style = BoxStyle.shapeOnly(BoxStyle.Shape.LINES);
46
    private final BoolSetting nether = new BoolSetting("Nether portals",
47
        "Show nether portals.", true);
48
    private final ColorSetting netherColor = new ColorSetting("Nether colour",
49
        "Colour of nether portals.", 276, 0.69f, 1f, false).under(nether);
50
    private final BoolSetting end = new BoolSetting("End portals",
51
        "Show the black portal blocks in a stronghold.", true);
52
    private final ColorSetting endColor = new ColorSetting("End colour",
53
        "Colour of end portals.", 156, 0.69f, 1f, false).under(end);
54
    private final BoolSetting frames = new BoolSetting("End portal frames",
55
        "Show the frame blocks around a stronghold portal.", true);
56
    private final ColorSetting frameColor = new ColorSetting("Frame colour",
57
        "Colour of end portal frames.", 210, 0.75f, 1f, false).under(frames);
58
    private final BoolSetting gateways = new BoolSetting("End gateways",
59
        "Show the gateways that throw you to the outer islands.", true);
60
    private final ColorSetting gatewayColor = new ColorSetting("Gateway colour",
61
        "Colour of end gateways.", 50, 0.75f, 1f, false).under(gateways);
62
    private final BoolSetting tracers = new BoolSetting("Tracers",
63
        "Draw a line to every portal.", false);
64
65
    private final ChunkScanner<Spot> scanner = new ChunkScanner<>();
66
    private List<Group> groups = List.of();
67
    private int timer;
68
69
    public Portals() {
70
        super("Portals", "Highlights portals through walls.", Category.RENDER);
71
        addSettings(range);
72
        addSettings(style.settings());
73
        addSettings(nether, netherColor, end, endColor, frames, frameColor,
74
            gateways, gatewayColor, tracers);
75
        searchTags("portal esp", "nether portal", "end portal");
76
    }
77
78
    @Override
79
    public String getSuffix() {
80
        return count(groups.size());
81
    }
82
83
    @Override
84
    protected void onEnable() {
85
        timer = 0;
86
        scanner.reset();
87
    }
88
89
    @Override
90
    protected void onDisable() {
91
        groups = List.of();
92
        scanner.reset();
93
    }
94
95
    private static boolean isPortal(Block block) {
96
        return block == Blocks.NETHER_PORTAL || block == Blocks.END_PORTAL
97
            || block == Blocks.END_GATEWAY || block == Blocks.END_PORTAL_FRAME;
98
    }
99
100
    // Zero for a portal the settings hide.
101
    private int colorOf(Block block) {
102
        if (block == Blocks.NETHER_PORTAL) {
103
            return nether.isOn() ? netherColor.getColor() : 0;
104
        }
105
        if (block == Blocks.END_PORTAL) {
106
            return end.isOn() ? endColor.getColor() : 0;
107
        }
108
        if (block == Blocks.END_PORTAL_FRAME) {
109
            return frames.isOn() ? frameColor.getColor() : 0;
110
        }
111
        if (block == Blocks.END_GATEWAY) {
112
            return gateways.isOn() ? gatewayColor.getColor() : 0;
113
        }
114
        return 0;
115
    }
116
117
    @Subscribe
118
    private void onPacketReceive(PacketReceiveEvent event) {
119
        scanner.markChanged(event.getPacket());
120
    }
121
122
    @Subscribe
123
    private void onTick(TickEvent event) {
124
        if (!inGame()) {
125
            return;
126
        }
127
        scanner.update(range.getInt(), (view, out) -> view.forEachMatching(
128
            state -> isPortal(state.getBlock()),
129
            (x, y, z, state) -> out.add(new Spot(new BlockPos(x, y, z), state.getBlock()))));
130
131
        if (--timer > 0) {
132
            return;
133
        }
134
        timer = MERGE_INTERVAL;
135
        groups = group(scanner.results());
136
    }
137
138
    private List<Group> group(List<Spot> spots) {
139
        Map<Block, Set<BlockPos>> found = new HashMap<>();
140
        for (Spot spot : spots) {
141
            if (colorOf(spot.block()) != 0) {
142
                found.computeIfAbsent(spot.block(), key -> new HashSet<>()).add(spot.pos());
143
            }
144
        }
145
146
        List<Group> result = new ArrayList<>();
147
        for (Map.Entry<Block, Set<BlockPos>> entry : found.entrySet()) {
148
            int color = colorOf(entry.getKey());
149
            for (AABB box : merge(entry.getValue())) {
150
                result.add(new Group(box, color));
151
            }
152
        }
153
        return result;
154
    }
155
156
    // One box per patch of touching blocks.
157
    private static List<AABB> merge(Set<BlockPos> positions) {
158
        List<AABB> boxes = new ArrayList<>();
159
        Set<BlockPos> remaining = new HashSet<>(positions);
160
        while (!remaining.isEmpty()) {
161
            BlockPos start = remaining.iterator().next();
162
            remaining.remove(start);
163
            AABB box = new AABB(start);
164
            Deque<BlockPos> queue = new ArrayDeque<>();
165
            queue.add(start);
166
            while (!queue.isEmpty()) {
167
                BlockPos pos = queue.poll();
168
                for (Direction direction : Direction.values()) {
169
                    BlockPos next = pos.relative(direction);
170
                    if (remaining.remove(next)) {
171
                        box = box.minmax(new AABB(next));
172
                        queue.add(next);
173
                    }
174
                }
175
            }
176
            boxes.add(box);
177
        }
178
        return boxes;
179
    }
180
181
    @Subscribe
182
    private void onRender3D(Render3DEvent event) {
183
        DrawBatch batch = event.getBatch();
184
        for (Group group : groups) {
185
            style.draw(batch, group.box(), group.color(), true);
186
            if (tracers.isOn()) {
187
                batch.tracer(group.box().getCenter(), group.color(), true);
188
            }
189
        }
190
    }
191
}
192