Radar module

Radar: Minecraft 26.3 cheat module, full source for every implementation (2 clients: OfflineClient, LiquidBounce (Kotlin)).

2 implementationsRENDER

Full module source: 2 implementations

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

OfflineClientRENDERsrc/main/java/com/jellypudding/offlineclient/modules/render/Radar.javaJava · 174 lines · 7.9 KB

Draws a small map of nearby entities on your screen.

SettingsSizeRangeCornerMarginRotatePlayersSleeping playersHostile mobsSlimesPassive mobsWater animalsBatsInvisibleItemsNamesHeight tintTint depthTint strength
Radar.javaJava · Minecraft 26.2 · 174 lines · 7.9 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.Render2DEvent;
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.ColorUtil;
11
import com.jellypudding.offlineclient.util.EntityUtil;
12
import com.jellypudding.offlineclient.util.RenderUtil;
13
import net.minecraft.client.gui.Font;
14
import net.minecraft.client.gui.GuiGraphicsExtractor;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.entity.LivingEntity;
17
import net.minecraft.world.entity.monster.cubemob.AbstractCubeMob;
18
import net.minecraft.world.entity.player.Player;
19
import net.minecraft.world.phys.Vec3;
20
21
public final class Radar extends Module {
22
23
    private static final int BACKGROUND = 0x80101018;
24
    private static final int BORDER = 0xFF3A3A4A;
25
    private static final int GRID = 0x40FFFFFF;
26
    private static final int SELF = 0xFFFFFFFF;
27
28
    public enum Corner { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }
29
30
    private final NumberSetting size = new NumberSetting("Size",
31
        "Width of the radar in pixels.", 100, 60, 220, 10, " px").min(40).max(400);
32
    private final NumberSetting range = new NumberSetting("Range",
33
        "How far the edge of the radar reaches.", 64, 16, 256, 8, " blocks").min(4);
34
    private final EnumSetting<Corner> corner = new EnumSetting<>("Corner",
35
        "Which corner the radar sits in.", Corner.TOP_RIGHT);
36
    private final NumberSetting margin = new NumberSetting("Margin",
37
        "Gap between the radar and the screen edge.", 6, 0, 40, 1, " px").min(0);
38
    private final BoolSetting rotate = new BoolSetting("Rotate",
39
        "Turns the radar until the way you face points up.", true);
40
    private final BoolSetting players = new BoolSetting("Players",
41
        "Show other players.", true);
42
    private final BoolSetting sleeping = new BoolSetting("Sleeping players",
43
        "Keep players who are in a bed on the radar.", true).under(players);
44
    private final BoolSetting hostile = new BoolSetting("Hostile mobs",
45
        "Show zombies and skeletons and the rest.", false);
46
    private final BoolSetting slimes = new BoolSetting("Slimes",
47
        "Slimes and magma cubes show.", true).under(hostile);
48
    private final BoolSetting passive = new BoolSetting("Passive mobs",
49
        "Show animals and villagers.", false);
50
    private final BoolSetting water = new BoolSetting("Water animals",
51
        "Show fish and squid and dolphins.", false);
52
    private final BoolSetting bats = new BoolSetting("Bats",
53
        "Show bats.", false);
54
    private final BoolSetting invisible = new BoolSetting("Invisible",
55
        "Show entities that are under an invisibility effect.", true);
56
    private final BoolSetting items = new BoolSetting("Items",
57
        "Show dropped items.", false);
58
    private final BoolSetting names = new BoolSetting("Names",
59
        "Write player names next to their dot.", true);
60
    private final BoolSetting height = new BoolSetting("Height tint",
61
        "Fade dots that are far above or below you.", true);
62
    private final NumberSetting tintDepth = new NumberSetting("Tint depth",
63
        "Blocks above or below you at which a dot is at its faintest.", 40, 5, 128, 1, " blocks")
64
        .min(1).under(height);
65
    private final NumberSetting tintStrength = new NumberSetting("Tint strength",
66
        "How faint the furthest dots get.", 65, 10, 100, 5, "%").min(0).max(100)
67
        .under(height);
68
69
    public Radar() {
70
        super("Radar", "Draws a small map of nearby entities on your screen.", Category.RENDER);
71
        addSettings(size, range, corner, margin, rotate, players, sleeping, hostile, slimes, passive,
72
            water, bats, invisible, items, names, height, tintDepth, tintStrength);
73
        searchTags("minimap", "entity map");
74
    }
75
76
    // Which kinds of entity the filters let through.
77
    private boolean shows(Entity entity) {
78
        if (entity == mc.player) {
79
            return false;
80
        }
81
        if (entity instanceof LivingEntity living && !living.isAlive()) {
82
            return false;
83
        }
84
        if (!invisible.isOn() && entity.isInvisible()) {
85
            return false;
86
        }
87
        return switch (EntityUtil.kindOf(entity)) {
88
            case PLAYER -> players.isOn() && !entity.isSpectator()
89
                && (sleeping.isOn() || !((Player) entity).isSleeping());
90
            case HOSTILE -> hostile.isOn() && (slimes.isOn() || !(entity instanceof AbstractCubeMob));
91
            case PASSIVE -> passive.isOn();
92
            case WATER -> water.isOn();
93
            case AMBIENT -> bats.isOn();
94
            case ITEM -> items.isOn();
95
            case OTHER -> false;
96
        };
97
    }
98
99
    @Subscribe
100
    private void onRender2D(Render2DEvent event) {
101
        if (!inGame()) {
102
            return;
103
        }
104
        GuiGraphicsExtractor context = event.getContext();
105
        int box = size.getInt();
106
        int gap = margin.getInt();
107
        int left = switch (corner.getValue()) {
108
            case TOP_LEFT, BOTTOM_LEFT -> gap;
109
            case TOP_RIGHT, BOTTOM_RIGHT -> context.guiWidth() - box - gap;
110
        };
111
        int top = switch (corner.getValue()) {
112
            case TOP_LEFT, TOP_RIGHT -> gap;
113
            case BOTTOM_LEFT, BOTTOM_RIGHT -> context.guiHeight() - box - gap;
114
        };
115
        int centerX = left + box / 2;
116
        int centerY = top + box / 2;
117
118
        RenderUtil.borderedRect(context, left, top, left + box, top + box, BACKGROUND, BORDER);
119
        context.fill(centerX, top + 2, centerX + 1, top + box - 2, GRID);
120
        context.fill(left + 2, centerY, left + box - 2, centerY + 1, GRID);
121
122
        double blocks = range.getValue();
123
        double pixelsPerBlock = (box / 2.0) / blocks;
124
        double yaw = Math.toRadians(mc.player.getYRot());
125
        boolean turn = rotate.isOn();
126
        double sin = Math.sin(yaw);
127
        double cos = Math.cos(yaw);
128
        Vec3 eye = mc.player.position();
129
        Font font = mc.font;
130
131
        context.guiRenderState.up();
132
        for (Entity entity : mc.level.entitiesForRendering()) {
133
            if (!shows(entity)) {
134
                continue;
135
            }
136
            double dx = entity.getX() - eye.x;
137
            double dz = entity.getZ() - eye.z;
138
            if (dx * dx + dz * dz > blocks * blocks) {
139
                continue;
140
            }
141
            // Yaw zero looks south.
142
            double rx = turn ? -(dx * cos + dz * sin) : dx;
143
            double rz = turn ? dx * sin - dz * cos : dz;
144
            int px = centerX + (int) Math.round(rx * pixelsPerBlock);
145
            int py = centerY + (int) Math.round(rz * pixelsPerBlock);
146
            if (px < left + 1 || px > left + box - 2 || py < top + 1 || py > top + box - 2) {
147
                continue;
148
            }
149
150
            int color = EntityUtil.colorOf(entity);
151
            if (height.isOn()) {
152
                double drop = Math.abs(entity.getY() - eye.y);
153
                float faintest = 1 - tintStrength.getFloat() / 100f;
154
                color = ColorUtil.fade(color,
155
                    (float) Math.clamp(1 - drop / tintDepth.getValue(), faintest, 1));
156
            }
157
            boolean isPlayer = entity instanceof Player;
158
            int dot = isPlayer ? 2 : 1;
159
            context.fill(px - dot, py - dot, px + dot + 1, py + dot + 1, color);
160
            if (isPlayer && names.isOn()) {
161
                String name = EntityUtil.displayNameOf((Player) entity);
162
                int width = font.width(name);
163
                int textX = px - width / 2;
164
                if (width < box - 2) {
165
                    textX = Math.clamp(textX, left + 1, left + box - width - 1);
166
                }
167
                context.text(font, name, textX, py - font.lineHeight - 2, color, true);
168
            }
169
        }
170
171
        context.fill(centerX - 1, centerY - 1, centerX + 2, centerY + 2, SELF);
172
    }
173
}
174
LiquidBounce (Kotlin)RENDERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleRadar.ktKotlin · 249 lines · 9.4 KB

Shows the direction of rendered entities on GUI.

SettingsAngleLimitationRadiusOnlyPlayersWidthHeightTailConcaveSizeSize
ModuleRadar.ktKotlin · Minecraft 26.2 · 249 lines · 9.4 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
20
package net.ccbluex.liquidbounce.features.module.modules.render
21
22
import com.mojang.blaze3d.platform.NativeImage
23
import net.ccbluex.liquidbounce.LiquidBounce
24
import net.ccbluex.liquidbounce.config.types.CurveValue.Axis.Companion.axis
25
import net.ccbluex.liquidbounce.config.types.group.Mode
26
import net.ccbluex.liquidbounce.config.types.group.ModeValueGroup
27
import net.ccbluex.liquidbounce.event.events.OverlayRenderEvent
28
import net.ccbluex.liquidbounce.event.handler
29
import net.ccbluex.liquidbounce.features.module.ClientModule
30
import net.ccbluex.liquidbounce.features.module.ModuleCategories
31
import net.ccbluex.liquidbounce.render.ClientRenderPipelines
32
import net.ccbluex.liquidbounce.render.GenericDistanceHSBColorMode
33
import net.ccbluex.liquidbounce.render.GenericEntityHealthColorMode
34
import net.ccbluex.liquidbounce.render.GenericRainbowColorMode
35
import net.ccbluex.liquidbounce.render.GenericStaticColorMode
36
import net.ccbluex.liquidbounce.render.drawTexQuad
37
import net.ccbluex.liquidbounce.render.drawTriangle
38
import net.ccbluex.liquidbounce.render.engine.type.Color4b
39
import net.ccbluex.liquidbounce.render.withPush
40
import net.ccbluex.liquidbounce.utils.math.fastSin
41
import net.ccbluex.liquidbounce.utils.math.floorToInt
42
import net.ccbluex.liquidbounce.utils.client.scaledDimension
43
import net.ccbluex.liquidbounce.utils.math.toRadians
44
import net.ccbluex.liquidbounce.utils.entity.RenderedEntities
45
import net.ccbluex.liquidbounce.utils.entity.cameraDistance
46
import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentPosition
47
import net.ccbluex.liquidbounce.utils.kotlin.unaryMinus
48
import net.ccbluex.liquidbounce.utils.render.asTexture
49
import net.ccbluex.liquidbounce.utils.render.textureSetup
50
import net.ccbluex.liquidbounce.utils.render.readNativeImage
51
import net.minecraft.client.CameraType
52
import net.minecraft.client.gui.GuiGraphicsExtractor
53
import net.minecraft.client.renderer.texture.AbstractTexture
54
import net.minecraft.util.Mth
55
import net.minecraft.world.entity.player.Player
56
import org.joml.Matrix3x2f
57
import org.joml.Vector2f
58
import kotlin.math.atan2
59
60
/**
61
 * Radar module
62
 *
63
 * Shows the direction of rendered entities on GUI.
64
 */
65
object ModuleRadar : ClientModule("Radar", ModuleCategories.RENDER, aliases = listOf("PointerESP")) {
66
67
    private val tiltModes = choices("Tilt", 0) {
68
        arrayOf(TiltMode.Static, TiltMode.ByPitch)
69
    }
70
71
    private sealed class TiltMode(name: String) : Mode(name) {
72
        final override val parent: ModeValueGroup<*>
73
            get() = tiltModes
74
75
        abstract fun transform(pose: Matrix3x2f, partialTick: Float)
76
77
        object Static : TiltMode("Static") {
78
            private val angle by float("Angle", 90f, -90f..90f, "deg")
79
80
            override fun transform(pose: Matrix3x2f, partialTick: Float) {
81
                pose.scale(1f, angle.fastSin())
82
            }
83
        }
84
85
        object ByPitch : TiltMode("ByPitch") {
86
            private val limitation by floatRange("Limitation", 45f..90f, 0f..90f, "deg").onChanged {
87
                limitationNeg = -it
88
            }
89
            private var limitationNeg: ClosedFloatingPointRange<Float> = -limitation
90
91
            override fun transform(pose: Matrix3x2f, partialTick: Float) {
92
                val pitchRad = run {
93
                    val pitch = player.getXRot(partialTick)
94
                    if (pitch >= 0) {
95
                        pitch.coerceIn(limitation)
96
                    } else {
97
                        pitch.coerceIn(limitationNeg)
98
                    }
99
                }.toRadians()
100
101
                pose.scale(1f, pitchRad.fastSin())
102
            }
103
        }
104
    }
105
106
    private val radius by float("Radius", 40f, 2f..200f)
107
108
    private val onlyPlayers by boolean("OnlyPlayers", false)
109
110
    private val pointerModes = choices("PointerMode", 0) {
111
        arrayOf(
112
            PointerMode.Triangle,
113
            PointerMode.ImageMode("Image1", LiquidBounce.resource("misc/triangle1.png").readNativeImage()),
114
            PointerMode.ImageMode("Image2", LiquidBounce.resource("misc/triangle2.png").readNativeImage()),
115
        )
116
    }
117
118
    private sealed class PointerMode(name: String) : Mode(name) {
119
        final override val parent: ModeValueGroup<*>
120
            get() = pointerModes
121
122
        context(ctx: GuiGraphicsExtractor)
123
        abstract fun draw(color: Color4b)
124
125
        object Triangle : PointerMode("Triangle") {
126
            private val width by float("Width", 8f, 1f..100f)
127
            private val height by float("Height", 10f, 1f..100f)
128
            private val tailConcaveSize by float("TailConcaveSize", 2f, 0f..50f).onChange {
129
                minOf(it, height)
130
            }
131
132
            context(ctx: GuiGraphicsExtractor)
133
            override fun draw(color: Color4b) {
134
                if (Mth.equal(tailConcaveSize, 0f)) {
135
                    ctx.drawTriangle(
136
                        x0 = -width * 0.5f, y0 = 0f,
137
                        x1 = 0f, y1 = height,
138
                        x2 = width * 0.5f, y2 = 0f,
139
                        fillColor = color,
140
                        cull = false,
141
                    )
142
                } else {
143
                    ctx.drawTriangle(
144
                        x0 = -width * 0.5f, y0 = 0f,
145
                        x1 = 0f, y1 = height,
146
                        x2 = 0f, y2 = tailConcaveSize,
147
                        fillColor = color,
148
                        cull = false,
149
                    ) // left
150
                    ctx.drawTriangle(
151
                        x0 = 0f, y0 = tailConcaveSize,
152
                        x1 = 0f, y1 = height,
153
                        x2 = width * 0.5f, y2 = 0f,
154
                        fillColor = color,
155
                        cull = false,
156
                    ) // right
157
                }
158
            }
159
        }
160
161
        class ImageMode(name: String, val texture: AbstractTexture) : PointerMode(name) {
162
            constructor(name: String, nativeImage: NativeImage) : this(name, nativeImage.asTexture { "Radar $name" })
163
164
            private val size by float("Size", 10f, 1f..100f)
165
166
            context(ctx: GuiGraphicsExtractor)
167
            override fun draw(color: Color4b) {
168
                ctx.drawTexQuad(
169
                    texture.textureSetup,
170
                    -size / 2f, 0f, size / 2f, size,
171
                    u1 = 1f, v1 = 1f, u2 = 0f, v2 = 0f,
172
                    argb = color.argb,
173
                    pipeline = ClientRenderPipelines.GUI.TexQuadNoCull,
174
                )
175
            }
176
        }
177
    }
178
179
    private val colorModes = choices("ColorMode", 0) {
180
        arrayOf(
181
            GenericDistanceHSBColorMode.entity(it, fixedAlpha = 1F),
182
            GenericEntityHealthColorMode(it),
183
            GenericStaticColorMode(it, Color4b.WHITE.with(a = 100)),
184
            GenericRainbowColorMode(it)
185
        )
186
    }
187
188
    private val alpha = curve(
189
        "Alpha",
190
        mutableListOf(Vector2f(0f, 1f), Vector2f(200f, 1f)),
191
        xAxis = "Distance" axis 0f..200f,
192
        yAxis = "Alpha" axis 0f..1f,
193
    )
194
195
    override fun onEnabled() {
196
        RenderedEntities.subscribe(this)
197
        super.onEnabled()
198
    }
199
200
    override fun onDisabled() {
201
        RenderedEntities.unsubscribe(this)
202
        super.onDisabled()
203
    }
204
205
    @Suppress("unused")
206
    private val renderHandler = handler<OverlayRenderEvent> {
207
        with(it.context) {
208
            pose().withPush {
209
                val (width, height) = mc.window.scaledDimension
210
                translate(width * 0.5f, height * 0.5f)
211
212
                val yawRad = player.getYRot(it.tickDelta).toRadians()
213
                val playerPos = player.interpolateCurrentPosition(it.tickDelta)
214
215
                tiltModes.activeMode.transform(this, it.tickDelta)
216
217
                if (mc.options.cameraType == CameraType.THIRD_PERSON_FRONT) {
218
                    scale(-1f, 1f)
219
                }
220
221
                rotate(-yawRad)
222
223
                for (entity in RenderedEntities) {
224
                    if (entity === player || (onlyPlayers && entity !is Player)) continue
225
                    val entityPos = entity.interpolateCurrentPosition(it.tickDelta)
226
227
                    val cameraDistance = entityPos.cameraDistance().toFloat()
228
                    val alpha = (alpha.transform(cameraDistance) * 255).floorToInt()
229
                    if (alpha == 0) continue
230
231
                    val color = colorModes.activeMode.getColor(entity).alpha(alpha)
232
233
                    val diffX = entityPos.x - playerPos.x
234
                    val diffZ = entityPos.z - playerPos.z
235
236
                    withPush {
237
                        rotate(atan2(diffZ, diffX).toFloat() + Mth.HALF_PI)
238
                        translate(0f, radius)
239
                        with(this@with) {
240
                            pointerModes.activeMode.draw(color = color)
241
                        }
242
                    }
243
                }
244
            }
245
        }
246
    }
247
248
}
249