liquid-filler module

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

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.

Meteor ClientWorldsrc/main/java/meteordevelopment/meteorclient/systems/modules/world/LiquidFiller.javaJava · 254 lines · 8.9 KB

Places blocks inside of liquid source blocks within range of you.

Settingsplace-inshapeplace-rangewalls-rangedelaymax-blocks-per-ticksort-moderotatelist-modewhitelistblacklist
LiquidFiller.javaJava · Minecraft 26.2 · 254 lines · 8.9 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.world;
7
8
import meteordevelopment.meteorclient.events.world.TickEvent;
9
import meteordevelopment.meteorclient.settings.*;
10
import meteordevelopment.meteorclient.systems.modules.Categories;
11
import meteordevelopment.meteorclient.systems.modules.Module;
12
import meteordevelopment.meteorclient.utils.Utils;
13
import meteordevelopment.meteorclient.utils.misc.ListMode;
14
import meteordevelopment.meteorclient.utils.player.FindItemResult;
15
import meteordevelopment.meteorclient.utils.player.InvUtils;
16
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
17
import meteordevelopment.meteorclient.utils.world.BlockIterator;
18
import meteordevelopment.meteorclient.utils.world.BlockUtils;
19
import meteordevelopment.orbit.EventHandler;
20
import net.minecraft.core.BlockPos;
21
import net.minecraft.world.item.BlockItem;
22
import net.minecraft.world.level.ClipContext;
23
import net.minecraft.world.level.block.Block;
24
import net.minecraft.world.level.block.Blocks;
25
import net.minecraft.world.level.material.Fluid;
26
import net.minecraft.world.level.material.Fluids;
27
import net.minecraft.world.phys.BlockHitResult;
28
import net.minecraft.world.phys.Vec3;
29
30
import java.util.ArrayList;
31
import java.util.Comparator;
32
import java.util.List;
33
34
public class LiquidFiller extends Module {
35
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
36
    private final SettingGroup sgWhitelist = settings.createGroup("Whitelist");
37
38
    private final Setting<PlaceIn> placeInLiquids = sgGeneral.add(new EnumSetting.Builder<PlaceIn>()
39
        .name("place-in")
40
        .description("What type of liquids to place in.")
41
        .defaultValue(PlaceIn.Both)
42
        .build()
43
    );
44
45
    private final Setting<Shape> shape = sgGeneral.add(new EnumSetting.Builder<Shape>()
46
        .name("shape")
47
        .description("The shape of placing algorithm.")
48
        .defaultValue(Shape.Sphere)
49
        .build()
50
    );
51
52
    private final Setting<Double> placeRange = sgGeneral.add(new DoubleSetting.Builder()
53
        .name("place-range")
54
        .description("The range at which blocks can be placed.")
55
        .defaultValue(4.5)
56
        .min(0)
57
        .sliderMax(6)
58
        .build()
59
    );
60
61
    private final Setting<Double> placeWallsRange = sgGeneral.add(new DoubleSetting.Builder()
62
        .name("walls-range")
63
        .description("Range in which to place when behind blocks.")
64
        .defaultValue(4.5)
65
        .min(0)
66
        .sliderMax(6)
67
        .build()
68
    );
69
70
    private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
71
        .name("delay")
72
        .description("Delay between actions in ticks.")
73
        .defaultValue(0)
74
        .min(0)
75
        .build()
76
    );
77
78
    private final Setting<Integer> maxBlocksPerTick = sgGeneral.add(new IntSetting.Builder()
79
        .name("max-blocks-per-tick")
80
        .description("Maximum blocks to try to place per tick.")
81
        .defaultValue(1)
82
        .min(1)
83
        .sliderRange(1, 10)
84
        .build()
85
    );
86
87
    private final Setting<SortMode> sortMode = sgGeneral.add(new EnumSetting.Builder<SortMode>()
88
        .name("sort-mode")
89
        .description("The blocks you want to place first.")
90
        .defaultValue(SortMode.Furthest)
91
        .build()
92
    );
93
94
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
95
        .name("rotate")
96
        .description("Automatically rotates towards the space targeted for filling.")
97
        .defaultValue(true)
98
        .build()
99
    );
100
101
    // Whitelist and blacklist
102
103
    private final Setting<ListMode> listMode = sgWhitelist.add(new EnumSetting.Builder<ListMode>()
104
        .name("list-mode")
105
        .description("Selection mode.")
106
        .defaultValue(ListMode.Whitelist)
107
        .build()
108
    );
109
110
    private final Setting<List<Block>> whitelist = sgWhitelist.add(new BlockListSetting.Builder()
111
        .name("whitelist")
112
        .description("The allowed blocks that it will use to fill up the liquid.")
113
        .defaultValue(
114
            Blocks.DIRT,
115
            Blocks.COBBLESTONE,
116
            Blocks.STONE,
117
            Blocks.NETHERRACK,
118
            Blocks.DIORITE,
119
            Blocks.GRANITE,
120
            Blocks.ANDESITE
121
        )
122
        .visible(() -> listMode.get() == ListMode.Whitelist)
123
        .build()
124
    );
125
126
    private final Setting<List<Block>> blacklist = sgWhitelist.add(new BlockListSetting.Builder()
127
        .name("blacklist")
128
        .description("The denied blocks that it not will use to fill up the liquid.")
129
        .visible(() -> listMode.get() == ListMode.Blacklist)
130
        .build()
131
    );
132
133
    private final List<BlockPos.MutableBlockPos> blocks = new ArrayList<>();
134
135
    private int timer;
136
137
    public LiquidFiller() {
138
        super(Categories.World, "liquid-filler", "Places blocks inside of liquid source blocks within range of you.");
139
    }
140
141
    @Override
142
    public void onActivate() {
143
        timer = 0;
144
    }
145
146
    @EventHandler
147
    private void onTick(TickEvent.Pre event) {
148
        // Update timer according to delay
149
        if (timer < delay.get()) {
150
            timer++;
151
            return;
152
        } else {
153
            timer = 0;
154
        }
155
156
        // Calculate some stuff
157
        double pX = mc.player.getX();
158
        double pY = mc.player.getY();
159
        double pZ = mc.player.getZ();
160
161
        // Find slot with a block
162
        FindItemResult item;
163
        item = InvUtils.findInHotbar(itemStack -> {
164
            if (!(itemStack.getItem() instanceof BlockItem)) return false;
165
166
            boolean itemInList = (listMode.get() == ListMode.Whitelist ? whitelist.get() : blacklist.get()).contains(Block.byItem(itemStack.getItem()));
167
            return listMode.get().allows(itemInList);
168
        });
169
        if (!item.found()) return;
170
171
        // Loop blocks around the player
172
        BlockIterator.register((int) Math.ceil(placeRange.get() + 1), (int) Math.ceil(placeRange.get()), (blockPos, blockState) -> {
173
174
            // Check raycast and range
175
            if (isOutOfRange(blockPos)) return;
176
177
            // Check if the block is a source block and set to be filled
178
            Fluid fluid = blockState.getFluidState().getType();
179
            if ((placeInLiquids.get() == PlaceIn.Both && (fluid != Fluids.WATER && fluid != Fluids.LAVA))
180
                || (placeInLiquids.get() == PlaceIn.Water && fluid != Fluids.WATER)
181
                || (placeInLiquids.get() == PlaceIn.Lava && fluid != Fluids.LAVA))
182
                return;
183
184
            // Check if the player can place at pos
185
            if (!BlockUtils.canPlace(blockPos)) return;
186
187
            // Add block
188
            blocks.add(blockPos.mutable());
189
        });
190
191
        BlockIterator.after(() -> {
192
            // Sort blocks
193
            if (sortMode.get() == SortMode.TopDown || sortMode.get() == SortMode.BottomUp)
194
                blocks.sort(Comparator.comparingDouble(value -> value.getY() * (sortMode.get() == SortMode.BottomUp ? 1 : -1)));
195
            else if (sortMode.get() != SortMode.None)
196
                blocks.sort(Comparator.comparingDouble(value -> Utils.squaredDistance(pX, pY, pZ, value.getX() + 0.5, value.getY() + 0.5, value.getZ() + 0.5) * (sortMode.get() == SortMode.Closest ? 1 : -1)));
197
198
            // Place and clear place positions
199
            int count = 0;
200
            for (BlockPos pos : blocks) {
201
                if (count >= maxBlocksPerTick.get()) break;
202
                BlockUtils.place(pos, item, rotate.get(), 0, true);
203
                count++;
204
            }
205
            blocks.clear();
206
        });
207
    }
208
209
    public enum PlaceIn {
210
        Both,
211
        Water,
212
        Lava
213
    }
214
215
    public enum SortMode {
216
        None,
217
        Closest,
218
        Furthest,
219
        TopDown,
220
        BottomUp
221
    }
222
223
    public enum Shape {
224
        Sphere,
225
        UniformCube
226
    }
227
228
    private boolean isOutOfRange(BlockPos blockPos) {
229
        if (!isWithinShape(blockPos, placeRange.get())) return true;
230
231
        ClipContext clipContext = new ClipContext(mc.player.getEyePosition(), Vec3.atCenterOf(blockPos), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mc.player);
232
        BlockHitResult result = mc.level.clip(clipContext);
233
        if (result == null || !result.getBlockPos().equals(blockPos))
234
            return !isWithinShape(blockPos, placeWallsRange.get());
235
236
        return false;
237
    }
238
239
    private boolean isWithinShape(BlockPos blockPos, double range) {
240
        // Cube shape
241
        if (shape.get() == Shape.UniformCube) {
242
            BlockPos playerBlockPos = mc.player.blockPosition();
243
            double dX = Math.abs(blockPos.getX() - playerBlockPos.getX());
244
            double dY = Math.abs(blockPos.getY() - playerBlockPos.getY());
245
            double dZ = Math.abs(blockPos.getZ() - playerBlockPos.getZ());
246
            double maxDist = Math.max(Math.max(dX, dY), dZ);
247
            return maxDist <= Math.floor(range);
248
        }
249
250
        // Spherical shape
251
        return PlayerUtils.isWithin(Vec3.atCenterOf(blockPos), range);
252
    }
253
}
254