elytra-fly module

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

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.

Meteor ClientMovementsrc/main/java/meteordevelopment/meteorclient/systems/modules/movement/elytrafly/ElytraFly.javaJava · 587 lines · 23.5 KB

Gives you more control over your elytra.

Settingsmodeauto-take-offfall-multiplierhorizontal-speedvertical-speedaccelerationacceleration-stepacceleration-startstop-in-waterno-unloaded-chunksauto-hoverno-crashcrash-look-aheadinsta-droppitch40-lower-boundspitch40-upper-boundspitch40-rotate-speed-uppitch40-rotate-speed-downauto-jumpyaw-lockyawpitch-lockpitchrestartrestart-delaysprint-constantlymanual-takeoffelytra-replacereplace-durabilitychest-swapreplenish-fireworksreplenish-slotauto-pilotuse-fireworksfirework-delayminimum-height
ElytraFly.javaJava · Minecraft 26.2 · 587 lines · 23.5 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.movement.elytrafly;
7
8
import meteordevelopment.meteorclient.MeteorClient;
9
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
10
import meteordevelopment.meteorclient.events.packets.PacketEvent;
11
import meteordevelopment.meteorclient.events.world.TickEvent;
12
import meteordevelopment.meteorclient.mixin.BlockBehaviourAccessor;
13
import meteordevelopment.meteorclient.mixininterface.IVec3;
14
import meteordevelopment.meteorclient.settings.*;
15
import meteordevelopment.meteorclient.systems.modules.Categories;
16
import meteordevelopment.meteorclient.systems.modules.Module;
17
import meteordevelopment.meteorclient.systems.modules.Modules;
18
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Bounce;
19
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Packet;
20
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Pitch40;
21
import meteordevelopment.meteorclient.systems.modules.movement.elytrafly.modes.Vanilla;
22
import meteordevelopment.meteorclient.systems.modules.player.ChestSwap;
23
import meteordevelopment.meteorclient.systems.modules.player.Rotation;
24
import meteordevelopment.meteorclient.systems.modules.render.Freecam;
25
import meteordevelopment.orbit.EventHandler;
26
import net.minecraft.core.component.DataComponents;
27
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
28
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
29
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
30
import net.minecraft.util.Mth;
31
import net.minecraft.world.entity.EquipmentSlot;
32
import net.minecraft.world.item.Items;
33
import net.minecraft.world.level.ClipContext;
34
import net.minecraft.world.level.block.Block;
35
import net.minecraft.world.level.block.state.BlockState;
36
import net.minecraft.world.phys.BlockHitResult;
37
import net.minecraft.world.phys.HitResult;
38
import net.minecraft.world.phys.Vec3;
39
40
public class ElytraFly extends Module {
41
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
42
    private final SettingGroup sgInventory = settings.createGroup("Inventory");
43
    private final SettingGroup sgAutopilot = settings.createGroup("Autopilot");
44
45
    // General
46
47
    public final Setting<ElytraFlightModes> flightMode = sgGeneral.add(new EnumSetting.Builder<ElytraFlightModes>()
48
        .name("mode")
49
        .description("The mode of flying.")
50
        .defaultValue(ElytraFlightModes.Vanilla)
51
        .onModuleActivated(flightModesSetting -> onModeChanged(flightModesSetting.get()))
52
        .onChanged(this::onModeChanged)
53
        .build()
54
    );
55
56
    public final Setting<Boolean> autoTakeOff = sgGeneral.add(new BoolSetting.Builder()
57
        .name("auto-take-off")
58
        .description("Automatically takes off when you hold jump without needing to double jump.")
59
        .defaultValue(false)
60
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
61
        .build()
62
    );
63
64
    public final Setting<Double> fallMultiplier = sgGeneral.add(new DoubleSetting.Builder()
65
        .name("fall-multiplier")
66
        .description("Controls how fast will you go down naturally.")
67
        .defaultValue(0.01)
68
        .min(0)
69
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
70
        .build()
71
    );
72
73
    public final Setting<Double> horizontalSpeed = sgGeneral.add(new DoubleSetting.Builder()
74
        .name("horizontal-speed")
75
        .description("How fast you go forward and backward.")
76
        .defaultValue(1)
77
        .min(0)
78
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
79
        .build()
80
    );
81
82
    public final Setting<Double> verticalSpeed = sgGeneral.add(new DoubleSetting.Builder()
83
        .name("vertical-speed")
84
        .description("How fast you go up and down.")
85
        .defaultValue(1)
86
        .min(0)
87
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
88
        .build()
89
    );
90
91
    public final Setting<Boolean> acceleration = sgGeneral.add(new BoolSetting.Builder()
92
        .name("acceleration")
93
        .defaultValue(false)
94
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
95
        .build()
96
    );
97
98
    public final Setting<Double> accelerationStep = sgGeneral.add(new DoubleSetting.Builder()
99
        .name("acceleration-step")
100
        .min(0.1)
101
        .max(5)
102
        .defaultValue(1)
103
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && acceleration.get() && flightMode.get() != ElytraFlightModes.Bounce)
104
        .build()
105
    );
106
107
    public final Setting<Double> accelerationMin = sgGeneral.add(new DoubleSetting.Builder()
108
        .name("acceleration-start")
109
        .min(0.1)
110
        .defaultValue(0)
111
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && acceleration.get() && flightMode.get() != ElytraFlightModes.Bounce)
112
        .build()
113
    );
114
115
    public final Setting<Boolean> stopInWater = sgGeneral.add(new BoolSetting.Builder()
116
        .name("stop-in-water")
117
        .description("Stops flying in water.")
118
        .defaultValue(true)
119
        .visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
120
        .build()
121
    );
122
123
    public final Setting<Boolean> dontGoIntoUnloadedChunks = sgGeneral.add(new BoolSetting.Builder()
124
        .name("no-unloaded-chunks")
125
        .description("Stops you from going into unloaded chunks.")
126
        .defaultValue(true)
127
        .build()
128
    );
129
130
    public final Setting<Boolean> autoHover = sgGeneral.add(new BoolSetting.Builder()
131
        .name("auto-hover")
132
        .description("Automatically hover .3 blocks off ground when holding shift.")
133
        .defaultValue(false)
134
        .visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
135
        .build()
136
    );
137
138
    public final Setting<Boolean> noCrash = sgGeneral.add(new BoolSetting.Builder()
139
        .name("no-crash")
140
        .description("Stops you from going into walls.")
141
        .defaultValue(false)
142
        .visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
143
        .build()
144
    );
145
146
    public final Setting<Integer> crashLookAhead = sgGeneral.add(new IntSetting.Builder()
147
        .name("crash-look-ahead")
148
        .description("Distance to look ahead when flying.")
149
        .defaultValue(5)
150
        .range(1, 15)
151
        .sliderMin(1)
152
        .visible(() -> noCrash.get() && flightMode.get() != ElytraFlightModes.Bounce)
153
        .build()
154
    );
155
156
    private final Setting<Boolean> instaDrop = sgGeneral.add(new BoolSetting.Builder()
157
        .name("insta-drop")
158
        .description("Makes you drop out of flight instantly.")
159
        .defaultValue(false)
160
        .visible(() -> flightMode.get() != ElytraFlightModes.Bounce)
161
        .build()
162
    );
163
164
    public final Setting<Double> pitch40lowerBounds = sgGeneral.add(new DoubleSetting.Builder()
165
        .name("pitch40-lower-bounds")
166
        .description(
167
            "The bottom height boundary for pitch40. You must be at least 40 blocks above this boundary when starting the module.\n" +
168
                "After descending below this boundary you will start pitching upwards."
169
        )
170
        .defaultValue(180)
171
        .min(-128)
172
        .sliderMax(360)
173
        .visible(() -> flightMode.get() == ElytraFlightModes.Pitch40)
174
        .build()
175
    );
176
177
    public final Setting<Double> pitch40upperBounds = sgGeneral.add(new DoubleSetting.Builder()
178
        .name("pitch40-upper-bounds")
179
        .description(
180
            "The upper height boundary for pitch40. You must be above this boundary when starting the module.\n" +
181
                "When ascending above this boundary, if you are not already, you will start pitching downwards."
182
        )
183
        .defaultValue(220)
184
        .min(-128)
185
        .sliderMax(360)
186
        .visible(() -> flightMode.get() == ElytraFlightModes.Pitch40)
187
        .build()
188
    );
189
190
    public final Setting<Double> pitch40rotationSpeedUp = sgGeneral.add(new DoubleSetting.Builder()
191
        .name("pitch40-rotate-speed-up")
192
        .description("The speed for pitch rotation upwards (degrees per tick).")
193
        .defaultValue(5.45)
194
        .min(1)
195
        .sliderMax(20)
196
        .visible(() -> flightMode.get() == ElytraFlightModes.Pitch40)
197
        .build()
198
    );
199
200
    public final Setting<Double> pitch40rotationSpeedDown = sgGeneral.add(new DoubleSetting.Builder()
201
        .name("pitch40-rotate-speed-down")
202
        .description("The speed for pitch rotation downwards (degrees per tick).")
203
        .defaultValue(0.90)
204
        .min(0.5)
205
        .sliderMax(2)
206
        .visible(() -> flightMode.get() == ElytraFlightModes.Pitch40)
207
        .build()
208
    );
209
210
    public final Setting<Boolean> autoJump = sgGeneral.add(new BoolSetting.Builder()
211
        .name("auto-jump")
212
        .description("Automatically jumps for you.")
213
        .defaultValue(true)
214
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
215
        .build()
216
    );
217
218
    public final Setting<Rotation.LockMode> yawLockMode = sgGeneral.add(new EnumSetting.Builder<Rotation.LockMode>()
219
        .name("yaw-lock")
220
        .description("Whether to enable yaw lock or not")
221
        .defaultValue(Rotation.LockMode.Smart)
222
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
223
        .build()
224
    );
225
226
    public final Setting<Double> yaw = sgGeneral.add(new DoubleSetting.Builder()
227
        .name("yaw")
228
        .description("The yaw angle to look at when using simple rotation lock in bounce mode.")
229
        .defaultValue(0)
230
        .range(0, 360)
231
        .sliderRange(0, 360)
232
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce && yawLockMode.get() == Rotation.LockMode.Simple)
233
        .build()
234
    );
235
236
    public final Setting<Boolean> lockPitch = sgGeneral.add(new BoolSetting.Builder()
237
        .name("pitch-lock")
238
        .description("Whether to lock your pitch angle.")
239
        .defaultValue(true)
240
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
241
        .build()
242
    );
243
244
    public final Setting<Double> pitch = sgGeneral.add(new DoubleSetting.Builder()
245
        .name("pitch")
246
        .description("The pitch angle to look at when using the bounce mode.")
247
        .defaultValue(85)
248
        .range(0, 90)
249
        .sliderRange(0, 90)
250
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce && lockPitch.get())
251
        .build()
252
    );
253
254
    public final Setting<Boolean> restart = sgGeneral.add(new BoolSetting.Builder()
255
        .name("restart")
256
        .description("Restarts flying with the elytra when rubberbanding.")
257
        .defaultValue(true)
258
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
259
        .build()
260
    );
261
262
    public final Setting<Integer> restartDelay = sgGeneral.add(new IntSetting.Builder()
263
        .name("restart-delay")
264
        .description("How many ticks to wait before restarting the elytra again after rubberbanding.")
265
        .defaultValue(7)
266
        .min(0)
267
        .sliderRange(0, 20)
268
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce && restart.get())
269
        .build()
270
    );
271
272
    public final Setting<Boolean> sprint = sgGeneral.add(new BoolSetting.Builder()
273
        .name("sprint-constantly")
274
        .description("Sprints all the time. If turned off, it will only sprint when the player is touching the ground.")
275
        .defaultValue(true)
276
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
277
        .build()
278
    );
279
280
    public final Setting<Boolean> manualTakeoff = sgGeneral.add(new BoolSetting.Builder()
281
        .name("manual-takeoff")
282
        .description("Does not automatically take off.")
283
        .defaultValue(false)
284
        .visible(() -> flightMode.get() == ElytraFlightModes.Bounce)
285
        .build()
286
    );
287
288
    // Inventory
289
290
    public final Setting<Boolean> replace = sgInventory.add(new BoolSetting.Builder()
291
        .name("elytra-replace")
292
        .description("Replaces broken elytra with a new elytra.")
293
        .defaultValue(false)
294
        .build()
295
    );
296
297
    public final Setting<Integer> replaceDurability = sgInventory.add(new IntSetting.Builder()
298
        .name("replace-durability")
299
        .description("The durability threshold your elytra will be replaced at.")
300
        .defaultValue(2)
301
        .sliderRange(1, 500)
302
        .visible(replace::get)
303
        .build()
304
    );
305
306
    public final Setting<ChestSwapMode> chestSwap = sgInventory.add(new EnumSetting.Builder<ChestSwapMode>()
307
        .name("chest-swap")
308
        .description("Enables ChestSwap when toggling this module.")
309
        .defaultValue(ChestSwapMode.Never)
310
        .build()
311
    );
312
313
    public final Setting<Boolean> autoReplenish = sgInventory.add(new BoolSetting.Builder()
314
        .name("replenish-fireworks")
315
        .description("Moves fireworks into a selected hotbar slot.")
316
        .defaultValue(false)
317
        .build()
318
    );
319
320
    public final Setting<Integer> replenishSlot = sgInventory.add(new IntSetting.Builder()
321
        .name("replenish-slot")
322
        .description("The slot auto move moves fireworks to.")
323
        .defaultValue(9)
324
        .range(1, 9)
325
        .sliderRange(1, 9)
326
        .visible(autoReplenish::get)
327
        .build()
328
    );
329
330
    // Autopilot
331
332
    public final Setting<Boolean> autoPilot = sgAutopilot.add(new BoolSetting.Builder()
333
        .name("auto-pilot")
334
        .description("Moves forward while elytra flying.")
335
        .defaultValue(false)
336
        .visible(() -> flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
337
        .build()
338
    );
339
340
    public final Setting<Boolean> useFireworks = sgAutopilot.add(new BoolSetting.Builder()
341
        .name("use-fireworks")
342
        .description("Uses firework rockets every second of your choice.")
343
        .defaultValue(false)
344
        .visible(() -> autoPilot.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
345
        .build()
346
    );
347
348
    public final Setting<Double> autoPilotFireworkDelay = sgAutopilot.add(new DoubleSetting.Builder()
349
        .name("firework-delay")
350
        .description("The delay in seconds in between using fireworks if \"Use Fireworks\" is enabled.")
351
        .min(1)
352
        .defaultValue(8)
353
        .sliderMax(20)
354
        .visible(() -> useFireworks.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
355
        .build()
356
    );
357
358
    public final Setting<Double> autoPilotMinimumHeight = sgAutopilot.add(new DoubleSetting.Builder()
359
        .name("minimum-height")
360
        .description("The minimum height for autopilot.")
361
        .defaultValue(120)
362
        .min(-128)
363
        .sliderMax(260)
364
        .visible(() -> autoPilot.get() && flightMode.get() != ElytraFlightModes.Pitch40 && flightMode.get() != ElytraFlightModes.Bounce)
365
        .build()
366
    );
367
368
    private ElytraFlightMode currentMode = new Vanilla();
369
370
    public ElytraFly() {
371
        super(Categories.Movement, "elytra-fly", "Gives you more control over your elytra.");
372
    }
373
374
    @Override
375
    public void onActivate() {
376
        currentMode.onActivate();
377
        if ((chestSwap.get() == ChestSwapMode.Always || chestSwap.get() == ChestSwapMode.WaitForGround)
378
            && mc.player.getItemBySlot(EquipmentSlot.CHEST).getItem() != Items.ELYTRA && isActive()) {
379
            Modules.get().get(ChestSwap.class).swap();
380
        }
381
    }
382
383
    @Override
384
    public void onDeactivate() {
385
        if (autoPilot.get()) mc.options.keyUp.setDown(false);
386
387
        if (chestSwap.get() == ChestSwapMode.Always && mc.player.getItemBySlot(EquipmentSlot.CHEST).getItem() == Items.ELYTRA) {
388
            Modules.get().get(ChestSwap.class).swap();
389
        } else if (chestSwap.get() == ChestSwapMode.WaitForGround) {
390
            enableGroundListener();
391
        }
392
393
        if (mc.player.isFallFlying() && instaDrop.get()) {
394
            enableInstaDropListener();
395
        }
396
397
        currentMode.onDeactivate();
398
    }
399
400
    @EventHandler
401
    private void onPlayerMove(PlayerMoveEvent event) {
402
        if (!(mc.player.getItemBySlot(EquipmentSlot.CHEST).has(DataComponents.GLIDER))) return;
403
404
        currentMode.autoTakeoff();
405
406
        if (mc.player.isFallFlying()) {
407
408
            if (flightMode.get() != ElytraFlightModes.Bounce) {
409
                currentMode.velX = 0;
410
                currentMode.velY = event.movement.y;
411
                currentMode.velZ = 0;
412
                currentMode.forward = Vec3.directionFromRotation(0, mc.player.getYRot()).scale(0.1);
413
                currentMode.right = Vec3.directionFromRotation(0, mc.player.getYRot() + 90).scale(0.1);
414
415
                // Handle stopInWater
416
                if (mc.player.isInWater() && stopInWater.get()) {
417
                    mc.getConnection().send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
418
                    return;
419
                }
420
421
                currentMode.handleFallMultiplier();
422
                currentMode.handleAutopilot();
423
424
                currentMode.handleAcceleration();
425
                currentMode.handleHorizontalSpeed(event);
426
                currentMode.handleVerticalSpeed(event);
427
            }
428
429
            int chunkX = (int) ((mc.player.getX() + currentMode.velX) / 16);
430
            int chunkZ = (int) ((mc.player.getZ() + currentMode.velZ) / 16);
431
            if (dontGoIntoUnloadedChunks.get()) {
432
                if (mc.level.getChunkSource().hasChunk(chunkX, chunkZ)) {
433
                    if (flightMode.get() != ElytraFlightModes.Bounce)
434
                        ((IVec3) event.movement).meteor$set(currentMode.velX, currentMode.velY, currentMode.velZ);
435
                } else {
436
                    currentMode.zeroAcceleration();
437
                    ((IVec3) event.movement).meteor$set(0, currentMode.velY, 0);
438
                }
439
            } else if (flightMode.get() != ElytraFlightModes.Bounce)
440
                ((IVec3) event.movement).meteor$set(currentMode.velX, currentMode.velY, currentMode.velZ);
441
442
            if (flightMode.get() != ElytraFlightModes.Bounce) currentMode.onPlayerMove();
443
        } else {
444
            if (currentMode.lastForwardPressed && flightMode.get() != ElytraFlightModes.Bounce) {
445
                mc.options.keyUp.setDown(false);
446
                currentMode.lastForwardPressed = false;
447
            }
448
        }
449
450
        if (noCrash.get() && mc.player.isFallFlying() && flightMode.get() != ElytraFlightModes.Bounce) {
451
            Vec3 lookAheadPos = mc.player.position().add(mc.player.getDeltaMovement().normalize().scale(crashLookAhead.get()));
452
            ClipContext clipContext = new ClipContext(mc.player.position(), new Vec3(lookAheadPos.x(), mc.player.getY(), lookAheadPos.z()), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, mc.player);
453
            BlockHitResult hitResult = mc.level.clip(clipContext);
454
            if (hitResult != null && hitResult.getType() == HitResult.Type.BLOCK) {
455
                ((IVec3) event.movement).meteor$set(0, currentMode.velY, 0);
456
            }
457
        }
458
459
        if (autoHover.get() && mc.player.input.keyPresses.shift() && !Modules.get().get(Freecam.class).isActive() && mc.player.isFallFlying() && flightMode.get() != ElytraFlightModes.Bounce) {
460
            BlockState underState = mc.level.getBlockState(mc.player.blockPosition().below());
461
            Block under = underState.getBlock();
462
            BlockState under2State = mc.level.getBlockState(mc.player.blockPosition().below().below());
463
            Block under2 = under2State.getBlock();
464
465
            final boolean underCollidable = ((BlockBehaviourAccessor) under).meteor$isHasCollision() || !underState.getFluidState().isEmpty();
466
            final boolean under2Collidable = ((BlockBehaviourAccessor) under2).meteor$isHasCollision() || !under2State.getFluidState().isEmpty();
467
468
            if (!underCollidable && under2Collidable) {
469
                ((IVec3) event.movement).meteor$set(event.movement.x, -0.1f, event.movement.z);
470
471
                mc.player.setXRot(Mth.clamp(mc.player.getXRot(0), -50.f, 20.f)); // clamp between -50 and 20 (>= 30 will pop you off, but lag makes that threshold lower)
472
            }
473
474
            if (underCollidable) {
475
                ((IVec3) event.movement).meteor$set(event.movement.x, -0.03f, event.movement.z);
476
477
                mc.player.setXRot(Mth.clamp(mc.player.getXRot(0), -50.f, 20.f));
478
479
                if (mc.player.position().y <= mc.player.blockPosition().below().getY() + 1.34f) {
480
                    ((IVec3) event.movement).meteor$set(event.movement.x, 0, event.movement.z);
481
                    mc.player.setShiftKeyDown(false);
482
                }
483
            }
484
        }
485
    }
486
487
    public boolean canPacketEfly() {
488
        return isActive() && flightMode.get() == ElytraFlightModes.Packet && mc.player.getItemBySlot(EquipmentSlot.CHEST).has(DataComponents.GLIDER) && !mc.player.onGround();
489
    }
490
491
    @EventHandler
492
    private void onTick(TickEvent.Post event) {
493
        currentMode.onTick();
494
    }
495
496
    @EventHandler
497
    private void onPreTick(TickEvent.Pre event) {
498
        currentMode.onPreTick();
499
    }
500
501
    @EventHandler
502
    private void onPacketSend(PacketEvent.Send event) {
503
        currentMode.onPacketSend(event);
504
    }
505
506
    @EventHandler
507
    private void onPacketReceive(PacketEvent.Receive event) {
508
        if (event.packet instanceof ClientboundPlayerPositionPacket) currentMode.zeroAcceleration();
509
510
        currentMode.onPacketReceive(event);
511
    }
512
513
    private void onModeChanged(ElytraFlightModes mode) {
514
        switch (mode) {
515
            case Vanilla -> currentMode = new Vanilla();
516
            case Packet -> currentMode = new Packet();
517
            case Pitch40 -> {
518
                currentMode = new Pitch40();
519
                autoPilot.set(false); // Pitch 40 is an autopilot of its own
520
            }
521
            case Bounce -> currentMode = new Bounce();
522
        }
523
    }
524
525
    //Ground
526
    private class StaticGroundListener {
527
        @EventHandler
528
        private void chestSwapGroundListener(PlayerMoveEvent event) {
529
            if (mc.player != null && mc.player.onGround()) {
530
                if (mc.player.getItemBySlot(EquipmentSlot.CHEST).getItem() == Items.ELYTRA) {
531
                    Modules.get().get(ChestSwap.class).swap();
532
                    disableGroundListener();
533
                }
534
            }
535
        }
536
    }
537
538
    private final StaticGroundListener staticGroundListener = new StaticGroundListener();
539
540
    protected void enableGroundListener() {
541
        MeteorClient.EVENT_BUS.subscribe(staticGroundListener);
542
    }
543
544
    protected void disableGroundListener() {
545
        MeteorClient.EVENT_BUS.unsubscribe(staticGroundListener);
546
    }
547
548
    //Drop
549
    private class StaticInstaDropListener {
550
        @EventHandler
551
        private void onInstadropTick(TickEvent.Post event) {
552
            if (mc.player != null && mc.player.isFallFlying()) {
553
                mc.player.setDeltaMovement(0, 0, 0);
554
                mc.player.connection.send(new ServerboundMovePlayerPacket.StatusOnly(true, mc.player.horizontalCollision));
555
            } else {
556
                disableInstaDropListener();
557
            }
558
        }
559
    }
560
561
    private final StaticInstaDropListener staticInstadropListener = new StaticInstaDropListener();
562
563
    protected void enableInstaDropListener() {
564
        MeteorClient.EVENT_BUS.subscribe(staticInstadropListener);
565
    }
566
567
    protected void disableInstaDropListener() {
568
        MeteorClient.EVENT_BUS.unsubscribe(staticInstadropListener);
569
    }
570
571
    @Override
572
    public String getInfoString() {
573
        return currentMode.getHudString();
574
    }
575
576
    public enum ChestSwapMode {
577
        Always,
578
        Never,
579
        WaitForGround
580
    }
581
582
    public enum AutoPilotMode {
583
        Vanilla,
584
        Pitch40
585
    }
586
}
587