BonemealAura module

BonemealAura: 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/BonemealAura.javaJava · 201 lines · 7.8 KB

Feeds bone meal to the plants around you.

SettingsRangeMulti mealLine of sightRotateFast placeUse whilst breakingUse whilst ridingTake fromSaplingsCropsStemsCocoaSea picklesOther
BonemealAura.javaJava · Minecraft 26.2 · 201 lines · 7.8 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.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.EnumSetting;
9
import com.jellypudding.offlineclient.setting.NumberSetting;
10
import com.jellypudding.offlineclient.util.BlockUtil;
11
import com.jellypudding.offlineclient.util.SwingMode;
12
import com.jellypudding.offlineclient.util.InventoryUtil;
13
import net.minecraft.core.BlockPos;
14
import net.minecraft.world.InteractionHand;
15
import net.minecraft.world.item.Items;
16
import net.minecraft.world.level.block.Block;
17
import net.minecraft.world.level.block.BonemealableBlock;
18
import net.minecraft.world.level.block.CocoaBlock;
19
import net.minecraft.world.level.block.CropBlock;
20
import net.minecraft.world.level.block.GrassBlock;
21
import net.minecraft.world.level.block.SaplingBlock;
22
import net.minecraft.world.level.block.SeaPickleBlock;
23
import net.minecraft.world.level.block.StemBlock;
24
import net.minecraft.world.level.block.state.BlockState;
25
26
import java.util.ArrayList;
27
import java.util.List;
28
29
// Feeds bone meal to whatever is still growing around you.
30
public final class BonemealAura extends Module {
31
32
    public enum TakeFrom { HANDS, HOTBAR, INVENTORY }
33
34
    // Vanilla repeats a held right click at this rate.
35
    private static final int CLICK_INTERVAL = 4;
36
37
    private final NumberSetting range = new NumberSetting("Range",
38
        "How far from your eyes to reach.", 5, 1, 6, 0.1).max(6);
39
    private final BoolSetting multi = new BoolSetting("Multi meal",
40
        "Feeds every plant in reach in one tick. Fast but obvious to an anti cheat.", false);
41
    private final BoolSetting lineOfSight = new BoolSetting("Line of sight",
42
        "Only feeds plants you can see from where you stand.", true);
43
    private final EnumSetting<SwingMode> swing = SwingMode.setting(SwingMode.BOTH);
44
    private final BoolSetting rotate = new BoolSetting("Rotate",
45
        "Turn towards the plant on the server side.", true);
46
    private final BoolSetting fastPlace = new BoolSetting("Fast place",
47
        "Ignores the right click cooldown between plants.", true);
48
    private final BoolSetting whileBreaking = new BoolSetting("Use whilst breaking",
49
        "Keeps going whilst you are mining a block.", false);
50
    private final BoolSetting whileRiding = new BoolSetting("Use whilst riding",
51
        "Keeps going whilst your hands are busy with a mount.", false);
52
    private final EnumSetting<TakeFrom> takeFrom = new EnumSetting<>("Take from",
53
        "Where bone meal may be taken from.", TakeFrom.HANDS)
54
        .describe(TakeFrom.HANDS, "Only uses bone meal already in your main hand.")
55
        .describe(TakeFrom.HOTBAR, "Switches to bone meal in the hotbar.")
56
        .describe(TakeFrom.INVENTORY, "Borrows bone meal from anywhere in the inventory.");
57
    private final BoolSetting saplings = new BoolSetting("Saplings",
58
        "Grows saplings into trees.", true);
59
    private final BoolSetting crops = new BoolSetting("Crops",
60
        "Wheat and carrots and potatoes and beetroot.", true);
61
    private final BoolSetting stems = new BoolSetting("Stems",
62
        "Pumpkin and melon stems.", true);
63
    private final BoolSetting cocoa = new BoolSetting("Cocoa",
64
        "Cocoa pods on jungle logs.", true);
65
    private final BoolSetting seaPickles = new BoolSetting("Sea pickles",
66
        "Spreads sea pickles across coral.", true);
67
    private final BoolSetting other = new BoolSetting("Other",
68
        "Everything else bone meal works on such as flowers and mushrooms.", false);
69
70
    private final InventoryUtil.HotbarLoan loan = new InventoryUtil.HotbarLoan();
71
    private int fed;
72
73
    public BonemealAura() {
74
        super("BonemealAura", "Feeds bone meal to the plants around you.", Category.WORLD);
75
        addSettings(range, multi, lineOfSight, rotate, swing, fastPlace, whileBreaking, whileRiding,
76
            takeFrom, saplings, crops, stems, cocoa, seaPickles, other);
77
        searchTags("bone meal", "fertiliser", "grow");
78
    }
79
80
    @Override
81
    public String getSuffix() {
82
        return fed == 0 ? null : fed + " fed";
83
    }
84
85
    @Override
86
    protected void onEnable() {
87
        fed = 0;
88
    }
89
90
    @Override
91
    protected void onDisable() {
92
        loan.giveBack();
93
    }
94
95
    @Subscribe
96
    private void onTick(TickEvent event) {
97
        if (!inGame() || mc.gameMode == null || mc.player.isSpectator() || mc.gui.screen() != null) {
98
            return;
99
        }
100
        if (mc.player.isDeadOrDying()) {
101
            // Respawn gives a fresh inventory. A borrowed slot could hold anything.
102
            loan.forget();
103
            return;
104
        }
105
        if (!fastPlace.isOn() && mc.rightClickDelay > 0) {
106
            return;
107
        }
108
        if (!whileBreaking.isOn() && mc.gameMode.isDestroying()) {
109
            return;
110
        }
111
        if (!whileRiding.isOn() && mc.player.isHandsBusy()) {
112
            return;
113
        }
114
        List<BlockPos> targets = targets();
115
        if (targets.isEmpty()) {
116
            loan.giveBack();
117
            return;
118
        }
119
        if (!holdBoneMeal()) {
120
            loan.giveBack();
121
            return;
122
        }
123
        if (multi.isOn()) {
124
            // Furthest plants first as a fed plant grows and hides the ones behind it.
125
            // Only the nearest turns since the rotation manager keeps one angle a tick.
126
            int before = fed;
127
            for (int i = targets.size() - 1; i >= 0; i--) {
128
                if (BlockUtil.useOn(targets.get(i), rotate.isOn() && i == 0, false)) {
129
                    fed++;
130
                }
131
            }
132
            if (fed > before) {
133
                swing.getValue().swing(InteractionHand.MAIN_HAND);
134
            }
135
            return;
136
        }
137
        if (BlockUtil.useOn(targets.getFirst(), rotate.isOn(), false)) {
138
            swing.getValue().swing(InteractionHand.MAIN_HAND);
139
            fed++;
140
            mc.rightClickDelay = CLICK_INTERVAL;
141
        }
142
    }
143
144
    // True once bone meal is in the main hand.
145
    private boolean holdBoneMeal() {
146
        if (mc.player.getMainHandItem().is(Items.BONE_MEAL)) {
147
            return true;
148
        }
149
        int limit = switch (takeFrom.getValue()) {
150
            case HANDS -> 0;
151
            case HOTBAR -> InventoryUtil.HOTBAR_SIZE;
152
            case INVENTORY -> InventoryUtil.WHOLE_INVENTORY;
153
        };
154
        for (int i = 0; i < limit; i++) {
155
            if (mc.player.getInventory().getItem(i).is(Items.BONE_MEAL)) {
156
                return loan.select(i);
157
            }
158
        }
159
        return false;
160
    }
161
162
    // Nearest first.
163
    private List<BlockPos> targets() {
164
        List<BlockPos> result = new ArrayList<>();
165
        for (BlockPos pos : BlockUtil.positionsWithin(range.getValue())) {
166
            if (wanted(pos) && (!lineOfSight.isOn() || BlockUtil.canSee(pos))) {
167
                result.add(pos);
168
            }
169
        }
170
        return result;
171
    }
172
173
    private boolean wanted(BlockPos pos) {
174
        BlockState state = BlockUtil.state(pos);
175
        Block block = state.getBlock();
176
        if (!(block instanceof BonemealableBlock plant) || !plant.isValidBonemealTarget(mc.level, pos, state)) {
177
            return false;
178
        }
179
        // Grass only sprouts more grass and flowers. Never worth the meal.
180
        if (block instanceof GrassBlock) {
181
            return false;
182
        }
183
        if (block instanceof SaplingBlock) {
184
            return saplings.isOn();
185
        }
186
        if (block instanceof CropBlock) {
187
            return crops.isOn();
188
        }
189
        if (block instanceof StemBlock) {
190
            return stems.isOn();
191
        }
192
        if (block instanceof CocoaBlock) {
193
            return cocoa.isOn();
194
        }
195
        if (block instanceof SeaPickleBlock) {
196
            return seaPickles.isOn();
197
        }
198
        return other.isOn();
199
    }
200
}
201