ElytraHelper module

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

1 implementationMOVEMENT

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.

CombatantMOVEMENTsrc/main/java/combatant/client/features/module/modules/movement/ElytraHelper.javaJava · 499 lines · 17.2 KB
Settingsauto_takeoffrecast_moderecast_auto_walkrecast_auto_jumprecast_allow_brokenrecast_delay
ElytraHelper.javaJava · Minecraft 26.2 · 499 lines · 17.2 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.movement;
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.core.Holder;
14
import net.minecraft.core.component.DataComponents;
15
import net.minecraft.core.registries.Registries;
16
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
17
import net.minecraft.world.entity.EquipmentSlot;
18
import net.minecraft.world.item.ItemStack;
19
import net.minecraft.world.item.Items;
20
import net.minecraft.world.item.enchantment.Enchantment;
21
import net.minecraft.world.item.enchantment.EnchantmentHelper;
22
import net.minecraft.world.item.enchantment.Enchantments;
23
import net.minecraft.world.item.equipment.Equippable;
24
import combatant.client.config.values.BooleanValue;
25
import combatant.client.config.values.EnumValue;
26
import combatant.client.config.values.NumberValue;
27
import combatant.client.events.EventHandler;
28
import combatant.client.events.impl.EventSync;
29
import combatant.client.events.impl.MovementInputEvent;
30
import combatant.client.features.module.Module;
31
import combatant.client.features.module.ModuleCategory;
32
import combatant.client.features.module.ModuleInfo;
33
import combatant.client.features.module.Notifier;
34
import combatant.client.util.player.ElytraRecastUtil;
35
import combatant.client.util.player.inventory.FireworkUseController;
36
import combatant.client.util.player.inventory.InventorySwap;
37
import combatant.client.util.pvp.client.CooldownsState;
38
39
//todo Description
40
@ModuleInfo(
41
        id = "elytrahelper",
42
        displayName = "ElytraHelper",
43
        category = ModuleCategory.MOVEMENT
44
)
45
public class ElytraHelper extends Module {
46
47
    private static final String SETTING_AUTO_TAKEOFF = "auto_takeoff";
48
    private static final String ACTION_SWAP_ELYTRA = "swap_elytra";
49
    private static final String ACTION_USE_FIREWORK = "use_firework";
50
    private static final String SETTING_RECAST_MODE = "recast_mode";
51
    private static final String SETTING_RECAST_AUTO_WALK = "recast_auto_walk";
52
    private static final String SETTING_RECAST_AUTO_JUMP = "recast_auto_jump";
53
    private static final String SETTING_RECAST_ALLOW_BROKEN = "recast_allow_broken";
54
    private static final String SETTING_RECAST_DELAY = "recast_delay";
55
    private static final int MANUAL_FIREWORK_COOLDOWN_TICKS = FireworkUseController.DEFAULT_MANUAL_COOLDOWN_TICKS;
56
    private final Minecraft client = Minecraft.getInstance();
57
    private final BooleanValue autoTakeoff =
58
            bool("auto_takeoff", SETTING_AUTO_TAKEOFF, true);
59
    private final EnumValue<ElytraRecastUtil.Mode> recastMode =
60
            enumSetting("recast_mode", SETTING_RECAST_MODE, ElytraRecastUtil.Mode.NORMAL, ElytraRecastUtil.Mode.values());
61
    private final BooleanValue recastAutoWalk =
62
            bool("recast_auto_walk", SETTING_RECAST_AUTO_WALK, true);
63
    private final BooleanValue recastAutoJump =
64
            bool("recast_auto_jump", SETTING_RECAST_AUTO_JUMP, true);
65
    private final BooleanValue recastAllowBroken =
66
            bool("recast_allow_broken", SETTING_RECAST_ALLOW_BROKEN, true);
67
    private final NumberValue<Integer> recastDelay =
68
            num("recast_delay", SETTING_RECAST_DELAY, 0, 0, 5);
69
    private ItemStack previousChest = ItemStack.EMPTY;
70
    private boolean swapLock = false;
71
    private boolean pendingFirework = false;
72
    private boolean queuedFireworkUse = false;
73
    private boolean queuedJump = false;
74
    private boolean queuedStartGlide = false;
75
    private boolean pendingAutoTakeoff = false;
76
    private boolean queuedAutoTakeoffRelease = false;
77
    private int queuedAutoTakeoffJumpTicks = 0;
78
    // Delay before START_FALL_FLYING during auto takeoff
79
    private int glideDelayTicks = 0;
80
81
    {
82
        setDefaultBind("LEFT_CTRL+R");
83
        addAction(ACTION_SWAP_ELYTRA, "R");
84
        addAction(ACTION_USE_FIREWORK, "F");
85
    }
86
87
    private boolean isRecastActive() {
88
        if (!isEnabled()) return false;
89
        return client != null && client.options != null && client.options.keyJump.isDown();
90
    }
91
92
    @Override
93
    public void onTick() {
94
        if (!isEnabled()) return;
95
        if (client.player == null || client.gameMode == null) return;
96
97
        LocalPlayer player = client.player;
98
99
        // ===== SWAP ELYTRA =====
100
        if (isActionPressedOnce(ACTION_SWAP_ELYTRA) && !swapLock) {
101
            swapLock = true;
102
            swapChest();
103
        }
104
        if (!isActionHeld(ACTION_SWAP_ELYTRA)) {
105
            swapLock = false;
106
        }
107
108
        if (glideDelayTicks > 0) {
109
            glideDelayTicks--;
110
        }
111
        if (pendingFirework && player.isFallFlying()) {
112
            pendingFirework = false;
113
            queueFireworkUse();
114
        }
115
        if (pendingAutoTakeoff) {
116
            tickAutoTakeoff(player);
117
        }
118
119
        // ===== FIREWORK / TAKEOFF =====
120
        if (isActionPressedOnce(ACTION_USE_FIREWORK)) {
121
            handleFireworkOrTakeoff(player);
122
        } else if (isActionHeld(ACTION_USE_FIREWORK) && player.isFallFlying() && canQueueManualFirework(player, false)) {
123
            queueFireworkUse();
124
        }
125
        if (isRecastActive()) {
126
            handleRecast(player);
127
        } else {
128
            ElytraRecastUtil.INSTANCE.reset(this);
129
        }
130
    }
131
132
    @Override
133
    public void onDisable() {
134
        if (client == null) return;
135
        InventorySwap.INSTANCE.releaseHotbar(this);
136
        queuedJump = false;
137
        queuedStartGlide = false;
138
        pendingAutoTakeoff = false;
139
        queuedAutoTakeoffRelease = false;
140
        queuedAutoTakeoffJumpTicks = 0;
141
        pendingFirework = false;
142
        queuedFireworkUse = false;
143
        glideDelayTicks = 0;
144
        ElytraRecastUtil.INSTANCE.reset(this);
145
    }
146
147
    private void handleRecast(LocalPlayer player) {
148
        ElytraRecastUtil.INSTANCE.request(
149
                this,
150
                player,
151
                recastMode.get(),
152
                recastAllowBroken.get(),
153
                !recastAutoJump.get(),
154
                recastAutoWalk.get(),
155
                recastDelay.get()
156
        );
157
        ElytraRecastUtil.INSTANCE.tick(this, player);
158
    }
159
160
    // =========================================================
161
    //           FIREWORK + AUTO TAKEOFF
162
    // =========================================================
163
    private void handleFireworkOrTakeoff(LocalPlayer player) {
164
165
        // Respect PVP firework cooldown first.
166
        if (CooldownsState.MANAGER.isInPvp()
167
                && CooldownsState.MANAGER.isCooling(Items.FIREWORK_ROCKET)) {
168
            Notifier.warning("Firework is on cooldown");
169
            return;
170
        }
171
172
        // Already gliding: queue the firework in sync phase. Holding the action keeps retrying,
173
        // but FireworkUseController and KillAura sync gates decide the actual shot frame.
174
        if (player.isFallFlying()) {
175
            pendingAutoTakeoff = false;
176
            queuedJump = false;
177
            queuedStartGlide = false;
178
            if (canQueueManualFirework(player, true)) {
179
                queueFireworkUse();
180
            }
181
            pendingFirework = false;
182
            return;
183
        }
184
185
        // AUTO TAKEOFF
186
        if (!autoTakeoff.get()) return;
187
        if (!player.getItemBySlot(EquipmentSlot.CHEST).is(Items.ELYTRA)) return;
188
        if (player.isPassenger()) return;
189
        if (pendingAutoTakeoff) {
190
            pendingFirework = true;
191
            return;
192
        }
193
194
        // Queue jump for sync phase; water and lava are allowed.
195
        pendingAutoTakeoff = true;
196
        queuedStartGlide = false;
197
        if (canJumpNow(player)) {
198
            queueJump();
199
            glideDelayTicks = player.onGround() ? 1 : 0;
200
        }
201
202
        // Firework will be used after glide starts.
203
        pendingFirework = true;
204
    }
205
206
    // =========================================================
207
    //                 DEFERRED FIREWORK USE
208
    // =========================================================
209
    private void queueFireworkUse() {
210
        queuedFireworkUse = true;
211
    }
212
213
    private boolean canQueueManualFirework(LocalPlayer player, boolean notifyCooldown) {
214
        if (player == null || !player.isFallFlying() || player.isUsingItem()) return false;
215
        if (CooldownsState.MANAGER.isInPvp()
216
                && CooldownsState.MANAGER.isCooling(Items.FIREWORK_ROCKET)) {
217
            if (notifyCooldown) {
218
                Notifier.warning("Firework is on cooldown");
219
            }
220
            return false;
221
        }
222
        return FireworkUseController.INSTANCE.canPassCooldown(MANUAL_FIREWORK_COOLDOWN_TICKS);
223
    }
224
225
    private void queueJump() {
226
        queuedJump = true;
227
    }
228
229
    private boolean canJumpNow(LocalPlayer player) {
230
        return player != null
231
                && !player.isPassenger()
232
                && !player.getAbilities().flying
233
                && (player.onGround() || player.isInWater() || player.isInLava());
234
    }
235
236
    private void clearAutoTakeoff() {
237
        pendingAutoTakeoff = false;
238
        queuedJump = false;
239
        queuedStartGlide = false;
240
        queuedAutoTakeoffRelease = false;
241
        queuedAutoTakeoffJumpTicks = 0;
242
        glideDelayTicks = 0;
243
    }
244
245
    private void tickAutoTakeoff(LocalPlayer player) {
246
        if (player == null) {
247
            clearAutoTakeoff();
248
            return;
249
        }
250
        if (player.isFallFlying()) {
251
            clearAutoTakeoff();
252
            return;
253
        }
254
        if (player.isPassenger() || !player.getItemBySlot(EquipmentSlot.CHEST).is(Items.ELYTRA)) {
255
            clearAutoTakeoff();
256
            pendingFirework = false;
257
            return;
258
        }
259
260
        if (player.isInWater() || player.isInLava()) {
261
            queueJump();
262
            queuedStartGlide = false;
263
            queuedAutoTakeoffRelease = false;
264
            glideDelayTicks = 0;
265
            return;
266
        }
267
268
        if (player.onGround()) {
269
            queueJump();
270
            queuedStartGlide = false;
271
            queuedAutoTakeoffRelease = false;
272
            if (glideDelayTicks <= 0) {
273
                glideDelayTicks = 1;
274
            }
275
            return;
276
        }
277
278
        if (glideDelayTicks > 0) {
279
            return;
280
        }
281
282
        if (player.getDeltaMovement().y > 0.0) {
283
            return;
284
        }
285
286
        if (queuedStartGlide || queuedAutoTakeoffRelease) {
287
            return;
288
        }
289
290
        queuedAutoTakeoffRelease = true;
291
        queuedStartGlide = true;
292
    }
293
294
    @EventHandler(priority = -1000)
295
    private void onMovementInput(MovementInputEvent event) {
296
        if (!isEnabled()) return;
297
298
        if (ElytraRecastUtil.INSTANCE.handleMovementInput(this, event)) {
299
            return;
300
        }
301
302
        if (queuedAutoTakeoffRelease) {
303
            event.setJump(false);
304
            queuedAutoTakeoffRelease = false;
305
            return;
306
        }
307
308
        if (queuedAutoTakeoffJumpTicks > 0) {
309
            event.setJump(true);
310
            queuedAutoTakeoffJumpTicks--;
311
            return;
312
        }
313
314
        if (!queuedJump) return;
315
316
        LocalPlayer player = client.player;
317
        if (player == null) {
318
            queuedJump = false;
319
            return;
320
        }
321
322
        if (canJumpNow(player)) {
323
            event.setJump(true);
324
        }
325
        queuedJump = false;
326
    }
327
328
    @EventHandler(priority = -1000)
329
    private void onSync(EventSync event) {
330
        if (!isEnabled()) return;
331
332
        LocalPlayer player = client.player;
333
        MultiPlayerGameMode manager = client.gameMode;
334
        if (player == null || manager == null) return;
335
336
        if (queuedStartGlide) {
337
            if (player.isFallFlying()) {
338
                queuedStartGlide = false;
339
                pendingAutoTakeoff = false;
340
            } else if (!player.onGround()
341
                    && !player.isInWater()
342
                    && !player.isInLava()
343
                    && player.getDeltaMovement().y <= 0.0) {
344
                queuedStartGlide = false;
345
                if (player.tryToStartFallFlying()) {
346
                    pendingAutoTakeoff = false;
347
                    queuedAutoTakeoffJumpTicks = 1;
348
                }
349
                if (player.isFallFlying() && client.getConnection() != null) {
350
                    client.getConnection().send(
351
                            new ServerboundPlayerCommandPacket(player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)
352
                    );
353
                } else {
354
                    glideDelayTicks = 1;
355
                }
356
            } else if (player.onGround() || player.isInWater() || player.isInLava()) {
357
                queuedStartGlide = false;
358
                queuedAutoTakeoffRelease = false;
359
            }
360
        }
361
362
        if (ElytraRecastUtil.INSTANCE.handleSync(this, event)) {
363
            return;
364
        }
365
366
        if (!queuedFireworkUse) return;
367
        queuedFireworkUse = false;
368
        FireworkUseController.INSTANCE.use(
369
                event.getYaw(),
370
                event.getPitch(),
371
                true,
372
                true,
373
                true,
374
                MANUAL_FIREWORK_COOLDOWN_TICKS,
375
                true
376
        );
377
    }
378
379
    // =========================================================
380
    //                     SWAP / UTILS
381
    // =========================================================
382
    private void swapChest() {
383
        LocalPlayer player = client.player;
384
        if (player == null) return;
385
386
        ItemStack equipped = getChestStack(player);
387
388
        if (!isElytra(equipped)) {
389
            int elytraSlot = findElytra(player);
390
            if (elytraSlot == -1) return;
391
            if (!equipped.isEmpty()) previousChest = equipped.copy();
392
            swapInventoryWithChest(player, elytraSlot);
393
            return;
394
        }
395
396
        int chestSlot = findPreviousOrAnyChest(player);
397
        if (chestSlot == -1) return;
398
        swapInventoryWithChest(player, chestSlot);
399
        previousChest = ItemStack.EMPTY;
400
    }
401
402
    private void swapInventoryWithChest(LocalPlayer player, int invSlot) {
403
        var handler = player.inventoryMenu;
404
        if (handler == null) return;
405
406
        int syncId = handler.containerId;
407
        int chestScreenSlot = 6;
408
        int invScreenSlot = InventorySwap.mapInventoryToScreenSlot(invSlot);
409
410
        client.execute(() -> InventorySwap.INSTANCE.swapScreenSlots(invScreenSlot, chestScreenSlot));
411
    }
412
413
    private ItemStack getChestStack(LocalPlayer player) {
414
        return player.getInventory()
415
                .getItem(EquipmentSlot.CHEST.getIndex(36));
416
    }
417
418
    private boolean isElytra(ItemStack stack) {
419
        return !stack.isEmpty() && stack.is(Items.ELYTRA);
420
    }
421
422
    private boolean isChestplate(ItemStack stack) {
423
        if (stack.isEmpty() || stack.is(Items.ELYTRA)) return false;
424
        Equippable eq = stack.get(DataComponents.EQUIPPABLE);
425
        return eq != null && eq.slot() == EquipmentSlot.CHEST;
426
    }
427
428
    private int findElytra(LocalPlayer player) {
429
        for (int i = 0; i < 36; i++) {
430
            if (player.getInventory().getItem(i).is(Items.ELYTRA)) return i;
431
        }
432
        return -1;
433
    }
434
435
    private int findPreviousOrAnyChest(LocalPlayer player) {
436
        if (!previousChest.isEmpty()) {
437
            for (int i = 0; i < 36; i++) {
438
                ItemStack s = player.getInventory().getItem(i);
439
                if (!s.isEmpty() && ItemStack.isSameItem(s, previousChest)) {
440
                    return i;
441
                }
442
            }
443
        }
444
445
        int best = findBestChestplate(player);
446
        if (best != -1) return best;
447
448
        for (int i = 0; i < 36; i++) {
449
            if (isChestplate(player.getInventory().getItem(i))) return i;
450
        }
451
452
        return -1;
453
    }
454
455
    private int findBestChestplate(LocalPlayer player) {
456
        int bestSlot = -1;
457
        int bestScore = -1;
458
459
        for (int i = 0; i < 36; i++) {
460
            ItemStack s = player.getInventory().getItem(i);
461
            int score = getChestDefenseScore(s);
462
            if (score > bestScore) {
463
                bestScore = score;
464
                bestSlot = i;
465
            }
466
        }
467
        return bestSlot;
468
    }
469
470
    private int getChestDefenseScore(ItemStack stack) {
471
        if (stack.isEmpty() || stack.is(Items.ELYTRA)) return 0;
472
473
        int base =
474
                stack.is(Items.LEATHER_CHESTPLATE) ? 3 :
475
                        stack.is(Items.COPPER_CHESTPLATE) ? 4 :
476
                                stack.is(Items.CHAINMAIL_CHESTPLATE) ? 5 :
477
                                        stack.is(Items.GOLDEN_CHESTPLATE) ? 5 :
478
                                                stack.is(Items.IRON_CHESTPLATE) ? 6 :
479
                                                        stack.is(Items.DIAMOND_CHESTPLATE) ? 8 :
480
                                                                stack.is(Items.NETHERITE_CHESTPLATE) ? 9 : 0;
481
482
        if (base == 0) return 0;
483
        return base * 10 + getProtectionLevel(stack) * 4;
484
    }
485
486
    private int getProtectionLevel(ItemStack stack) {
487
        Holder<Enchantment> prot = getProtectionEnchant();
488
        return prot == null ? 0 : EnchantmentHelper.getItemEnchantmentLevel(prot, stack);
489
    }
490
491
    private Holder<Enchantment> getProtectionEnchant() {
492
        if (client.level == null) return null;
493
        var registry = client.level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT);
494
        Enchantment ench = registry.getValue(Enchantments.PROTECTION);
495
        return ench == null ? null : registry.wrapAsHolder(ench);
496
    }
497
498
}
499