quiver module

quiver: Minecraft 26.3 cheat module, full source for every implementation (3 clients: Meteor Client, MelaHack (ThunderHack fork), OfflineClient).

3 implementationsCombatCOMBAT

Full module source: 3 implementations

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/Quiver.javaJava · 267 lines · 9.0 KB

Shoots arrows at yourself.

Settingseffectscooldowncheck-effectssilent-bowchat-infoonly-in-holesonly-on-groundmin-health
Quiver.javaJava · Minecraft 26.2 · 267 lines · 9.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 it.unimi.dsi.fastutil.ints.IntArrayList;
9
import it.unimi.dsi.fastutil.ints.IntList;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.mixin.BlockBehaviourAccessor;
12
import meteordevelopment.meteorclient.settings.*;
13
import meteordevelopment.meteorclient.systems.modules.Categories;
14
import meteordevelopment.meteorclient.systems.modules.Module;
15
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
16
import meteordevelopment.meteorclient.utils.player.FindItemResult;
17
import meteordevelopment.meteorclient.utils.player.InvUtils;
18
import meteordevelopment.orbit.EventHandler;
19
import net.minecraft.core.BlockPos;
20
import net.minecraft.core.Direction;
21
import net.minecraft.core.component.DataComponents;
22
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
23
import net.minecraft.world.effect.MobEffect;
24
import net.minecraft.world.effect.MobEffectInstance;
25
import net.minecraft.world.effect.MobEffects;
26
import net.minecraft.world.entity.player.Player;
27
import net.minecraft.world.item.BowItem;
28
import net.minecraft.world.item.ItemStack;
29
import net.minecraft.world.item.Items;
30
import net.minecraft.world.level.block.Block;
31
import net.minecraft.world.level.block.Blocks;
32
import net.minecraft.world.level.block.state.BlockState;
33
34
import java.util.HashSet;
35
import java.util.Iterator;
36
import java.util.List;
37
import java.util.Set;
38
39
public class Quiver extends Module {
40
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
41
    private final SettingGroup sgSafety = settings.createGroup("Safety");
42
43
44
    private final Setting<List<MobEffect>> effects = sgGeneral.add(new StatusEffectListSetting.Builder()
45
        .name("effects")
46
        .description("Which effects to shoot you with.")
47
        .defaultValue(MobEffects.STRENGTH.value())
48
        .build()
49
    );
50
51
    private final Setting<Integer> cooldown = sgGeneral.add(new IntSetting.Builder()
52
        .name("cooldown")
53
        .description("How many ticks between shooting effects (19 minimum for NCP).")
54
        .defaultValue(10)
55
        .range(0, 40)
56
        .sliderRange(0, 40)
57
        .build()
58
    );
59
60
    private final Setting<Boolean> checkEffects = sgGeneral.add(new BoolSetting.Builder()
61
        .name("check-effects")
62
        .description("Won't shoot you with effects you already have.")
63
        .defaultValue(true)
64
        .build()
65
    );
66
67
    private final Setting<Boolean> silentBow = sgGeneral.add(new BoolSetting.Builder()
68
        .name("silent-bow")
69
        .description("Takes a bow from your inventory to quiver.")
70
        .defaultValue(true)
71
        .build()
72
    );
73
74
    private final Setting<Boolean> chatInfo = sgGeneral.add(new BoolSetting.Builder()
75
        .name("chat-info")
76
        .description("Sends info about quiver checks in chat.")
77
        .defaultValue(false)
78
        .build()
79
    );
80
81
    // Safety
82
83
    private final Setting<Boolean> onlyInHoles = sgSafety.add(new BoolSetting.Builder()
84
        .name("only-in-holes")
85
        .description("Only quiver when you're in a hole.")
86
        .defaultValue(true)
87
        .build()
88
    );
89
90
    private final Setting<Boolean> onlyOnGround = sgSafety.add(new BoolSetting.Builder()
91
        .name("only-on-ground")
92
        .description("Only quiver when you're on the ground.")
93
        .defaultValue(true)
94
        .build()
95
    );
96
97
    private final Setting<Double> minHealth = sgSafety.add(new DoubleSetting.Builder()
98
        .name("min-health")
99
        .description("How much health you must have to quiver.")
100
        .defaultValue(10)
101
        .range(0, 36)
102
        .sliderRange(0, 36)
103
        .build()
104
    );
105
106
    private final IntList arrowSlots = new IntArrayList();
107
    private FindItemResult bow;
108
    private boolean wasMainhand, wasHotbar;
109
    private int timer, prevSlot;
110
    private final BlockPos.MutableBlockPos testPos = new BlockPos.MutableBlockPos();
111
112
    public Quiver() {
113
        super(Categories.Combat, "quiver", "Shoots arrows at yourself.");
114
    }
115
116
    @Override
117
    public void onActivate() {
118
        bow = InvUtils.find(Items.BOW);
119
        if (!shouldQuiver()) return;
120
121
        mc.options.keyUse.setDown(false);
122
        mc.gameMode.releaseUsingItem(mc.player);
123
124
        prevSlot = bow.slot();
125
        wasHotbar = bow.isHotbar();
126
        timer = 0;
127
128
        if (!bow.isMainHand()) {
129
            if (wasHotbar) InvUtils.swap(bow.slot(), true);
130
            else InvUtils.move().from(mc.player.getInventory().getSelectedSlot()).to(prevSlot);
131
        } else wasMainhand = true;
132
133
        arrowSlots.clear();
134
        Set<MobEffect> usedEffects = new HashSet<>();
135
136
        for (int i = mc.player.getInventory().getContainerSize(); i > 0; i--) {
137
            if (i == mc.player.getInventory().getSelectedSlot()) continue;
138
139
            ItemStack item = mc.player.getInventory().getItem(i);
140
141
            if (item.getItem() != Items.TIPPED_ARROW) continue;
142
143
            Iterator<MobEffectInstance> effects = item.getItem().components().get(DataComponents.POTION_CONTENTS).getAllEffects().iterator();
144
145
            if (!effects.hasNext()) continue;
146
147
            MobEffect effect = effects.next().getEffect().value();
148
149
            if (this.effects.get().contains(effect)
150
                && !usedEffects.contains(effect)
151
                && (!hasEffect(effect) || !checkEffects.get())) {
152
                usedEffects.add(effect);
153
                arrowSlots.add(i);
154
            }
155
        }
156
    }
157
158
    @Override
159
    public void onDeactivate() {
160
        if (!wasMainhand) {
161
            if (wasHotbar) InvUtils.swapBack();
162
            else InvUtils.move().from(mc.player.getInventory().getSelectedSlot()).to(prevSlot);
163
        }
164
    }
165
166
    @EventHandler
167
    private void onTick(TickEvent.Pre event) {
168
        bow = InvUtils.find(Items.BOW);
169
        if (!shouldQuiver()) return;
170
        if (arrowSlots.isEmpty()) {
171
            toggle();
172
            return;
173
        }
174
175
        if (timer > 0) {
176
            timer--;
177
            return;
178
        }
179
180
        boolean charging = mc.options.keyUse.isDown();
181
182
        if (!charging) {
183
            InvUtils.move().from(arrowSlots.getInt(0)).to(9);
184
            mc.options.keyUse.setDown(true);
185
        } else {
186
            if (BowItem.getPowerForTime(mc.player.getTicksUsingItem()) >= 0.12) {
187
                int targetSlot = arrowSlots.removeInt(0);
188
189
                mc.getConnection().send(new ServerboundMovePlayerPacket.Rot(mc.player.getYRot(), -90, mc.player.onGround(), mc.player.horizontalCollision));
190
                mc.options.keyUse.setDown(false);
191
                mc.gameMode.releaseUsingItem(mc.player);
192
                if (targetSlot != 9) InvUtils.move().from(9).to(targetSlot);
193
194
                timer = cooldown.get();
195
            }
196
        }
197
    }
198
199
    private boolean shouldQuiver() {
200
        if (!bow.found() || !bow.isHotbar() && !silentBow.get()) {
201
            if (chatInfo.get()) error("Couldn't find a usable bow, disabling.");
202
            toggle();
203
            return false;
204
        }
205
206
        if (!headIsOpen()) {
207
            if (chatInfo.get()) error("Not enough space to quiver, disabling.");
208
            toggle();
209
            return false;
210
        }
211
212
        if (EntityUtils.getTotalHealth(mc.player) < minHealth.get()) {
213
            if (chatInfo.get()) error("Not enough health to quiver, disabling.");
214
            toggle();
215
            return false;
216
        }
217
218
        if (onlyOnGround.get() && !mc.player.onGround()) {
219
            if (chatInfo.get()) error("You are not on the ground, disabling.");
220
            toggle();
221
            return false;
222
        }
223
224
        if (onlyInHoles.get() && !isSurrounded(mc.player)) {
225
            if (chatInfo.get()) error("You are not in a hole, disabling.");
226
            toggle();
227
            return false;
228
        }
229
230
        return true;
231
    }
232
233
    private boolean headIsOpen() {
234
        testPos.set(mc.player.blockPosition().offset(0, 1, 0));
235
        BlockState pos1 = mc.level.getBlockState(testPos);
236
        if (((BlockBehaviourAccessor) pos1.getBlock()).meteor$isHasCollision()) return false;
237
238
        testPos.offset(0, 1, 0);
239
        BlockState pos2 = mc.level.getBlockState(testPos);
240
        return !((BlockBehaviourAccessor) pos2.getBlock()).meteor$isHasCollision();
241
    }
242
243
    private boolean hasEffect(MobEffect effect) {
244
        for (MobEffectInstance statusEffect : mc.player.getActiveEffects()) {
245
            if (statusEffect.getEffect().value().equals(effect)) return true;
246
        }
247
248
        return false;
249
    }
250
251
    private boolean isSurrounded(Player target) {
252
        for (Direction dir : Direction.values()) {
253
            if (dir == Direction.UP || dir == Direction.DOWN) continue;
254
255
            testPos.set(target.blockPosition()).relative(dir);
256
            Block block = mc.level.getBlockState(testPos).getBlock();
257
258
            if (block != Blocks.OBSIDIAN && block != Blocks.BEDROCK && block != Blocks.RESPAWN_ANCHOR
259
                && block != Blocks.CRYING_OBSIDIAN && block != Blocks.NETHERITE_BLOCK) {
260
                return false;
261
            }
262
        }
263
264
        return true;
265
    }
266
}
267
MelaHack (ThunderHack fork)COMBATsrc/main/java/thunder/hack/features/modules/combat/Quiver.javaJava · 117 lines · 4.1 KB

Automatically shoots you with a tipped arrow.

SettingsOnly In Hole
Quiver.javaJava · Minecraft 26.2 · 117 lines · 4.1 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.combat;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
5
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
6
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
7
import net.minecraft.world.effect.MobEffects;
8
import net.minecraft.world.item.BowItem;
9
import net.minecraft.world.item.Items;
10
import net.minecraft.world.item.TippedArrowItem;
11
import thunder.hack.events.impl.EventSync;
12
import thunder.hack.features.modules.Module;
13
import thunder.hack.setting.Setting;
14
import thunder.hack.utility.player.InventoryUtility;
15
import thunder.hack.utility.player.SearchInvResult;
16
import thunder.hack.utility.world.HoleUtility;
17
18
import java.util.Objects;
19
20
import static thunder.hack.features.modules.client.ClientSettings.isRu;
21
22
public final class Quiver extends Module {
23
    private final Setting<Boolean> onlyInHole = new Setting<>("Only In Hole", false);
24
25
    private int preBowSlot;
26
    private int count;
27
28
    public Quiver() {
29
        super("Quiver", Category.COMBAT);
30
    }
31
32
    @Override
33
    public void onEnable() {
34
        count = 0;
35
        preBowSlot = mc.player.getInventory().getSelectedSlot();
36
    }
37
38
    @Override
39
    public void onDisable() {
40
        if (preBowSlot != -1)
41
            InventoryUtility.switchTo(preBowSlot);
42
43
        mc.options.keyUse.setDown(false);
44
    }
45
46
    @EventHandler
47
    @SuppressWarnings("unused")
48
    private void onSync(EventSync event) {
49
        if ((!HoleUtility.isHole(mc.player.blockPosition()) && onlyInHole.getValue()) || (mc.player.isUsingItem() && !mc.player.getMainHandItem().getItem().equals(Items.BOW)))
50
            return;
51
52
        SearchInvResult strength = getArrow("strength");
53
        SearchInvResult swiftness = getArrow("swiftness");
54
55
        boolean hasStrength = !strength.found() || (mc.player.hasEffect(MobEffects.STRENGTH) && mc.player.getEffect(MobEffects.STRENGTH).getDuration() > 100);
56
        boolean hasSwiftness = !swiftness.found() || (mc.player.hasEffect(MobEffects.SPEED) && mc.player.getEffect(MobEffects.SPEED).getDuration() > 100);
57
58
        if (!strength.found() && !swiftness.found()) {
59
            disable(isRu() ? "В интвенторе отсутствуют нужные стрелы! Отключение..." : "No arrows in hotbar! Disabling...");
60
            return;
61
        }
62
63
        if (hasSwiftness && hasStrength) {
64
            disable();
65
            return;
66
        }
67
68
        SearchInvResult result = InventoryUtility.findItemInHotBar(Items.BOW);
69
        if (!result.found()) {
70
            disable(isRu() ? "В хотбаре отсутствует лук! Отключение..." : "No bow in hotbar! Disabling...");
71
            return;
72
        }
73
        result.switchTo();
74
75
        if (BowItem.getPowerForTime(mc.player.getTicksUsingItem()) >= 0.15) {
76
            releaseBow();
77
            switchInvSlot(strength.slot(), swiftness.slot());
78
            return;
79
        }
80
81
        if (count >= (strength.found()  && swiftness.found() ? 2 : 1)) {
82
            disable();
83
            return;
84
        }
85
86
        mc.options.keyUse.setDown(true);
87
    }
88
89
    private void releaseBow() {
90
        sendPacket(new ServerboundMovePlayerPacket.Rot(mc.player.getYRot(), -90, mc.player.onGround(), mc.player.horizontalCollision));
91
        mc.options.keyUse.setDown(false);
92
        mc.gameMode.releaseUsingItem(mc.player);
93
        count++;
94
    }
95
96
    private SearchInvResult getArrow(String name) {
97
        return InventoryUtility.findInInventory(stack -> {
98
            if (stack.getItem() instanceof TippedArrowItem tai) {
99
                String key = tai.getDescriptionId();
100
                return key.contains("effect." + name);
101
            }
102
            return false;
103
        });
104
    }
105
106
    private void switchInvSlot(int from, int to) {
107
        if (from == -1 || to == -1)
108
            return;
109
110
        sendPacket(new ServerboundPlayerCommandPacket(Objects.requireNonNull(mc.player), ServerboundPlayerCommandPacket.Action.STOP_SPRINTING));
111
        clickSlot(from);
112
        clickSlot(to);
113
        clickSlot(from);
114
        sendPacket(new ServerboundContainerClosePacket(mc.player.containerMenu.containerId));
115
    }
116
}
117
OfflineClientCOMBATsrc/main/java/com/jellypudding/offlineclient/modules/combat/Quiver.javaJava · 194 lines · 6.6 KB

Picks which arrow your bow fires next.

SettingsEffectsSave tippedWhilst drawingDelay
Quiver.javaJava · Minecraft 26.2 · 194 lines · 6.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.combat;
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.InventoryUtil;
11
import com.jellypudding.offlineclient.util.InventoryUtil.Swap;
12
import net.minecraft.core.component.DataComponents;
13
import net.minecraft.core.registries.BuiltInRegistries;
14
import net.minecraft.resources.Identifier;
15
import net.minecraft.world.effect.MobEffect;
16
import net.minecraft.world.effect.MobEffectInstance;
17
import net.minecraft.world.effect.MobEffects;
18
import net.minecraft.world.item.BowItem;
19
import net.minecraft.world.item.CrossbowItem;
20
import net.minecraft.world.item.ItemStack;
21
import net.minecraft.world.item.Items;
22
import net.minecraft.world.item.alchemy.PotionContents;
23
24
import java.util.List;
25
26
// The game fires the first arrow it finds.
27
public final class Quiver extends Module {
28
29
    private final RegistryListSetting<MobEffect> effects = new RegistryListSetting<>("Effects",
30
        "Tipped arrows to reach for in order of preference.",
31
        BuiltInRegistries.MOB_EFFECT,
32
        List.of(MobEffects.INSTANT_DAMAGE.value(), MobEffects.POISON.value(),
33
            MobEffects.SLOWNESS.value(), MobEffects.WEAKNESS.value()));
34
    private final BoolSetting plainFallback = new BoolSetting("Save tipped",
35
        "Move plain arrows to the front when none of the chosen ones are around.", false);
36
    private final BoolSetting drawingOnly = new BoolSetting("Whilst drawing",
37
        "Only sort the quiver whilst the bow is actually being drawn.", false);
38
    private final NumberSetting delay = new NumberSetting("Delay",
39
        "Ticks between moves.", 2, 0, 20, 1, " ticks");
40
41
    private final InventoryUtil.StrandedStack cursor = new InventoryUtil.StrandedStack();
42
    private int timer;
43
    private String chosen;
44
45
    public Quiver() {
46
        super("Quiver", "Picks which arrow your bow fires next.", Category.COMBAT);
47
        addSettings(effects, plainFallback, drawingOnly, delay);
48
        searchTags("tipped arrow", "arrow select", "bow");
49
    }
50
51
    @Override
52
    public String getSuffix() {
53
        return chosen;
54
    }
55
56
    @Override
57
    protected void onEnable() {
58
        timer = 0;
59
        chosen = null;
60
    }
61
62
    @Override
63
    protected void onDisable() {
64
        if (inGame()) {
65
            cursor.giveBack();
66
        }
67
    }
68
69
    @Subscribe
70
    private void onTick(TickEvent event) {
71
        if (!inGame() || mc.player.isSpectator() || !holdsLauncher()) {
72
            chosen = null;
73
            return;
74
        }
75
        if (!cursor.recover()) {
76
            return;
77
        }
78
        if (drawingOnly.isOn() && !isDrawing()) {
79
            return;
80
        }
81
        if (!InventoryUtil.inventoryFree()) {
82
            return;
83
        }
84
        if (timer > 0) {
85
            timer--;
86
            return;
87
        }
88
89
        int want = findWanted();
90
        if (want == -1) {
91
            chosen = null;
92
            return;
93
        }
94
        chosen = label(mc.player.getInventory().getItem(want));
95
96
        // An arrow in the offhand beats everything else the game looks at.
97
        if (isArrow(mc.player.getOffhandItem())) {
98
            if (!ItemStack.isSameItemSameComponents(mc.player.getOffhandItem(),
99
                mc.player.getInventory().getItem(want))) {
100
                move(InventoryUtil.networkSlot(want), InventoryUtil.OFFHAND_SLOT);
101
            }
102
            return;
103
        }
104
105
        int first = firstArrow();
106
        if (first == -1 || first == want) {
107
            return;
108
        }
109
        move(InventoryUtil.networkSlot(want), InventoryUtil.networkSlot(first));
110
    }
111
112
    private void move(int from, int to) {
113
        Swap result = InventoryUtil.swap(from, to);
114
        if (result == Swap.REFUSED) {
115
            return;
116
        }
117
        if (result == Swap.STRANDED) {
118
            // Whatever the arrow displaced had nowhere to go.
119
            cursor.hold(from);
120
        }
121
        timer = delay.getInt();
122
    }
123
124
    private boolean holdsLauncher() {
125
        return isLauncher(mc.player.getMainHandItem()) || isLauncher(mc.player.getOffhandItem());
126
    }
127
128
    private static boolean isLauncher(ItemStack stack) {
129
        return stack.getItem() instanceof BowItem || stack.getItem() instanceof CrossbowItem;
130
    }
131
132
    private boolean isDrawing() {
133
        if (mc.player.isUsingItem() && isLauncher(mc.player.getUseItem())) {
134
            return true;
135
        }
136
        return isLauncher(mc.player.getMainHandItem()) && mc.options.keyUse.isDown();
137
    }
138
139
    private int firstArrow() {
140
        return InventoryUtil.findSlot(Quiver::isArrow, InventoryUtil.WHOLE_INVENTORY);
141
    }
142
143
    // Inventory index of the arrow that should be fired next.
144
    private int findWanted() {
145
        for (Identifier id : effects.getValue()) {
146
            if (!BuiltInRegistries.MOB_EFFECT.containsKey(id)) {
147
                continue;
148
            }
149
            MobEffect effect = BuiltInRegistries.MOB_EFFECT.getValue(id);
150
            for (int i = 0; i < InventoryUtil.WHOLE_INVENTORY; i++) {
151
                ItemStack stack = mc.player.getInventory().getItem(i);
152
                if (stack.is(Items.TIPPED_ARROW) && hasEffect(stack, effect)) {
153
                    return i;
154
                }
155
            }
156
        }
157
        if (!plainFallback.isOn()) {
158
            return -1;
159
        }
160
        return InventoryUtil.findSlot(Items.ARROW, InventoryUtil.WHOLE_INVENTORY);
161
    }
162
163
    private static boolean hasEffect(ItemStack stack, MobEffect effect) {
164
        PotionContents contents = stack.get(DataComponents.POTION_CONTENTS);
165
        if (contents == null) {
166
            return false;
167
        }
168
        for (MobEffectInstance instance : contents.getAllEffects()) {
169
            if (instance.getEffect().value() == effect) {
170
                return true;
171
            }
172
        }
173
        return false;
174
    }
175
176
    private static boolean isArrow(ItemStack stack) {
177
        return stack.is(Items.ARROW) || stack.is(Items.TIPPED_ARROW)
178
            || stack.is(Items.SPECTRAL_ARROW);
179
    }
180
181
    private static String label(ItemStack stack) {
182
        if (!stack.is(Items.TIPPED_ARROW)) {
183
            return "plain";
184
        }
185
        PotionContents contents = stack.get(DataComponents.POTION_CONTENTS);
186
        if (contents == null) {
187
            return "plain";
188
        }
189
        var effects = contents.getAllEffects().iterator();
190
        return effects.hasNext()
191
            ? effects.next().getEffect().value().getDisplayName().getString() : "plain";
192
    }
193
}
194