storage-esp module

storage-esp: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationRender

Clients with this module

Full module source: 1 implementation

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

Meteor ClientRendersrc/main/java/meteordevelopment/meteorclient/systems/modules/render/StorageESP.javaJava · 365 lines · 14.1 KB

Renders all specified storage blocks.

Settingsmodestorage-blockstracersshape-modefill-opacitywidthglow-multiplierchesttrapped-chestbarrelshulkerender-chestotherfade-distancehide-openedopened-color
StorageESP.javaJava · Minecraft 26.2 · 365 lines · 14.1 KB · 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.render;
7
8
import meteordevelopment.meteorclient.events.entity.player.InteractBlockEvent;
9
import meteordevelopment.meteorclient.events.render.Render3DEvent;
10
import meteordevelopment.meteorclient.gui.GuiTheme;
11
import meteordevelopment.meteorclient.gui.widgets.WWidget;
12
import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList;
13
import meteordevelopment.meteorclient.gui.widgets.pressable.WButton;
14
import meteordevelopment.meteorclient.renderer.MeshBuilder;
15
import meteordevelopment.meteorclient.renderer.MeshRenderer;
16
import meteordevelopment.meteorclient.renderer.MeteorRenderPipelines;
17
import meteordevelopment.meteorclient.renderer.ShapeMode;
18
import meteordevelopment.meteorclient.settings.*;
19
import meteordevelopment.meteorclient.systems.modules.Categories;
20
import meteordevelopment.meteorclient.systems.modules.Module;
21
import meteordevelopment.meteorclient.utils.Utils;
22
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
23
import meteordevelopment.meteorclient.utils.render.MeshBuilderVertexConsumerProvider;
24
import meteordevelopment.meteorclient.utils.render.RenderUtils;
25
import meteordevelopment.meteorclient.utils.render.SimpleBlockRenderer;
26
import meteordevelopment.meteorclient.utils.render.color.Color;
27
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
28
import meteordevelopment.meteorclient.utils.render.postprocess.PostProcessShaders;
29
import meteordevelopment.meteorclient.utils.world.Dir;
30
import meteordevelopment.orbit.EventHandler;
31
import net.minecraft.core.BlockPos;
32
import net.minecraft.core.Direction;
33
import net.minecraft.world.level.block.Blocks;
34
import net.minecraft.world.level.block.ChestBlock;
35
import net.minecraft.world.level.block.entity.*;
36
import net.minecraft.world.level.block.state.BlockState;
37
import net.minecraft.world.level.block.state.properties.ChestType;
38
39
import java.util.HashSet;
40
import java.util.List;
41
import java.util.Set;
42
43
public class StorageESP extends Module {
44
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
45
    private final SettingGroup sgOpened = settings.createGroup("Opened Rendering");
46
    private final Set<BlockPos> interactedBlocks = new HashSet<>();
47
48
    private final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
49
        .name("mode")
50
        .description("Rendering mode.")
51
        .defaultValue(Mode.Shader)
52
        .build()
53
    );
54
55
    private final Setting<List<BlockEntityType<?>>> storageBlocks = sgGeneral.add(new StorageBlockListSetting.Builder()
56
        .name("storage-blocks")
57
        .description("Select the storage blocks to display.")
58
        .defaultValue(StorageBlockListSetting.STORAGE_BLOCKS)
59
        .build()
60
    );
61
62
    private final Setting<Boolean> tracers = sgGeneral.add(new BoolSetting.Builder()
63
        .name("tracers")
64
        .description("Draws tracers to storage blocks.")
65
        .defaultValue(false)
66
        .build()
67
    );
68
69
    public final Setting<ShapeMode> shapeMode = sgGeneral.add(new EnumSetting.Builder<ShapeMode>()
70
        .name("shape-mode")
71
        .description("How the shapes are rendered.")
72
        .defaultValue(ShapeMode.Both)
73
        .build()
74
    );
75
76
    public final Setting<Integer> fillOpacity = sgGeneral.add(new IntSetting.Builder()
77
        .name("fill-opacity")
78
        .description("The opacity of the shape fill.")
79
        .visible(() -> shapeMode.get() != ShapeMode.Lines)
80
        .defaultValue(50)
81
        .range(0, 255)
82
        .sliderMax(255)
83
        .build()
84
    );
85
86
    public final Setting<Integer> outlineWidth = sgGeneral.add(new IntSetting.Builder()
87
        .name("width")
88
        .description("The width of the shader outline.")
89
        .visible(() -> mode.get() == Mode.Shader)
90
        .defaultValue(1)
91
        .range(1, 10)
92
        .sliderRange(1, 5)
93
        .build()
94
    );
95
96
    public final Setting<Double> glowMultiplier = sgGeneral.add(new DoubleSetting.Builder()
97
        .name("glow-multiplier")
98
        .description("Multiplier for glow effect")
99
        .visible(() -> mode.get() == Mode.Shader)
100
        .decimalPlaces(3)
101
        .defaultValue(3.5)
102
        .min(0)
103
        .sliderMax(10)
104
        .build()
105
    );
106
107
    private final Setting<SettingColor> chest = sgGeneral.add(new ColorSetting.Builder()
108
        .name("chest")
109
        .description("The color of chests.")
110
        .defaultValue(new SettingColor(255, 160, 0, 255))
111
        .build()
112
    );
113
114
    private final Setting<SettingColor> trappedChest = sgGeneral.add(new ColorSetting.Builder()
115
        .name("trapped-chest")
116
        .description("The color of trapped chests.")
117
        .defaultValue(new SettingColor(255, 0, 0, 255))
118
        .build()
119
    );
120
121
    private final Setting<SettingColor> barrel = sgGeneral.add(new ColorSetting.Builder()
122
        .name("barrel")
123
        .description("The color of barrels.")
124
        .defaultValue(new SettingColor(255, 160, 0, 255))
125
        .build()
126
    );
127
128
    private final Setting<SettingColor> shulker = sgGeneral.add(new ColorSetting.Builder()
129
        .name("shulker")
130
        .description("The color of Shulker Boxes.")
131
        .defaultValue(new SettingColor(255, 160, 0, 255))
132
        .build()
133
    );
134
135
    private final Setting<SettingColor> enderChest = sgGeneral.add(new ColorSetting.Builder()
136
        .name("ender-chest")
137
        .description("The color of Ender Chests.")
138
        .defaultValue(new SettingColor(120, 0, 255, 255))
139
        .build()
140
    );
141
142
    private final Setting<SettingColor> other = sgGeneral.add(new ColorSetting.Builder()
143
        .name("other")
144
        .description("The color of furnaces, dispensers, droppers and hoppers.")
145
        .defaultValue(new SettingColor(140, 140, 140, 255))
146
        .build()
147
    );
148
149
    private final Setting<Double> fadeDistance = sgGeneral.add(new DoubleSetting.Builder()
150
        .name("fade-distance")
151
        .description("The distance at which the color will fade.")
152
        .defaultValue(6)
153
        .min(0)
154
        .sliderMax(12)
155
        .build()
156
    );
157
158
    private final Setting<Boolean> hideOpened = sgOpened.add(new BoolSetting.Builder()
159
        .name("hide-opened")
160
        .description("Hides opened containers.")
161
        .defaultValue(false)
162
        .build()
163
    );
164
165
    private final Setting<SettingColor> openedColor = sgOpened.add(new ColorSetting.Builder()
166
        .name("opened-color")
167
        .description("Optional setting to change colors of opened chests, as opposed to not rendering. Disabled at zero opacity.")
168
        .defaultValue(new SettingColor(203, 90, 203, 0)) // TRANSPARENT BY DEFAULT.
169
        .build()
170
    );
171
172
173
    private final Color lineColor = new Color(0, 0, 0, 0);
174
    private final Color sideColor = new Color(0, 0, 0, 0);
175
    private boolean render;
176
    private int count;
177
178
    private final MeshBuilder mesh;
179
    private final MeshBuilderVertexConsumerProvider vertexConsumerProvider;
180
181
    public StorageESP() {
182
        super(Categories.Render, "storage-esp", "Renders all specified storage blocks.");
183
184
        mesh = new MeshBuilder(MeteorRenderPipelines.WORLD_COLORED);
185
        vertexConsumerProvider = new MeshBuilderVertexConsumerProvider(mesh);
186
    }
187
188
    private void getBlockEntityColor(BlockEntity blockEntity) {
189
        render = false;
190
191
        if (!storageBlocks.get().contains(blockEntity.getType())) return;
192
193
        if (blockEntity instanceof TrappedChestBlockEntity)
194
            lineColor.set(trappedChest.get()); // Must come before ChestBlockEntity as it is the superclass of TrappedChestBlockEntity
195
        else if (blockEntity instanceof ChestBlockEntity) lineColor.set(chest.get());
196
        else if (blockEntity instanceof BarrelBlockEntity) lineColor.set(barrel.get());
197
        else if (blockEntity instanceof ShulkerBoxBlockEntity) lineColor.set(shulker.get());
198
        else if (blockEntity instanceof EnderChestBlockEntity) lineColor.set(enderChest.get());
199
        else if (blockEntity instanceof AbstractFurnaceBlockEntity || blockEntity instanceof BrewingStandBlockEntity || blockEntity instanceof ChiseledBookShelfBlockEntity || blockEntity instanceof CrafterBlockEntity || blockEntity instanceof DispenserBlockEntity || blockEntity instanceof DecoratedPotBlockEntity || blockEntity instanceof HopperBlockEntity)
200
            lineColor.set(other.get());
201
        else return;
202
203
        render = true;
204
205
        if (shapeMode.get() == ShapeMode.Sides || shapeMode.get() == ShapeMode.Both) {
206
            sideColor.set(lineColor);
207
            sideColor.a = fillOpacity.get();
208
        }
209
    }
210
211
    @Override
212
    public WWidget getWidget(GuiTheme theme) {
213
        WVerticalList list = theme.verticalList();
214
215
        // Button to Clear Interacted Blocks
216
        WButton clear = list.add(theme.button("Clear Rendering Cache")).expandX().widget();
217
218
        clear.action = interactedBlocks::clear;
219
220
        return list;
221
    }
222
223
    @EventHandler
224
    private void onBlockInteract(InteractBlockEvent event) {
225
        BlockPos pos = event.result.getBlockPos();
226
        BlockEntity blockEntity = mc.level.getBlockEntity(pos);
227
228
        if (blockEntity == null) return;
229
230
        interactedBlocks.add(pos);
231
        if (blockEntity instanceof ChestBlockEntity chestBlockEntity) {
232
            BlockState state = chestBlockEntity.getBlockState();
233
            ChestType chestType = state.getValue(ChestBlock.TYPE);
234
235
            if (chestType == ChestType.LEFT || chestType == ChestType.RIGHT) {
236
                // It's part of a double chest
237
                Direction facing = state.getValue(ChestBlock.FACING);
238
                BlockPos otherPartPos = pos.relative(chestType == ChestType.LEFT ? facing.getClockWise() : facing.getCounterClockWise());
239
240
                interactedBlocks.add(otherPartPos);
241
            }
242
        }
243
    }
244
245
    @EventHandler
246
    private void onRender(Render3DEvent event) {
247
        count = 0;
248
249
        for (BlockEntity blockEntity : Utils.blockEntities()) {
250
            // Check if the block has been interacted with (opened)
251
            boolean interacted = interactedBlocks.contains(blockEntity.getBlockPos());
252
            if (interacted && hideOpened.get()) continue;  // Skip rendering if "hideOpened" is true
253
254
            getBlockEntityColor(blockEntity);
255
256
            // Set the color to openedColor if its alpha is greater than 0
257
            if (interacted && openedColor.get().a > 0) {
258
                // openedColor takes precedence.
259
                lineColor.set(openedColor.get());
260
                sideColor.set(openedColor.get());
261
                sideColor.a = fillOpacity.get(); // Maintain fill opacity setting for consistency
262
            }
263
264
            if (render) {
265
                double dist = PlayerUtils.squaredDistanceTo(blockEntity.getBlockPos().getX() + 0.5, blockEntity.getBlockPos().getY() + 0.5, blockEntity.getBlockPos().getZ() + 0.5);
266
                double a = 1;
267
                if (dist <= fadeDistance.get() * fadeDistance.get())
268
                    a = dist / (fadeDistance.get() * fadeDistance.get());
269
270
                if (a < 0.075) continue;
271
272
                // Only start a mesh when there's something to render
273
                if (count == 0 && mode.get() == Mode.Shader) {
274
                    mesh.begin();
275
                }
276
277
                int prevLineA = lineColor.a;
278
                int prevSideA = sideColor.a;
279
280
                lineColor.a *= a;
281
                sideColor.a *= a;
282
283
                if (tracers.get()) {
284
                    event.renderer.line(RenderUtils.center.x, RenderUtils.center.y, RenderUtils.center.z, blockEntity.getBlockPos().getX() + 0.5, blockEntity.getBlockPos().getY() + 0.5, blockEntity.getBlockPos().getZ() + 0.5, lineColor);
285
                }
286
287
                if (mode.get() == Mode.Box) {
288
                    renderBox(event, blockEntity);
289
                }
290
291
                if (mode.get() == Mode.Shader) {
292
                    renderShader(event, blockEntity);
293
                }
294
295
                lineColor.a = prevLineA;
296
                sideColor.a = prevSideA;
297
298
                count++;
299
            }
300
        }
301
302
        if (mode.get() == Mode.Shader && count > 0) {
303
            MeshRenderer.begin()
304
                .attachments(PostProcessShaders.STORAGE_OUTLINE.framebuffer)
305
                .clearColor(Color.CLEAR)
306
                .pipeline(MeteorRenderPipelines.WORLD_COLORED)
307
                .mesh(mesh, event.matrices)
308
                .end();
309
310
            PostProcessShaders.STORAGE_OUTLINE.render();
311
        }
312
    }
313
314
315
    private void renderBox(Render3DEvent event, BlockEntity blockEntity) {
316
        double x1 = blockEntity.getBlockPos().getX();
317
        double y1 = blockEntity.getBlockPos().getY();
318
        double z1 = blockEntity.getBlockPos().getZ();
319
320
        double x2 = blockEntity.getBlockPos().getX() + 1;
321
        double y2 = blockEntity.getBlockPos().getY() + 1;
322
        double z2 = blockEntity.getBlockPos().getZ() + 1;
323
324
        int excludeDir = 0;
325
        if (blockEntity instanceof ChestBlockEntity) {
326
            BlockState state = mc.level.getBlockState(blockEntity.getBlockPos());
327
            if ((state.getBlock() == Blocks.CHEST || state.getBlock() == Blocks.TRAPPED_CHEST) && state.getValue(ChestBlock.TYPE) != ChestType.SINGLE) {
328
                excludeDir = Dir.get(ChestBlock.getConnectedDirection(state));
329
            }
330
        }
331
332
        if (blockEntity instanceof ChestBlockEntity || blockEntity instanceof EnderChestBlockEntity) {
333
            double a = 1.0 / 16.0;
334
335
            if (Dir.isNot(excludeDir, Dir.WEST)) x1 += a;
336
            if (Dir.isNot(excludeDir, Dir.NORTH)) z1 += a;
337
338
            if (Dir.isNot(excludeDir, Dir.EAST)) x2 -= a;
339
            y2 -= a * 2;
340
            if (Dir.isNot(excludeDir, Dir.SOUTH)) z2 -= a;
341
        }
342
343
        event.renderer.box(x1, y1, z1, x2, y2, z2, sideColor, lineColor, shapeMode.get(), excludeDir);
344
    }
345
346
    private void renderShader(Render3DEvent event, BlockEntity blockEntity) {
347
        vertexConsumerProvider.setColor(lineColor);
348
        SimpleBlockRenderer.renderWithBlockEntity(blockEntity, event.tickDelta, vertexConsumerProvider);
349
    }
350
351
    @Override
352
    public String getInfoString() {
353
        return Integer.toString(count);
354
    }
355
356
    public boolean isShader() {
357
        return isActive() && mode.get() == Mode.Shader;
358
    }
359
360
    public enum Mode {
361
        Box,
362
        Shader
363
    }
364
}
365