WallHack module

WallHack: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

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.

OfflineClientRENDERsrc/main/java/com/jellypudding/offlineclient/modules/render/WallHack.javaJava · 101 lines · 3.5 KB

Makes the blocks you choose see through.

SettingsBlocksOpacitySkip hidden chunks
WallHack.javaJava · Minecraft 26.2 · 101 lines · 3.5 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.TickEvent;
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.NumberSetting;
9
import com.jellypudding.offlineclient.setting.RegistryListSetting;
10
import com.jellypudding.offlineclient.util.ChunkRebuild;
11
import net.minecraft.core.registries.BuiltInRegistries;
12
import net.minecraft.world.level.block.Block;
13
import net.minecraft.world.level.block.Blocks;
14
15
import java.util.HashSet;
16
import java.util.List;
17
import java.util.Set;
18
19
// The mirror of XRay. The listed blocks go see through and the rest stay solid.
20
// XRay owns the meshing path and asks this module what the chosen blocks need.
21
public final class WallHack extends Module {
22
23
    // The chunk mesher reads this once per block.
24
    private static volatile WallHack instance;
25
26
    private final RegistryListSetting<Block> blocks = new RegistryListSetting<>("Blocks",
27
        "The blocks that go see through.", BuiltInRegistries.BLOCK,
28
        List.of(Blocks.STONE, Blocks.DEEPSLATE, Blocks.TUFF, Blocks.ANDESITE,
29
            Blocks.DIORITE, Blocks.GRANITE, Blocks.DIRT, Blocks.GRASS_BLOCK,
30
            Blocks.NETHERRACK, Blocks.END_STONE));
31
    private final NumberSetting opacity = new NumberSetting("Opacity",
32
        "How visible the listed blocks stay.", 0, 0, 100, 5, "%").max(100);
33
    private final BoolSetting skipHidden = new BoolSetting("Skip hidden chunks",
34
        "Let the game leave out chunks it thinks are out of sight.", false);
35
36
    // Read from worker threads and replaced whole.
37
    private volatile Set<Block> seeThrough = Set.of();
38
    private volatile int alpha;
39
    private final ChunkRebuild rebuild = new ChunkRebuild();
40
41
    public WallHack() {
42
        super("WallHack", "Makes the blocks you choose see through.", Category.RENDER);
43
        addSettings(blocks, opacity, skipHidden);
44
        searchTags("xray", "see through", "walls");
45
        instance = this;
46
    }
47
48
    // Null before the client has started.
49
    public static WallHack get() {
50
        return instance;
51
    }
52
53
    @Override
54
    public String getSuffix() {
55
        return count(blocks.size());
56
    }
57
58
    @Override
59
    protected void onEnable() {
60
        snapshot();
61
        ChunkRebuild.now();
62
    }
63
64
    @Override
65
    protected void onDisable() {
66
        ChunkRebuild.now();
67
    }
68
69
    @Subscribe
70
    private void onTick(TickEvent event) {
71
        rebuild.tick(snapshot());
72
    }
73
74
    // True if anything changed.
75
    private boolean snapshot() {
76
        Set<Block> next = new HashSet<>(blocks.resolved());
77
        int nextAlpha = (int) Math.round(opacity.getValue() / 100.0 * 255.0);
78
        boolean changed = !next.equals(seeThrough) || nextAlpha != alpha;
79
        if (changed) {
80
            seeThrough = Set.copyOf(next);
81
            alpha = nextAlpha;
82
        }
83
        return changed;
84
    }
85
86
    // Vanilla skips chunk sections that are boxed in by solid ground.
87
    public boolean showsHiddenChunks() {
88
        return isEnabled() && !skipHidden.isOn();
89
    }
90
91
    // Minus one leaves the block alone and zero skips it. Anything else is the
92
    // alpha for a see through version.
93
    public int alphaFor(Block block) {
94
        if (!isEnabled() || !seeThrough.contains(block)) {
95
            return -1;
96
        }
97
        int a = alpha;
98
        return a >= 255 ? -1 : a;
99
    }
100
}
101