middle-click-extra module

middle-click-extra: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationPlayer

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 ClientPlayersrc/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.javaJava · 231 lines · 7.9 KB

Perform various actions when you middle click.

Settingsmodesend-messagemessage-to-sendquick-swapswap-backdisable-in-creativenotify
MiddleClickExtra.javaJava · Minecraft 26.2 · 231 lines · 7.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.player;
7
8
import meteordevelopment.meteorclient.events.entity.player.FinishUsingItemEvent;
9
import meteordevelopment.meteorclient.events.entity.player.StoppedUsingItemEvent;
10
import meteordevelopment.meteorclient.events.meteor.MouseClickEvent;
11
import meteordevelopment.meteorclient.events.packets.PacketEvent;
12
import meteordevelopment.meteorclient.events.world.TickEvent;
13
import meteordevelopment.meteorclient.settings.*;
14
import meteordevelopment.meteorclient.systems.friends.Friend;
15
import meteordevelopment.meteorclient.systems.friends.Friends;
16
import meteordevelopment.meteorclient.systems.modules.Categories;
17
import meteordevelopment.meteorclient.systems.modules.Module;
18
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
19
import meteordevelopment.meteorclient.utils.player.ChatUtils;
20
import meteordevelopment.meteorclient.utils.player.FindItemResult;
21
import meteordevelopment.meteorclient.utils.player.InvUtils;
22
import meteordevelopment.orbit.EventHandler;
23
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
24
import net.minecraft.world.InteractionHand;
25
import net.minecraft.world.entity.player.Player;
26
import net.minecraft.world.item.BowItem;
27
import net.minecraft.world.item.Item;
28
import net.minecraft.world.item.Items;
29
import net.minecraft.world.level.GameType;
30
31
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_MIDDLE;
32
33
public class MiddleClickExtra extends Module {
34
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
35
36
    private final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
37
        .name("mode")
38
        .description("Which item to use when you middle click.")
39
        .defaultValue(Mode.Pearl)
40
        .build()
41
    );
42
43
    private final Setting<Boolean> message = sgGeneral.add(new BoolSetting.Builder()
44
        .name("send-message")
45
        .description("Sends a message when you add a player as a friend.")
46
        .defaultValue(false)
47
        .visible(() -> mode.get() == Mode.AddFriend)
48
        .build()
49
    );
50
51
    private final Setting<String> friendMessage = sgGeneral.add(new StringSetting.Builder()
52
        .name("message-to-send")
53
        .description("Message to send when you add a player as a friend (use %player for the player's name)")
54
        .defaultValue("/msg %player I just friended you on Meteor.")
55
        .visible(() -> mode.get() == Mode.AddFriend)
56
        .build()
57
    );
58
59
    private final Setting<Boolean> quickSwap = sgGeneral.add(new BoolSetting.Builder()
60
        .name("quick-swap")
61
        .description("Allows you to use items in your inventory by simulating hotbar key presses. May get flagged by anticheats.")
62
        .defaultValue(false)
63
        .visible(() -> mode.get() != Mode.AddFriend)
64
        .build()
65
    );
66
67
    private final Setting<Boolean> swapBack = sgGeneral.add(new BoolSetting.Builder()
68
        .name("swap-back")
69
        .description("Swap back to your original slot when you finish using an item.")
70
        .defaultValue(false)
71
        .visible(() -> mode.get() != Mode.AddFriend && !quickSwap.get())
72
        .build()
73
    );
74
75
    private final Setting<Boolean> disableInCreative = sgGeneral.add(new BoolSetting.Builder()
76
        .name("disable-in-creative")
77
        .description("Middle click action is disabled in Creative mode.")
78
        .defaultValue(true)
79
        .build()
80
    );
81
82
    private final Setting<Boolean> notify = sgGeneral.add(new BoolSetting.Builder()
83
        .name("notify")
84
        .description("Notifies you when you do not have the specified item in your hotbar.")
85
        .defaultValue(true)
86
        .visible(() -> mode.get() != Mode.AddFriend)
87
        .build()
88
    );
89
90
    public MiddleClickExtra() {
91
        super(Categories.Player, "middle-click-extra", "Perform various actions when you middle click.");
92
    }
93
94
    private boolean isUsing;
95
    private boolean wasHeld;
96
    private int itemSlot;
97
    private int selectedSlot;
98
99
    @Override
100
    public void onDeactivate() {
101
        stopIfUsing(false);
102
    }
103
104
    @EventHandler
105
    private void onMouseClick(MouseClickEvent event) {
106
        if (event.action != KeyAction.Press || event.button() != MOUSE_BUTTON_MIDDLE || mc.gui.screen() != null)
107
            return;
108
109
        if (disabledByCreative()) return;
110
111
        if (mode.get() == Mode.AddFriend) {
112
            if (mc.crosshairPickEntity == null) return;
113
            if (!(mc.crosshairPickEntity instanceof Player player)) return;
114
115
            if (!Friends.get().isFriend(player)) {
116
                Friends.get().add(new Friend(player));
117
                info("Added %s to friends", player.getName().getString());
118
                if (message.get()) {
119
                    String messageNotify = friendMessage.get().replace("%player", player.getName().getString());
120
                    ChatUtils.sendPlayerMsg(messageNotify);
121
                }
122
123
            } else {
124
                Friends.get().remove(Friends.get().get(player));
125
                info("Removed %s from friends", player.getName().getString());
126
            }
127
128
            return;
129
        }
130
131
        FindItemResult result = InvUtils.find(mode.get().item);
132
        if (!result.found() || !result.isHotbar() && !quickSwap.get()) {
133
            if (notify.get()) warning("Unable to find specified item.");
134
            return;
135
        }
136
137
        selectedSlot = mc.player.getInventory().getSelectedSlot();
138
        itemSlot = result.slot();
139
        wasHeld = result.isMainHand();
140
141
        if (!wasHeld) {
142
            if (!quickSwap.get()) InvUtils.swap(result.slot(), swapBack.get());
143
            else InvUtils.quickSwap().fromId(selectedSlot).to(itemSlot);
144
        }
145
146
        if (mode.get().immediate) {
147
            mc.gameMode.useItem(mc.player, InteractionHand.MAIN_HAND);
148
            swapBack(false);
149
        } else {
150
            mc.options.keyUse.setDown(true);
151
            isUsing = true;
152
        }
153
    }
154
155
    @EventHandler
156
    private void onTick(TickEvent.Pre event) {
157
        if (!isUsing) return;
158
        boolean pressed = true;
159
160
        if (mc.player.getMainHandItem().getItem() instanceof BowItem) {
161
            pressed = BowItem.getPowerForTime(mc.player.getTicksUsingItem()) < 1;
162
        }
163
164
        mc.options.keyUse.setDown(pressed);
165
    }
166
167
    @EventHandler
168
    private void onPacketSendEvent(PacketEvent.Send event) {
169
        if (event.packet instanceof ServerboundSetCarriedItemPacket) {
170
            stopIfUsing(true);
171
        }
172
    }
173
174
    @EventHandler
175
    private void onStoppedUsingItem(StoppedUsingItemEvent event) {
176
        stopIfUsing(false);
177
    }
178
179
    @EventHandler
180
    private void onFinishUsingItem(FinishUsingItemEvent event) {
181
        stopIfUsing(false);
182
    }
183
184
    private void stopIfUsing(boolean wasCancelled) {
185
        if (isUsing) {
186
            swapBack(wasCancelled);
187
            mc.options.keyUse.setDown(false);
188
            isUsing = false;
189
        }
190
    }
191
192
    void swapBack(boolean wasCancelled) {
193
        if (wasHeld) return;
194
195
        if (quickSwap.get()) {
196
            InvUtils.quickSwap().fromId(selectedSlot).to(itemSlot);
197
        } else {
198
            if (!swapBack.get() || wasCancelled) return;
199
            InvUtils.swapBack();
200
        }
201
    }
202
203
    private boolean disabledByCreative() {
204
        if (mc.player == null) return false;
205
206
        return disableInCreative.get() && mc.player.gameMode() == GameType.CREATIVE;
207
    }
208
209
    public enum Mode {
210
        Pearl(Items.ENDER_PEARL, true),
211
        XP(Items.EXPERIENCE_BOTTLE, true),
212
        Rocket(Items.FIREWORK_ROCKET, true),
213
        WindCharge(Items.WIND_CHARGE, true),
214
215
        Bow(Items.BOW, false),
216
        Gap(Items.GOLDEN_APPLE, false),
217
        EGap(Items.ENCHANTED_GOLDEN_APPLE, false),
218
        Chorus(Items.CHORUS_FRUIT, false),
219
220
        AddFriend(null, true);
221
222
        private final Item item;
223
        private final boolean immediate;
224
225
        Mode(Item item, boolean immediate) {
226
            this.item = item;
227
            this.immediate = immediate;
228
        }
229
    }
230
}
231