BuildRandom module

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

1 implementationWORLD

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.

OfflineClientWORLDsrc/main/java/com/jellypudding/offlineclient/modules/world/BuildRandom.javaJava · 128 lines · 5.3 KB

Places your held block at random spots around you.

SettingsRangeAttemptsCheck held itemLine of sightFast placeWhilst breakingWhilst ridingIndicator
BuildRandom.javaJava · Minecraft 26.2 · 128 lines · 5.3 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.world;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.Render3DEvent;
5
import com.jellypudding.offlineclient.event.events.TickEvent;
6
import com.jellypudding.offlineclient.module.Category;
7
import com.jellypudding.offlineclient.module.Module;
8
import com.jellypudding.offlineclient.render.BoxStyle;
9
import com.jellypudding.offlineclient.setting.BoolSetting;
10
import com.jellypudding.offlineclient.setting.EnumSetting;
11
import com.jellypudding.offlineclient.setting.NumberSetting;
12
import com.jellypudding.offlineclient.util.BlockUtil;
13
import com.jellypudding.offlineclient.util.FaceMode;
14
import com.jellypudding.offlineclient.util.RotationPriority;
15
import com.jellypudding.offlineclient.util.SwingMode;
16
import net.minecraft.core.BlockPos;
17
import net.minecraft.core.Direction;
18
import net.minecraft.world.InteractionHand;
19
import net.minecraft.world.item.BlockItem;
20
import net.minecraft.world.phys.Vec3;
21
22
import java.util.concurrent.ThreadLocalRandom;
23
24
// Scatters whatever you hold over the ground around you. Fire and lava and spawn
25
// eggs work as well as blocks once the held item check is off.
26
public final class BuildRandom extends Module {
27
28
    // The vanilla wait between two placements.
29
    private static final int PLACE_DELAY = 4;
30
31
    private final NumberSetting range = new NumberSetting("Range",
32
        "How far from your eyes a block may go.", 5, 1, 6, 0.05).min(1).max(6);
33
    private final NumberSetting attempts = new NumberSetting("Attempts",
34
        "Random spots tried each tick before giving up. More builds faster and lags more.",
35
        128, 1, 1024, 1).min(1);
36
    private final BoolSetting checkItem = new BoolSetting("Check held item",
37
        "Only places whilst you hold a block.", true);
38
    private final BoolSetting lineOfSight = new BoolSetting("Line of sight",
39
        "Never places behind a wall.", false);
40
    private final EnumSetting<FaceMode> faceTarget = FaceMode.setting(FaceMode.SERVER);
41
    private final EnumSetting<SwingMode> swing = SwingMode.setting(SwingMode.PACKET);
42
    private final BoolSetting fastPlace = new BoolSetting("Fast place",
43
        "Ignores the vanilla wait between placements.", false);
44
    private final BoolSetting whilstBreaking = new BoolSetting("Whilst breaking",
45
        "Keeps placing whilst you mine a block. Impossible by hand and easy to spot.", false);
46
    private final BoolSetting whilstRiding = new BoolSetting("Whilst riding",
47
        "Keeps placing whilst you ride something. Impossible by hand and easy to spot.", false);
48
    private final BoolSetting indicator = new BoolSetting("Indicator",
49
        "Draws a box where the last block was placed.", true);
50
    private final BoxStyle indicatorStyle = new BoxStyle(BoxStyle.Shape.BOTH, 110);
51
52
    private BlockPos lastPlaced;
53
54
    public BuildRandom() {
55
        super("BuildRandom", "Places your held block at random spots around you.", Category.WORLD);
56
        addSettings(range, attempts, checkItem, lineOfSight, faceTarget, swing, fastPlace,
57
            whilstBreaking, whilstRiding, indicator);
58
        addSettings(indicatorStyle.settings());
59
        searchTags("random build", "place random", "scatter");
60
    }
61
62
    @Override
63
    protected void onDisable() {
64
        lastPlaced = null;
65
    }
66
67
    @Subscribe
68
    private void onTick(TickEvent event) {
69
        lastPlaced = null;
70
        if (!inGame() || (!fastPlace.isOn() && mc.rightClickDelay > 0)) {
71
            return;
72
        }
73
        if (checkItem.isOn() && !(mc.player.getMainHandItem().getItem() instanceof BlockItem)) {
74
            return;
75
        }
76
        if (!whilstBreaking.isOn() && mc.gameMode.isDestroying()) {
77
            return;
78
        }
79
        if (!whilstRiding.isOn() && mc.player.isPassenger()) {
80
            return;
81
        }
82
        BlockPos eyes = BlockPos.containing(mc.player.getEyePosition());
83
        int reach = (int) Math.ceil(range.getValue());
84
        int span = reach * 2 + 1;
85
        ThreadLocalRandom random = ThreadLocalRandom.current();
86
        for (int i = 0; i < attempts.getInt(); i++) {
87
            BlockPos pos = eyes.offset(random.nextInt(span) - reach, random.nextInt(span) - reach,
88
                random.nextInt(span) - reach);
89
            if (tryPlace(pos)) {
90
                return;
91
            }
92
        }
93
    }
94
95
    private boolean tryPlace(BlockPos pos) {
96
        if (!BlockUtil.isReplaceable(pos)) {
97
            return false;
98
        }
99
        Direction support = BlockUtil.findPlaceSupport(pos);
100
        if (support == null) {
101
            return false;
102
        }
103
        Vec3 hit = BlockUtil.hitPoint(pos.relative(support), support.getOpposite());
104
        double limit = range.getValue() * range.getValue();
105
        if (mc.player.getEyePosition().distanceToSqr(hit) > limit) {
106
            return false;
107
        }
108
        if (lineOfSight.isOn() && !BlockUtil.canSee(hit)) {
109
            return false;
110
        }
111
        faceTarget.getValue().face(hit, RotationPriority.PLACE);
112
        if (!BlockUtil.place(pos, support, false, false)) {
113
            return false;
114
        }
115
        swing.getValue().swing(InteractionHand.MAIN_HAND);
116
        mc.rightClickDelay = PLACE_DELAY;
117
        lastPlaced = pos;
118
        return true;
119
    }
120
121
    @Subscribe
122
    private void onRender3D(Render3DEvent event) {
123
        if (lastPlaced != null && indicator.isOn()) {
124
            indicatorStyle.draw(event.getBatch(), lastPlaced, false);
125
        }
126
    }
127
}
128