ClickPearl module

ClickPearl: Minecraft 26.3 cheat module, full source for every implementation (1 client: Combatant).

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.

CombatantPLAYERsrc/main/java/combatant/client/features/module/modules/player/ClickPearl.javaJava · 160 lines · 5.7 KB
ClickPearl.javaJava · Minecraft 26.2 · 160 lines · 5.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.features.module.modules.player;
9
10
import net.minecraft.client.Minecraft;
11
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
12
import net.minecraft.client.player.LocalPlayer;
13
import net.minecraft.world.InteractionHand;
14
import net.minecraft.world.item.ItemStack;
15
import net.minecraft.world.item.Items;
16
import combatant.client.features.module.Module;
17
import combatant.client.features.module.ModuleCategory;
18
import combatant.client.features.module.ModuleInfo;
19
import combatant.client.mixins.accessors.PlayerInventoryAccessor;
20
import combatant.client.util.player.ResetAttackCooldown;
21
import combatant.client.util.player.inventory.InventorySwap;
22
23
//todo Description
24
@ModuleInfo(
25
        id = "clickpearl",
26
        displayName = "ClickPearl",
27
        category = ModuleCategory.PLAYER
28
)
29
public class ClickPearl extends Module {
30
    private static final String ACTION_CLICKPEARL = "clickpearl";
31
32
    private final Minecraft client = Minecraft.getInstance();
33
    private ItemStack previousHeld = ItemStack.EMPTY;
34
35
    public ClickPearl() {
36
        // Default binds:
37
        // - Toggle module with LEFT_CTRL+Z
38
        // - Action key is Z (handled by module's own logic)
39
        setDefaultBind("LEFT_CTRL+Z");
40
        action(ACTION_CLICKPEARL, "Z");
41
    }
42
43
    @Override
44
    public void onTick() {
45
        if (!isEnabled()) return;
46
        if (client.player == null || client.gameMode == null) return;
47
48
        if (isActionPressedOnce(ACTION_CLICKPEARL)) {
49
            tryThrowPearl();
50
        }
51
    }
52
53
    // ===========================
54
    //      ТВОЯ ЛОГИКА — НЕ ТРОНУТА
55
    // ===========================
56
    private void tryThrowPearl() {
57
        LocalPlayer player = client.player;
58
        MultiPlayerGameMode manager = client.gameMode;
59
        if (player == null || manager == null) return;
60
        if (player.getCooldowns().isOnCooldown(new ItemStack(Items.ENDER_PEARL))) return;
61
62
        PlayerInventoryAccessor inv = (PlayerInventoryAccessor) player.getInventory();
63
        int originalSlot = inv.combatant$getSelectedSlot();
64
65
        ItemStack off = player.getOffhandItem();
66
        if (isPearl(off)) {
67
            manager.useItem(player, InteractionHand.OFF_HAND);
68
            player.swing(InteractionHand.OFF_HAND);
69
            return;
70
        }
71
72
        int hotbarPearl = findPearlInHotbar(player);
73
        if (hotbarPearl != -1) {
74
            inv.combatant$setSelectedSlot(hotbarPearl);
75
            manager.useItem(player, InteractionHand.MAIN_HAND);
76
            player.swing(InteractionHand.MAIN_HAND);
77
            inv.combatant$setSelectedSlot(originalSlot);
78
            return;
79
        }
80
81
        int invPearl = findPearlInInventory(player);
82
        if (invPearl == -1) return;
83
84
        int emptyHotbar = findFirstEmptyHotbarSlot(player);
85
        var handler = player.inventoryMenu;
86
        if (handler == null) return;
87
        int syncId = handler.containerId;
88
89
        client.execute(() -> {
90
            if (emptyHotbar != -1) {
91
                int pearlScreen = InventorySwap.mapInventoryToScreenSlot(invPearl);
92
                int targetScreen = InventorySwap.mapHotbarToScreenSlot(emptyHotbar);
93
94
                InventorySwap.INSTANCE.swapScreenSlots(pearlScreen, targetScreen);
95
96
                inv.combatant$setSelectedSlot(emptyHotbar);
97
                manager.useItem(player, InteractionHand.MAIN_HAND);
98
                player.swing(InteractionHand.MAIN_HAND);
99
                inv.combatant$setSelectedSlot(originalSlot);
100
            } else {
101
                int targetScreen = InventorySwap.mapHotbarToScreenSlot(originalSlot);
102
                int pearlScreen = InventorySwap.mapInventoryToScreenSlot(invPearl);
103
104
                ItemStack currentHeld = player.getMainHandItem();
105
                previousHeld = currentHeld.isEmpty() ? ItemStack.EMPTY : currentHeld.copy();
106
107
                InventorySwap.INSTANCE.swapScreenSlots(pearlScreen, targetScreen);
108
109
                manager.useItem(player, InteractionHand.MAIN_HAND);
110
                player.swing(InteractionHand.MAIN_HAND);
111
112
                if (!previousHeld.isEmpty()) {
113
                    int restoreSlot = findItemInInventory(player, previousHeld);
114
                    if (restoreSlot != -1) {
115
                        int restoreScreen = InventorySwap.mapInventoryToScreenSlot(restoreSlot);
116
                        InventorySwap.INSTANCE.swapScreenSlots(restoreScreen, targetScreen);
117
                        ResetAttackCooldown.resetAttackCooldown(player);
118
                    }
119
                }
120
121
                inv.combatant$setSelectedSlot(originalSlot);
122
            }
123
        });
124
    }
125
126
    private boolean isPearl(ItemStack stack) {
127
        return stack != null && stack.is(Items.ENDER_PEARL);
128
    }
129
130
    private int findPearlInHotbar(LocalPlayer player) {
131
        for (int i = 0; i < 9; i++) {
132
            if (isPearl(player.getInventory().getItem(i))) return i;
133
        }
134
        return -1;
135
    }
136
137
    private int findPearlInInventory(LocalPlayer player) {
138
        for (int i = 0; i < 36; i++) {
139
            if (isPearl(player.getInventory().getItem(i))) return i;
140
        }
141
        return -1;
142
    }
143
144
    private int findFirstEmptyHotbarSlot(LocalPlayer player) {
145
        for (int i = 0; i < 9; i++) {
146
            if (player.getInventory().getItem(i).isEmpty()) return i;
147
        }
148
        return -1;
149
    }
150
151
    private int findItemInInventory(LocalPlayer player, ItemStack itemStack) {
152
        if (itemStack == null || itemStack.isEmpty()) return -1;
153
        for (int i = 0; i < 36; i++) {
154
            ItemStack s = player.getInventory().getItem(i);
155
            if (!s.isEmpty() && s.getItem() == itemStack.getItem()) return i;
156
        }
157
        return -1;
158
    }
159
}
160