bow-spam module

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

1 implementationCombat

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 ClientCombatsrc/main/java/meteordevelopment/meteorclient/systems/modules/combat/BowSpam.javaJava · 145 lines · 5.0 KB

Spams bows and crossbows.

Settingschargewhen-holding-right-clickspam-crossbowscrossbow-delaysearch-inventory
BowSpam.javaJava · Minecraft 26.2 · 145 lines · 5.0 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.combat;
7
8
import meteordevelopment.meteorclient.events.world.TickEvent;
9
import meteordevelopment.meteorclient.settings.BoolSetting;
10
import meteordevelopment.meteorclient.settings.IntSetting;
11
import meteordevelopment.meteorclient.settings.Setting;
12
import meteordevelopment.meteorclient.settings.SettingGroup;
13
import meteordevelopment.meteorclient.systems.modules.Categories;
14
import meteordevelopment.meteorclient.systems.modules.Module;
15
import meteordevelopment.meteorclient.utils.player.FindItemResult;
16
import meteordevelopment.meteorclient.utils.player.InvUtils;
17
import meteordevelopment.orbit.EventHandler;
18
import net.minecraft.world.InteractionHand;
19
import net.minecraft.world.item.ArrowItem;
20
import net.minecraft.world.item.CrossbowItem;
21
import net.minecraft.world.item.ItemStack;
22
import net.minecraft.world.item.Items;
23
24
public class BowSpam extends Module {
25
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
26
    private final SettingGroup sgCrossbows = settings.createGroup("Crossbows");
27
28
    private final Setting<Integer> charge = sgGeneral.add(new IntSetting.Builder()
29
        .name("charge")
30
        .description("How long to charge the bow before releasing in ticks.")
31
        .defaultValue(5)
32
        .range(4, 20)
33
        .sliderRange(4, 20)
34
        .build()
35
    );
36
37
    private final Setting<Boolean> onlyWhenHoldingRightClick = sgGeneral.add(new BoolSetting.Builder()
38
        .name("when-holding-right-click")
39
        .description("Works only when holding right click.")
40
        .defaultValue(false)
41
        .build()
42
    );
43
44
    private final Setting<Boolean> spamCrossbows = sgCrossbows.add(new BoolSetting.Builder()
45
        .name("spam-crossbows")
46
        .description("Whether to spam loaded crossbows; takes priority over charging bows.")
47
        .defaultValue(true)
48
        .build()
49
    );
50
51
    private final Setting<Integer> crossbowDelay = sgCrossbows.add(new IntSetting.Builder()
52
        .name("crossbow-delay")
53
        .description("Delay between shooting crossbows in ticks.")
54
        .defaultValue(10)
55
        .sliderRange(0, 20)
56
        .min(0)
57
        .build()
58
    );
59
60
    private final Setting<Boolean> searchInventory = sgCrossbows.add(new BoolSetting.Builder()
61
        .name("search-inventory")
62
        .description("Whether to search your inventory to find loaded crossbows.")
63
        .defaultValue(true)
64
        .build()
65
    );
66
67
    private boolean wasBow = false;
68
    private boolean wasHoldingRightClick = false;
69
    private int ticks = 0;
70
71
    public BowSpam() {
72
        super(Categories.Combat, "bow-spam", "Spams bows and crossbows.", "auto-bow", "crossbow-spam", "auto-crossbow");
73
    }
74
75
    @Override
76
    public void onActivate() {
77
        wasBow = false;
78
        wasHoldingRightClick = false;
79
    }
80
81
    @Override
82
    public void onDeactivate() {
83
        setPressed(false);
84
    }
85
86
    @EventHandler
87
    private void onTick(TickEvent.Pre event) {
88
        FindItemResult crossbow = searchInventory.get() ? InvUtils.find(this::crossbow) : InvUtils.find(this::crossbow, 0, 8);
89
        if (spamCrossbows.get() && crossbow.found()) {
90
            if (ticks >= crossbowDelay.get()) {
91
                int slot = crossbow.slot();
92
                if (!crossbow.isHotbar()) {
93
                    FindItemResult valid = InvUtils.find(stack -> stack.isEmpty() || stack.is(Items.CROSSBOW) || stack.is(Items.ARROW), 0, 8);
94
                    if (!valid.found()) return;
95
96
                    InvUtils.quickSwap().fromId(valid.slot()).to(crossbow.slot());
97
                    slot = valid.slot();
98
                }
99
100
                InvUtils.swap(slot, true);
101
                mc.gameMode.useItem(mc.player, InteractionHand.MAIN_HAND);
102
                InvUtils.swapBack();
103
104
                ticks = 0;
105
            } else {
106
                ticks++;
107
            }
108
109
            return;
110
        }
111
112
        if (!mc.player.getAbilities().instabuild && !InvUtils.find(itemStack -> itemStack.getItem() instanceof ArrowItem).found())
113
            return;
114
115
        if (!onlyWhenHoldingRightClick.get() || mc.options.keyUse.isDown()) {
116
            boolean isBow = InvUtils.testInHands(Items.BOW);
117
            if (!isBow && wasBow) setPressed(false);
118
119
            wasBow = isBow;
120
            if (!isBow) return;
121
122
            if (mc.player.getTicksUsingItem() >= charge.get()) {
123
                mc.gameMode.releaseUsingItem(mc.player);
124
            } else {
125
                setPressed(true);
126
            }
127
128
            wasHoldingRightClick = mc.options.keyUse.isDown();
129
        } else {
130
            if (wasHoldingRightClick) {
131
                setPressed(false);
132
                wasHoldingRightClick = false;
133
            }
134
        }
135
    }
136
137
    private void setPressed(boolean pressed) {
138
        mc.options.keyUse.setDown(pressed);
139
    }
140
141
    private boolean crossbow(ItemStack stack) {
142
        return stack.getItem() instanceof CrossbowItem && CrossbowItem.isCharged(stack);
143
    }
144
}
145