block-selection module

block-selection: 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/BlockSelection.javaJava · 122 lines · 5.2 KB

Modifies how your block selection is rendered.

Settingsadvancedsingle-sideshape-modeside-colorline-colorhide-when-inside-block
BlockSelection.javaJava · Minecraft 26.2 · 122 lines · 5.2 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.render.Render3DEvent;
9
import meteordevelopment.meteorclient.renderer.ShapeMode;
10
import meteordevelopment.meteorclient.settings.*;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
14
import meteordevelopment.orbit.EventHandler;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.core.Direction;
17
import net.minecraft.world.phys.AABB;
18
import net.minecraft.world.phys.BlockHitResult;
19
import net.minecraft.world.phys.HitResult;
20
import net.minecraft.world.phys.shapes.VoxelShape;
21
22
public class BlockSelection extends Module {
23
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
24
25
    private final Setting<Boolean> advanced = sgGeneral.add(new BoolSetting.Builder()
26
        .name("advanced")
27
        .description("Shows a more advanced outline on different types of shape blocks.")
28
        .defaultValue(true)
29
        .build()
30
    );
31
32
    private final Setting<Boolean> oneSide = sgGeneral.add(new BoolSetting.Builder()
33
        .name("single-side")
34
        .description("Only renders the side you are looking at.")
35
        .defaultValue(false)
36
        .build()
37
    );
38
39
    private final Setting<ShapeMode> shapeMode = sgGeneral.add(new EnumSetting.Builder<ShapeMode>()
40
        .name("shape-mode")
41
        .description("How the shapes are rendered.")
42
        .defaultValue(ShapeMode.Both)
43
        .build()
44
    );
45
46
    private final Setting<SettingColor> sideColor = sgGeneral.add(new ColorSetting.Builder()
47
        .name("side-color")
48
        .description("The side color.")
49
        .defaultValue(new SettingColor(255, 255, 255, 50))
50
        .build()
51
    );
52
53
    private final Setting<SettingColor> lineColor = sgGeneral.add(new ColorSetting.Builder()
54
        .name("line-color")
55
        .description("The line color.")
56
        .defaultValue(new SettingColor(255, 255, 255, 255))
57
        .build()
58
    );
59
60
    private final Setting<Boolean> hideInside = sgGeneral.add(new BoolSetting.Builder()
61
        .name("hide-when-inside-block")
62
        .description("Hide selection when inside target block.")
63
        .defaultValue(true)
64
        .build()
65
    );
66
67
    public BlockSelection() {
68
        super(Categories.Render, "block-selection", "Modifies how your block selection is rendered.");
69
    }
70
71
    @EventHandler
72
    private void onRender(Render3DEvent event) {
73
        if (mc.hitResult == null || !(mc.hitResult instanceof BlockHitResult result) || result.getType() == HitResult.Type.MISS)
74
            return;
75
76
        if (hideInside.get() && result.isInside()) return;
77
78
        BlockPos bp = result.getBlockPos();
79
        Direction side = result.getDirection();
80
81
        VoxelShape shape = mc.level.getBlockState(bp).getShape(mc.level, bp);
82
83
        if (shape.isEmpty()) return;
84
        AABB box = shape.bounds();
85
86
        if (oneSide.get()) {
87
            switch (side) {
88
                case Direction.UP, Direction.DOWN ->
89
                    event.renderer.sideHorizontal(bp.getX() + box.minX, bp.getY() + (side == Direction.DOWN ? box.minY : box.maxY), bp.getZ() + box.minZ, bp.getX() + box.maxX, bp.getZ() + box.maxZ, sideColor.get(), lineColor.get(), shapeMode.get());
90
                case Direction.SOUTH, Direction.NORTH -> {
91
                    double z = side == Direction.NORTH ? box.minZ : box.maxZ;
92
                    event.renderer.sideVertical(bp.getX() + box.minX, bp.getY() + box.minY, bp.getZ() + z, bp.getX() + box.maxX, bp.getY() + box.maxY, bp.getZ() + z, sideColor.get(), lineColor.get(), shapeMode.get());
93
                }
94
                case Direction.EAST, Direction.WEST -> {
95
                    double x = side == Direction.WEST ? box.minX : box.maxX;
96
                    event.renderer.sideVertical(bp.getX() + x, bp.getY() + box.minY, bp.getZ() + box.minZ, bp.getX() + x, bp.getY() + box.maxY, bp.getZ() + box.maxZ, sideColor.get(), lineColor.get(), shapeMode.get());
97
                }
98
            }
99
        } else {
100
            if (advanced.get()) {
101
                if (shapeMode.get() == ShapeMode.Both || shapeMode.get() == ShapeMode.Lines) {
102
                    shape.forAllEdges((minX, minY, minZ, maxX, maxY, maxZ) -> {
103
                        event.renderer.line(bp.getX() + minX, bp.getY() + minY, bp.getZ() + minZ, bp.getX() + maxX, bp.getY() + maxY, bp.getZ() + maxZ, lineColor.get());
104
                    });
105
                }
106
107
                if (shapeMode.get() == ShapeMode.Both || shapeMode.get() == ShapeMode.Sides) {
108
                    for (AABB b : shape.toAabbs()) {
109
                        render(event, bp, b);
110
                    }
111
                }
112
            } else {
113
                render(event, bp, box);
114
            }
115
        }
116
    }
117
118
    private void render(Render3DEvent event, BlockPos bp, AABB box) {
119
        event.renderer.box(bp.getX() + box.minX, bp.getY() + box.minY, bp.getZ() + box.minZ, bp.getX() + box.maxX, bp.getY() + box.maxY, bp.getZ() + box.maxZ, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
120
    }
121
}
122