Elytra+ module

Elytra+: Minecraft 26.3 cheat module, full source for every implementation (1 client: MelaHack (ThunderHack fork)).

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.

MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/ElytraPlus.javaJava · 934 lines · 42.8 KB

Allows you fly on elytra without fireworks.

SettingsModeDisablerDelay2b2tOnlySpaceStopOnGroundInfDurabilityVerticalNCPStrictAntiKickXZSpeedYSpeedFireSlotAccelerationAccelerateFactorFireDelayGrimRotateFireWorkExtenderGroundSafeKeepFlyingDisableOnFlagAllowFireSwapBowBombBombKeyInstantFlyCruiseControlFactorUpSpeedGlideStopMotionMinUpSpeedForceHeightHeightDownSpeedSpeedLimitMaxSpeedRedeployIntervalRedeployTimeoutRedeployDelayInfiniteMaxSpeed
ElytraPlus.javaJava · Minecraft 26.2 · 934 lines · 42.8 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import com.mojang.blaze3d.platform.InputConstants;
4
import com.mojang.blaze3d.vertex.BufferBuilder;
5
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
6
import com.mojang.blaze3d.vertex.PoseStack;
7
import thunder.hack.utility.render.Tesselator;
8
import com.mojang.blaze3d.vertex.VertexFormat;
9
10
import thunder.hack.utility.render.compat.RenderSystem;
11
import meteordevelopment.orbit.EventHandler;
12
import meteordevelopment.orbit.EventPriority;
13
import net.minecraft.ChatFormatting;
14
import thunder.hack.utility.render.ShaderProgramKeys;
15
import net.minecraft.client.gui.GuiGraphicsExtractor;
16
import thunder.hack.utility.render.BufferRenderer;
17
import net.minecraft.core.BlockPos;
18
import net.minecraft.network.protocol.common.ClientboundPingPacket;
19
import net.minecraft.network.protocol.game.*;
20
import net.minecraft.network.syncher.SynchedEntityData;
21
import net.minecraft.sounds.SoundEvents;
22
import net.minecraft.sounds.SoundSource;
23
import net.minecraft.util.Mth;
24
import net.minecraft.world.InteractionHand;
25
import net.minecraft.world.entity.EquipmentSlot;
26
import net.minecraft.world.entity.LivingEntity;
27
import net.minecraft.world.inventory.ContainerInput;
28
import net.minecraft.world.item.Item;
29
import net.minecraft.world.item.ItemStack;
30
import net.minecraft.world.item.Items;
31
import net.minecraft.world.level.block.LiquidBlock;
32
import net.minecraft.world.phys.Vec3;
33
import thunder.hack.ThunderHack;
34
import thunder.hack.core.Managers;
35
import thunder.hack.events.impl.*;
36
import thunder.hack.gui.font.FontRenderers;
37
import thunder.hack.gui.notification.Notification;
38
import thunder.hack.features.modules.Module;
39
import thunder.hack.features.modules.client.HudEditor;
40
import thunder.hack.features.modules.combat.Criticals;
41
import thunder.hack.setting.Setting;
42
import thunder.hack.setting.impl.Bind;
43
import thunder.hack.setting.impl.BooleanSettingGroup;
44
import thunder.hack.utility.math.MathUtility;
45
import thunder.hack.utility.player.InventoryUtility;
46
import thunder.hack.utility.player.MovementUtility;
47
import thunder.hack.utility.player.PlayerUtility;
48
import thunder.hack.utility.render.Render2DEngine;
49
import thunder.hack.utility.render.Render3DEngine;
50
51
import java.util.List;
52
53
import static thunder.hack.features.modules.client.ClientSettings.isRu;
54
import static thunder.hack.features.modules.player.ElytraSwap.getChestPlateSlot;
55
56
public class ElytraPlus extends Module {
57
    public ElytraPlus() {
58
        super("Elytra+", Category.MOVEMENT);
59
    }
60
61
    public final Setting<Mode> mode = new Setting<>("Mode", Mode.FireWork);
62
    private final Setting<Integer> disablerDelay = new Setting<>("DisablerDelay", 1, 0, 10, v -> mode.is(Mode.SunriseOld));
63
    private final Setting<Boolean> twoBee = new Setting<>("2b2t", false, v -> mode.is(Mode.Boost));
64
    private final Setting<Boolean> onlySpace = new Setting<>("OnlySpace", true, v -> mode.is(Mode.Boost) && twoBee.getValue());
65
    private final Setting<Boolean> stopOnGround = new Setting<>("StopOnGround", false, v -> mode.is(Mode.Packet));
66
    private final Setting<Boolean> infDurability = new Setting<>("InfDurability", true, v -> mode.is(Mode.Packet));
67
    private final Setting<Boolean> vertical = new Setting<>("Vertical", false, v -> mode.is(Mode.Packet));
68
    private final Setting<NCPStrict> ncpStrict = new Setting<>("NCPStrict", NCPStrict.Off, v -> mode.is(Mode.Packet));
69
    private final Setting<AntiKick> antiKick = new Setting<>("AntiKick", AntiKick.Jitter, v -> mode.is(Mode.FireWork) || mode.is(Mode.SunriseOld));
70
    private final Setting<Float> xzSpeed = new Setting<>("XZSpeed", 1.55f, 0.1f, 10f, v -> !mode.is(Mode.Boost) && mode.getValue() != Mode.Pitch40Infinite);
71
    private final Setting<Float> ySpeed = new Setting<>("YSpeed", 0.47f, 0f, 2f, v -> mode.is(Mode.FireWork) || mode.getValue() == Mode.SunriseOld || (mode.is(Mode.Packet) && vertical.getValue()));
72
    private final Setting<Integer> fireSlot = new Setting<>("FireSlot", 1, 1, 9, v -> mode.is(Mode.FireWork));
73
    private final Setting<BooleanSettingGroup> accelerate = new Setting<>("Acceleration", new BooleanSettingGroup(false), v -> mode.is(Mode.Control) || mode.is(Mode.Packet));
74
    private final Setting<Float> accelerateFactor = new Setting<>("AccelerateFactor", 9f, 0f, 100f, v -> mode.is(Mode.Control) || mode.is(Mode.Packet)).addToGroup(accelerate);
75
    private final Setting<Float> fireDelay = new Setting<>("FireDelay", 1.5f, 0f, 1.5f, v -> mode.is(Mode.FireWork));
76
    private final Setting<BooleanSettingGroup> grim = new Setting<>("Grim", new BooleanSettingGroup(false), v -> mode.is(Mode.FireWork));
77
    private final Setting<Boolean> rotate = new Setting<>("Rotate", true, v -> mode.is(Mode.FireWork)).addToGroup(grim);
78
    private final Setting<Boolean> fireWorkExtender = new Setting<>("FireWorkExtender", true, v -> mode.is(Mode.FireWork)).addToGroup(grim);
79
    private final Setting<Boolean> stayMad = new Setting<>("GroundSafe", false, v -> mode.is(Mode.FireWork));
80
    private final Setting<Boolean> keepFlying = new Setting<>("KeepFlying", false, v -> mode.is(Mode.FireWork));
81
    private final Setting<Boolean> disableOnFlag = new Setting<>("DisableOnFlag", false, v -> mode.is(Mode.FireWork));
82
    private final Setting<Boolean> allowFireSwap = new Setting<>("AllowFireSwap", false, v -> mode.is(Mode.FireWork));
83
    private final Setting<Boolean> bowBomb = new Setting<>("BowBomb", false, v -> mode.is(Mode.FireWork) || mode.getValue() == Mode.SunriseOld);
84
    private final Setting<Bind> bombKey = new Setting<>("BombKey", new Bind(-1, false, false), v -> mode.getValue() == Mode.SunriseOld);
85
    private final Setting<Boolean> instantFly = new Setting<>("InstantFly", true, v -> ((mode.is(Mode.Boost) && !twoBee.getValue()) || mode.is(Mode.Control)));
86
    private final Setting<Boolean> cruiseControl = new Setting<>("CruiseControl", false, v -> mode.is(Mode.Boost));
87
    private final Setting<Float> factor = new Setting<>("Factor", 1.5f, 0.1f, 50.0f, v -> mode.is(Mode.Boost));
88
    private final Setting<Float> upSpeed = new Setting<>("UpSpeed", 1.0f, 0.01f, 5.0f, v -> ((mode.is(Mode.Boost) && !twoBee.getValue()) || mode.is(Mode.Control)));
89
    private final Setting<Float> downFactor = new Setting<>("Glide", 1.0f, 0.0f, 2.0f, v -> ((mode.is(Mode.Boost) && !twoBee.getValue()) || mode.is(Mode.Control)));
90
    private final Setting<Boolean> stopMotion = new Setting<>("StopMotion", true, v -> mode.is(Mode.Boost) && !twoBee.getValue());
91
    private final Setting<Float> minUpSpeed = new Setting<>("MinUpSpeed", 0.5f, 0.1f, 5.0f, v -> mode.is(Mode.Boost) && cruiseControl.getValue());
92
    private final Setting<Boolean> forceHeight = new Setting<>("ForceHeight", false, v -> (mode.is(Mode.Boost) && cruiseControl.getValue()));
93
    private final Setting<Integer> manualHeight = new Setting<>("Height", 121, 1, 256, v -> mode.is(Mode.Boost) && forceHeight.getValue());
94
    private final Setting<Float> sneakDownSpeed = new Setting<>("DownSpeed", 1.0f, 0.01f, 5.0f, v -> mode.is(Mode.Control));
95
    private final Setting<Boolean> speedLimit = new Setting<>("SpeedLimit", true, v -> mode.is(Mode.Boost));
96
    private final Setting<Float> maxSpeed = new Setting<>("MaxSpeed", 2.5f, 0.1f, 10.0f, v -> mode.is(Mode.Boost));
97
    private final Setting<Float> redeployInterval = new Setting<>("RedeployInterval", 1F, 0.1F, 5F, v -> mode.is(Mode.Boost) && !twoBee.getValue());
98
    private final Setting<Float> redeployTimeOut = new Setting<>("RedeployTimeout", 5f, 0.1f, 20f, v -> mode.is(Mode.Boost) && !twoBee.getValue());
99
    private final Setting<Float> redeployDelay = new Setting<>("RedeployDelay", 0.5F, 0.1F, 1F, v -> mode.is(Mode.Boost) && !twoBee.getValue());
100
    private final Setting<Float> infiniteMaxSpeed = new Setting<>("InfiniteMaxSpeed", 150f, 50f, 170f, v -> mode.getValue() == Mode.Pitch40Infinite);
101
    private final Setting<Float> infiniteMinSpeed = new Setting<>("InfiniteMinSpeed", 25f, 10f, 70f, v -> mode.getValue() == Mode.Pitch40Infinite);
102
    private final Setting<Integer> infiniteMaxHeight = new Setting<>("InfiniteMaxHeight", 200, 50, 360, v -> mode.getValue() == Mode.Pitch40Infinite);
103
104
    public enum Mode {FireWork, SunriseOld, Boost, Control, Pitch40Infinite, SunriseNew, Packet}
105
106
    public enum AntiKick {Off, Jitter, Glide}
107
108
    public enum NCPStrict {Off, Old, New, Motion}
109
110
    private final thunder.hack.utility.Timer startTimer = new thunder.hack.utility.Timer();
111
    private final thunder.hack.utility.Timer redeployTimer = new thunder.hack.utility.Timer();
112
    private final thunder.hack.utility.Timer strictTimer = new thunder.hack.utility.Timer();
113
    private final thunder.hack.utility.Timer pingTimer = new thunder.hack.utility.Timer();
114
115
    private boolean infiniteFlag, hasTouchedGround, elytraEquiped, flying, started;
116
    private float acceleration, accelerationY, height, prevClientPitch, infinitePitch, lastInfinitePitch;
117
118
    private ItemStack prevArmorItemCopy, getStackInSlotCopy;
119
    private Item prevArmorItem = Items.AIR;
120
    private Item prevItemInHand = Items.AIR;
121
    private Vec3 flightZonePos;
122
    private int prevElytraSlot = -1, disablerTicks;
123
    private int slotWithFireWorks = -1;
124
    private long lastFireworkTime;
125
126
    @Override
127
    public void onEnable() {
128
        if (mc.player.getY() < infiniteMaxHeight.getValue() && mode.getValue() == Mode.Pitch40Infinite) {
129
            disable(
130
                    isRu() ?
131
                            "Поднимись выше " + ChatFormatting.AQUA + infiniteMaxHeight.getValue() + ChatFormatting.GRAY + " высоты!" :
132
                            "Go above " + ChatFormatting.AQUA + infiniteMaxHeight.getValue() + ChatFormatting.GRAY + " height!"
133
            );
134
        }
135
136
        flying = false;
137
        reset();
138
139
        infiniteFlag = false;
140
        acceleration = 0;
141
        accelerationY = 0;
142
143
        if (mc.player != null)
144
            height = (float) mc.player.getY();
145
146
        pingTimer.reset();
147
148
        if (mode.is(Mode.FireWork)) fireworkOnEnable();
149
    }
150
151
    @EventHandler
152
    public void modifyVelocity(EventTravel e) {
153
        if (mode.getValue() == Mode.Pitch40Infinite) {
154
            if (e.isPre()) {
155
                prevClientPitch = mc.player.getXRot();
156
                mc.player.setXRot(lastInfinitePitch);
157
            } else mc.player.setXRot(prevClientPitch);
158
        }
159
        if (mode.is(Mode.FireWork)) {
160
            if (Managers.PLAYER.ticksElytraFlying < 4) {
161
                if (e.isPre()) {
162
                    prevClientPitch = mc.player.getXRot();
163
                    mc.player.setXRot(-45f);
164
                } else mc.player.setXRot(prevClientPitch);
165
            }
166
        }
167
        if (mode.getValue() == Mode.SunriseNew) {
168
            if (mc.options.keyJump.isDown()) {
169
                if (e.isPre()) {
170
                    prevClientPitch = mc.player.getXRot();
171
                    mc.player.setXRot(-45f);
172
                } else mc.player.setXRot(prevClientPitch);
173
            } else if (mc.options.keyShift.isDown()) {
174
                if (e.isPre()) {
175
                    prevClientPitch = mc.player.getXRot();
176
                    mc.player.setXRot(45f);
177
                } else mc.player.setXRot(prevClientPitch);
178
            }
179
        }
180
    }
181
182
    @EventHandler
183
    public void onSync(EventSync e) {
184
        switch (mode.getValue()) {
185
            case SunriseOld -> doSunrise();
186
            case SunriseNew -> doSunriseNew();
187
            case Boost, Control -> doPreLegacy();
188
            case FireWork -> fireworkOnSync();
189
            case Pitch40Infinite -> doPitch40Infinite();
190
            case Packet -> doPacket(e);
191
        }
192
    }
193
194
    private void doPacket(EventSync e) {
195
        if ((!isBoxCollidingGround() || !stopOnGround.getValue()) && mc.player.getInventory().getItem(38).getItem() == Items.ELYTRA) {
196
            if (infDurability.getValue() || !mc.player.isFallFlying())
197
                sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
198
199
            if (mc.player.tickCount % 3 != 0 && ncpStrict.is(NCPStrict.Motion))
200
                e.cancel();
201
        }
202
    }
203
204
    private void doPitch40Infinite() {
205
        ItemStack is = mc.player.getItemBySlot(EquipmentSlot.CHEST);
206
        if (is.is(Items.ELYTRA)) {
207
            mc.player.setXRot(lastInfinitePitch);
208
            if (is.getDamageValue() > 380 && mc.player.tickCount % 100 == 0) {
209
                Managers.NOTIFICATION.publicity("Elytra+", isRu() ? "Элитра скоро сломается!" : "Elytra's about to break!", 2, Notification.Type.WARNING);
210
                mc.level.playSeededSound(mc.player, mc.player.getX(), mc.player.getY(), mc.player.getZ(), SoundEvents.GENERIC_EXPLODE, SoundSource.AMBIENT, 10.0f, 1.0F, 0);
211
            }
212
        }
213
    }
214
215
    private void doSunriseNew() {
216
        if (mc.player.horizontalCollision)
217
            acceleration = 0;
218
219
        int elytra = InventoryUtility.getElytra();
220
221
        if (elytra == -1)
222
            return;
223
224
        if (mc.player.onGround()) {
225
            mc.player.jumpFromGround();
226
            acceleration = 0;
227
            return;
228
        }
229
230
        if (mc.player.fallDistance <= 0)
231
            return;
232
233
        if (mc.options.keyJump.isDown() || mc.options.keyShift.isDown()) {
234
            acceleration = 0;
235
            takeOnElytra();
236
        } else {
237
            takeOnChestPlate();
238
            if (mc.player.tickCount % 8 == 0)
239
                matrixDisabler(elytra);
240
241
            MovementUtility.setMotion(Math.min((acceleration = (acceleration + 8.0F / xzSpeed.getValue())) / 100.0F, xzSpeed.getValue()));
242
            if (!MovementUtility.isMoving()) acceleration = 0;
243
            mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), -0.005F, mc.player.getDeltaMovement().z());
244
        }
245
    }
246
247
    private void takeOnElytra() {
248
        int elytra = InventoryUtility.getElytra();
249
        if (elytra == -1) return;
250
        elytra = elytra >= 0 && elytra < 9 ? elytra + 36 : elytra;
251
        if (elytra != -2) {
252
            clickSlot(elytra);
253
            clickSlot(6);
254
            clickSlot(elytra);
255
            mc.player.connection.send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
256
        }
257
    }
258
259
    private void takeOnChestPlate() {
260
        int slot = getChestPlateSlot();
261
        if (slot == -1) return;
262
        if (slot != -2) {
263
            clickSlot(slot);
264
            clickSlot(6);
265
            clickSlot(slot);
266
        }
267
    }
268
269
    private float getInfinitePitch() {
270
        if (mc.player.getY() < infiniteMaxHeight.getValue()) {
271
            if (Managers.PLAYER.currentPlayerSpeed * 72f < infiniteMinSpeed.getValue() && !infiniteFlag)
272
                infiniteFlag = true;
273
            if (Managers.PLAYER.currentPlayerSpeed * 72f > infiniteMaxSpeed.getValue() && infiniteFlag)
274
                infiniteFlag = false;
275
        } else infiniteFlag = true;
276
277
        if (infiniteFlag) infinitePitch += 3;
278
        else infinitePitch -= 3;
279
280
        infinitePitch = MathUtility.clamp(infinitePitch, -40, 40);
281
        return infinitePitch;
282
    }
283
284
    @Override
285
    public void onDisable() {
286
        ThunderHack.TICK_TIMER = 1.0f;
287
        mc.player.getAbilities().flying = false;
288
        mc.player.getAbilities().setFlyingSpeed(0.05F);
289
        if (mode.is(Mode.FireWork))
290
            fireworkOnDisable();
291
    }
292
293
    @EventHandler(priority = EventPriority.LOWEST)
294
    public void onMove(EventMove e) {
295
        switch (mode.getValue()) {
296
            case Boost -> doBoost(e);
297
            case Control -> doControl(e);
298
            case FireWork -> fireworkOnMove(e);
299
            case Packet -> doMotionPacket(e);
300
        }
301
    }
302
303
    @EventHandler
304
    public void onPacketSend(PacketEvent.SendPost event) {
305
        if (fullNullCheck()) return;
306
307
        if (event.getPacket() instanceof ServerboundPlayerCommandPacket command && mode.is(Mode.FireWork))
308
            if (command.getAction() == ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)
309
                doFireWork(false);
310
311
        if (event.getPacket() instanceof ServerboundInteractPacket p && mode.is(Mode.FireWork) && grim.getValue().isEnabled() && fireWorkExtender.getValue())
312
            if (flying && flightZonePos != null && Criticals.getEntity(p).tickCount < (pingTimer.getPassedTimeMs() / 50f))
313
                sendMessage(ChatFormatting.RED + (isRu() ? "В этом режиме нельзя бить сущностей которые появились после включения модуля!" : "In this mode, you cannot hit entities that spawned after the module was turned on!"));
314
    }
315
316
    @EventHandler
317
    public void onPacketReceive(PacketEvent.Receive e) {
318
        if (e.getPacket() instanceof ClientboundSetEntityDataPacket pac && pac.id() == mc.player.getId() && (mode.is(Mode.Packet) || mode.is(Mode.SunriseOld))) {
319
            List<SynchedEntityData.DataValue<?>> values = pac.packedItems();
320
            if (values.isEmpty())
321
                return;
322
323
            for (SynchedEntityData.DataValue<?> value : values)
324
                if (value.value().toString().equals("FALL_FLYING") || (value.id() == 0 && (value.value().toString().equals("-120") || value.value().toString().equals("-128") || value.value().toString().equals("-126"))))
325
                    e.cancel();
326
        }
327
328
        if (e.getPacket() instanceof ClientboundPlayerPositionPacket) {
329
            acceleration = 0;
330
            accelerationY = 0;
331
            pingTimer.reset();
332
333
            if (disableOnFlag.getValue() && mode.is(Mode.FireWork))
334
                disable(isRu() ? "Выключен из-за флага!" : "Disabled due to flag!");
335
        }
336
337
        if (e.getPacket() instanceof ClientboundPingPacket && mode.is(Mode.FireWork) && grim.getValue().isEnabled() && fireWorkExtender.getValue() && flying)
338
            if (!pingTimer.passedMs(50000)) {
339
                if (pingTimer.passedMs(1000) && PlayerUtility.getSquaredDistance2D(flightZonePos) < 7000)
340
                    e.cancel();
341
            } else pingTimer.reset();
342
    }
343
344
    @EventHandler
345
    public void onPlayerUpdate(PlayerUpdateEvent e) {
346
        switch (mode.getValue()) {
347
            case FireWork -> fireWorkOnPlayerUpdate();
348
            case Pitch40Infinite -> lastInfinitePitch = PlayerUtility.fixAngle(getInfinitePitch());
349
        }
350
    }
351
352
    private void doMotionPacket(EventMove e) {
353
        mc.player.getAbilities().flying = false;
354
        mc.player.getAbilities().setFlyingSpeed(0.05F);
355
356
        if ((isBoxCollidingGround() && stopOnGround.getValue()) || mc.player.getInventory().getItem(38).getItem() != Items.ELYTRA)
357
            return;
358
359
        mc.player.getAbilities().flying = true;
360
        mc.player.getAbilities().setFlyingSpeed((xzSpeed.getValue() / 15f) * (accelerate.getValue().isEnabled() ? Math.min((acceleration += accelerateFactor.getValue()) / 100.0f, 1.0f) : 1f));
361
        e.cancel();
362
363
        if (mc.player.tickCount % 3 == 0 && ncpStrict.is(NCPStrict.Motion)) {
364
            e.setY(0);
365
            e.setX(0);
366
            e.setZ(0);
367
            return;
368
        }
369
370
        if (Math.abs(e.getX()) < 0.05)
371
            e.setX(0);
372
373
        if (Math.abs(e.getZ()) < 0.05)
374
            e.setZ(0);
375
376
        e.setY(vertical.getValue() ? mc.options.keyJump.isDown() ? ySpeed.getValue() : mc.options.keyShift.isDown() ? -ySpeed.getValue() : 0 : 0);
377
378
        switch (ncpStrict.getValue()) {
379
            case New -> e.setY(-1.000088900582341E-12);
380
            case Motion -> e.setY(-4.000355602329364E-12);
381
            case Old -> e.setY(0.0002 - (mc.player.tickCount % 2 == 0 ? 0 : 0.000001) + MathUtility.random(0, 0.0000009));
382
        }
383
384
        if (mc.player.horizontalCollision && (ncpStrict.is(NCPStrict.New) || ncpStrict.is(NCPStrict.Motion)) && mc.player.tickCount % 2 == 0)
385
            e.setY(-0.07840000152587923);
386
387
        if ((infDurability.getValue() || ncpStrict.is(NCPStrict.Motion))) {
388
            if (!MovementUtility.isMoving() && Math.abs(e.getX()) < 0.121) {
389
                float angleToRad = (float) Math.toRadians(4.5 * (mc.player.tickCount % 80));
390
                e.setX(Math.sin(angleToRad) * 0.12);
391
                e.setZ(Math.cos(angleToRad) * 0.12);
392
            }
393
        }
394
    }
395
396
    private void doPreLegacy() {
397
        if (twoBee.getValue() && mode.is(Mode.Boost)) return;
398
        if (mc.player.onGround()) hasTouchedGround = true;
399
        if (!cruiseControl.getValue()) height = (float) mc.player.getY();
400
401
        if (strictTimer.passedMs(1500) && !strictTimer.passedMs(2000))
402
            ThunderHack.TICK_TIMER = 1.0f;
403
404
        if (!mc.player.isFallFlying()) {
405
            if (hasTouchedGround && !mc.player.onGround() && mc.player.fallDistance > 0 && instantFly.getValue())
406
                ThunderHack.TICK_TIMER = 0.3f;
407
408
            if (!mc.player.onGround() && instantFly.getValue() && mc.player.getDeltaMovement().y() < 0D) {
409
                if (!startTimer.passedMs((long) (1000 * redeployDelay.getValue()))) return;
410
                startTimer.reset();
411
                sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
412
                hasTouchedGround = false;
413
                strictTimer.reset();
414
            }
415
        }
416
    }
417
418
    public void onRender3D(PoseStack stack) {
419
        if (mode.is(Mode.FireWork) && grim.getValue().isEnabled() && fireWorkExtender.getValue() && flying && flightZonePos != null) {
420
            stack.pushPose();
421
            Render3DEngine.setupRender();
422
            RenderSystem.disableCull();
423
            Tesselator tessellator = Tesselator.getInstance();
424
            RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR);
425
            BufferBuilder bufferBuilder = Tesselator.getInstance().begin(com.mojang.blaze3d.PrimitiveTopology.TRIANGLE_STRIP, DefaultVertexFormat.POSITION_COLOR);
426
427
            float cos;
428
            float sin;
429
            for (int i = 0; i <= 30; i++) {
430
                cos = (float) ((flightZonePos.x() - mc.getEntityRenderDispatcher().camera.position().x) + Math.cos(i * (Math.PI * 2f) / 30f) * 95);
431
                sin = (float) ((flightZonePos.z() - mc.getEntityRenderDispatcher().camera.position().z) + Math.sin(i * (Math.PI * 2f) / 30f) * 95);
432
                bufferBuilder.addVertex(stack.last().pose(), cos, (float) -mc.getEntityRenderDispatcher().camera.position().y, sin).setColor(Render2DEngine.injectAlpha(HudEditor.getColor(i), 255).getRGB());
433
                bufferBuilder.addVertex(stack.last().pose(), cos, (float) ((float) 128 - mc.getEntityRenderDispatcher().camera.position().y), sin).setColor(Render2DEngine.injectAlpha(HudEditor.getColor(i), 0).getRGB());
434
            }
435
            Render2DEngine.endBuilding(bufferBuilder);
436
            RenderSystem.enableCull();
437
            Render3DEngine.endRender();
438
            stack.popPose();
439
        }
440
    }
441
442
    public void onRender2D(GuiGraphicsExtractor context) {
443
        if (mode.is(Mode.FireWork) && grim.getValue().isEnabled() && fireWorkExtender.getValue() && flying) {
444
            if (!pingTimer.passedMs(50000)) {
445
                if (pingTimer.passedMs(1000)) {
446
                    int timeS = (int) MathUtility.round2(((float) (50000 - pingTimer.getPassedTimeMs()) / 1000f));
447
                    int dist = (int) (83f - Math.sqrt(PlayerUtility.getSquaredDistance2D(flightZonePos)));
448
                    FontRenderers.sf_bold.drawCenteredString(context.pose(), isRu() ? ("Осталось " + timeS + " секунд и " + dist + " метров") : (timeS + " seconds and " + dist + " meters left"),
449
                            mc.getWindow().getGuiScaledWidth() / 2f, mc.getWindow().getGuiScaledHeight() / 2f + 30f, -1);
450
                }
451
            }
452
        }
453
    }
454
455
    private void doSunrise() {
456
        if (mc.player.horizontalCollision)
457
            acceleration = 0;
458
        if (mc.player.verticalCollision) {
459
            acceleration = 0;
460
            mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), 0.41999998688697815, mc.player.getDeltaMovement().z());
461
        }
462
463
        int elytra = InventoryUtility.getElytra();
464
        if (elytra == -1) return;
465
        if (mc.player.onGround()) mc.player.jumpFromGround();
466
467
        if (disablerTicks-- <= 0)
468
            matrixDisabler(elytra);
469
470
        if (mc.player.fallDistance > 0.25f) {
471
            MovementUtility.setMotion(Math.min((acceleration = (acceleration + 11.0F / xzSpeed.getValue())) / 100.0F, xzSpeed.getValue()));
472
            if (!MovementUtility.isMoving()) acceleration = 0;
473
474
            if (InputConstants.isKeyDown(mc.getWindow(), bombKey.getValue().getKey())) {
475
                MovementUtility.setMotion(0.8f);
476
                mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), mc.player.tickCount % 2 == 0 ? 0.41999998688697815 : -0.41999998688697815, mc.player.getDeltaMovement().z());
477
                acceleration = 70;
478
            } else {
479
                switch (antiKick.getValue()) {
480
                    case Jitter -> mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), mc.player.tickCount % 2 == 0 ? 0.08 : -0.08, mc.player.getDeltaMovement().z());
481
                    case Glide -> mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), -0.01F - (mc.player.tickCount % 2 == 0 ? 1.0E-4F : 0.006F), mc.player.getDeltaMovement().z());
482
                    case Off -> mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), 0, mc.player.getDeltaMovement().z());
483
                }
484
            }
485
486
            if (!mc.player.isShiftKeyDown() && mc.options.keyJump.isDown())
487
                mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), ySpeed.getValue(), mc.player.getDeltaMovement().z());
488
489
            if (mc.options.keyShift.isDown())
490
                mc.player.setDeltaMovement(mc.player.getDeltaMovement().x(), -ySpeed.getValue(), mc.player.getDeltaMovement().z());
491
        }
492
    }
493
494
    private void doBoost(EventMove e) {
495
        if (mc.player.getInventory().getItem(38).getItem() != Items.ELYTRA || !mc.player.isFallFlying() || mc.player.isInWater() || mc.player.isInLava() || !mc.player.isFallFlying())
496
            return;
497
498
        float moveForward = mc.player.input.getMoveVector().y;
499
500
        if (cruiseControl.getValue()) {
501
            if (mc.options.keyJump.isDown()) height++;
502
            else if (mc.options.keyShift.isDown()) height--;
503
            if (forceHeight.getValue()) height = manualHeight.getValue();
504
505
            if(twoBee.getValue()) {
506
                if (Managers.PLAYER.currentPlayerSpeed >= minUpSpeed.getValue())
507
                    mc.player.setXRot((float) Mth.clamp(Mth.wrapDegrees(Math.toDegrees(Math.atan2((height - mc.player.getY()) * -1.0, 10))), -50, 50));
508
                else
509
                    mc.player.setXRot(0.25F);
510
            } else {
511
                double heightPct = 1 - Math.sqrt(Mth.clamp(Managers.PLAYER.currentPlayerSpeed / 1.7, 0.0, 1.0));
512
                if (Managers.PLAYER.currentPlayerSpeed >= minUpSpeed.getValue() && startTimer.passedMs((long) (2000 * redeployInterval.getValue()))) {
513
                    double pitch = -(44.4 * heightPct + 0.6);
514
                    double diff = (height + 1 - mc.player.getY()) * 2;
515
                    double pDist = -Math.toDegrees(Math.atan2(Math.abs(diff), Managers.PLAYER.currentPlayerSpeed * 30.0)) * Math.signum(diff);
516
                    mc.player.setXRot((float) (pitch + (pDist - pitch) * Mth.clamp(Math.abs(diff), 0.0, 1.0)));
517
                } else {
518
                    mc.player.setXRot(0.25F);
519
                    moveForward = 1;
520
                }
521
            }
522
        }
523
524
        if(twoBee.getValue()) {
525
            if ((mc.options.keyJump.isDown() || !onlySpace.getValue() || cruiseControl.getValue())) {
526
                double[] m = MovementUtility.forwardWithoutStrafe((factor.getValue() / 10f));
527
                e.setX(e.getX() + m[0]);
528
                e.setZ(e.getZ() + m[1]);
529
            }
530
        } else {
531
            Vec3 rotationVec = mc.player.getViewVector(Render3DEngine.getTickDelta());
532
533
            double d6 = Math.hypot(rotationVec.x, rotationVec.z);
534
            double currentSpeed = Math.hypot(e.getX(), e.getZ());
535
536
            float f4 = (float) (Math.pow(Math.cos(Math.toRadians(mc.player.getXRot())), 2) * Math.min(1, rotationVec.length() / 0.4));
537
538
            e.setY(e.getY() + (-0.08D + (double) f4 * 0.06));
539
540
            if (e.getY() < 0 && d6 > 0) {
541
                double ySpeed = e.getY() * -0.1 * (double) f4;
542
                e.setY(e.getY() + ySpeed);
543
                e.setX(e.getX() + rotationVec.x * ySpeed / d6);
544
                e.setZ(e.getZ() + rotationVec.z * ySpeed / d6);
545
            }
546
547
            if (mc.player.getXRot() < 0) {
548
                double ySpeed = currentSpeed * -Math.sin(Math.toRadians(mc.player.getXRot())) * 0.04;
549
                e.setY(e.getY() + ySpeed * 3.2);
550
                e.setX(e.getX() - rotationVec.x * ySpeed / d6);
551
                e.setZ(e.getZ() - rotationVec.z * ySpeed / d6);
552
            }
553
554
            if (d6 > 0) {
555
                e.setX(e.getX() + (rotationVec.x / d6 * currentSpeed - e.getX()) * 0.1D);
556
                e.setZ(e.getZ() + (rotationVec.z / d6 * currentSpeed - e.getZ()) * 0.1D);
557
            }
558
559
            if (mc.player.getXRot() > 0 && e.getY() < 0) {
560
                if (moveForward != 0 && startTimer.passedMs((long) (2000 * redeployInterval.getValue())) && redeployTimer.passedMs((long) (1000 * redeployTimeOut.getValue()))) {
561
                    if (stopMotion.getValue()) {
562
                        e.setX(0);
563
                        e.setZ(0);
564
                    }
565
                    startTimer.reset();
566
                    sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
567
                } else if (!startTimer.passedMs((long) (2000 * redeployInterval.getValue()))) {
568
                    e.setX(e.getX() - moveForward * Math.sin(Math.toRadians(mc.player.getYRot())) * factor.getValue() / 20F);
569
                    e.setZ(e.getZ() + moveForward * Math.cos(Math.toRadians(mc.player.getYRot())) * factor.getValue() / 20F);
570
                    redeployTimer.reset();
571
                }
572
            }
573
        }
574
575
        double speed = Math.hypot(e.getX(), e.getZ());
576
577
        if (speedLimit.getValue() && speed > maxSpeed.getValue()) {
578
            e.setX(e.getX() * maxSpeed.getValue() / speed);
579
            e.setZ(e.getZ() * maxSpeed.getValue() / speed);
580
        }
581
582
        mc.player.setDeltaMovement(e.getX(), e.getY(), e.getZ());
583
        e.cancel();
584
    }
585
586
    private void doControl(EventMove e) {
587
        if (mc.player.getInventory().getItem(38).getItem() != Items.ELYTRA || !mc.player.isFallFlying())
588
            return;
589
590
        double[] dir = MovementUtility.forward(xzSpeed.getValue() * (accelerate.getValue().isEnabled() ? Math.min((acceleration += accelerateFactor.getValue()) / 100.0f, 1.0f) : 1f));
591
        e.setX(dir[0]);
592
        e.setY(mc.options.keyJump.isDown() ? upSpeed.getValue() : mc.options.keyShift.isDown() ? -sneakDownSpeed.getValue() : -0.08 * downFactor.getValue());
593
        e.setZ(dir[1]);
594
595
        if (!MovementUtility.isMoving())
596
            acceleration = 0;
597
598
        mc.player.setDeltaMovement(e.getX(), e.getY(), e.getZ());
599
        e.cancel();
600
    }
601
602
    public void matrixDisabler(int elytra) {
603
        elytra = elytra >= 0 && elytra < 9 ? elytra + 36 : elytra;
604
        if (elytra != -2) {
605
            mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, elytra, 1, ContainerInput.PICKUP, mc.player);
606
            mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, 6, 1, ContainerInput.PICKUP, mc.player);
607
        }
608
        mc.player.connection.send(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
609
        if (elytra != -2) {
610
            mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, 6, 1, ContainerInput.PICKUP, mc.player);
611
            mc.gameMode.handleContainerInput(mc.player.containerMenu.containerId, elytra, 1, ContainerInput.PICKUP, mc.player);
612
        }
613
        disablerTicks = disablerDelay.getValue();
614
    }
615
616
    private int getFireWorks(boolean hotbar) {
617
        if (hotbar) {
618
            return InventoryUtility.findItemInHotBar(Items.FIREWORK_ROCKET).slot();
619
        } else return InventoryUtility.findItemInInventory(Items.FIREWORK_ROCKET).slot();
620
    }
621
622
    private void noFireworks() {
623
        disable(isRu() ? "Нету фейерверков в инвентаре!" : "No fireworks in the hotbar!");
624
        flying = false;
625
    }
626
627
    private void noElytra() {
628
        disable(isRu() ? "Нету элитр в инвентаре!" : "No elytras found in the inventory!");
629
        flying = false;
630
    }
631
632
    private void reset() {
633
        slotWithFireWorks = -1;
634
        prevItemInHand = Items.AIR;
635
        getStackInSlotCopy = null;
636
    }
637
638
    private void resetPrevItems() {
639
        prevElytraSlot = -1;
640
        prevArmorItem = Items.AIR;
641
        prevArmorItemCopy = null;
642
    }
643
644
    private void moveFireworksToHotbar(int n2) {
645
        clickSlot(n2);
646
        clickSlot(fireSlot.getValue() - 1 + 36);
647
        clickSlot(n2);
648
    }
649
650
    private void returnItem() {
651
        if (slotWithFireWorks == -1 || getStackInSlotCopy == null || prevItemInHand == Items.FIREWORK_ROCKET || prevItemInHand == Items.AIR) {
652
            return;
653
        }
654
        int n2 = findInInventory(getStackInSlotCopy, prevItemInHand);
655
        n2 = n2 < 9 && n2 != -1 ? n2 + 36 : n2;
656
        clickSlot(n2);
657
        clickSlot(fireSlot.getValue() - 1 + 36);
658
        clickSlot(n2);
659
    }
660
661
    public static int findInInventory(ItemStack stack, Item item) {
662
        if (stack == null) {
663
            return -1;
664
        }
665
        for (int i2 = 0; i2 < 45; ++i2) {
666
            ItemStack is = mc.player.getInventory().getItem(i2);
667
            if (!ItemStack.isSameItem(is, stack) || is.getItem() != item) continue;
668
            return i2;
669
        }
670
        return -1;
671
    }
672
673
    private int getFireworks() {
674
        if (mc.player.getOffhandItem().getItem() == Items.FIREWORK_ROCKET) {
675
            return -2;
676
        }
677
        int firesInHotbar = getFireWorks(true);
678
        int firesInInventory = getFireWorks(false);
679
        if (firesInInventory == -1) {
680
            noFireworks();
681
            return -1;
682
        }
683
        if (firesInHotbar == -1) {
684
            if (!allowFireSwap.getValue()) {
685
                disable(isRu() ? "Нет фейерверков!" : "No fireworks!");
686
                return fireSlot.getValue() - 1;
687
            }
688
            moveFireworksToHotbar(firesInInventory);
689
            return fireSlot.getValue() - 1;
690
        }
691
        return firesInHotbar;
692
    }
693
694
    private boolean canFly() {
695
        if (shouldSwapToElytra()) return false;
696
        return getFireworks() != -1;
697
    }
698
699
    private boolean shouldSwapToElytra() {
700
        ItemStack is = mc.player.getItemBySlot(EquipmentSlot.CHEST);
701
        return !LivingEntity.canGlideUsing(is, EquipmentSlot.CHEST);
702
    }
703
704
    private void doFireWork(boolean started) {
705
        if (started && (float) (System.currentTimeMillis() - lastFireworkTime) < fireDelay.getValue() * 1000.0f)
706
            return;
707
708
        if (grim.getValue().isEnabled() && fireWorkExtender.getValue() && started && pingTimer.passedMs(200) && flightZonePos != null && PlayerUtility.getSquaredDistance2D(flightZonePos) < 7000)
709
            return;
710
711
        if (started && !mc.player.isFallFlying()) return;
712
        if (!started && Managers.PLAYER.ticksElytraFlying > 1) return;
713
714
        int slot = getFireworks();
715
        if (slot == -1) {
716
            slotWithFireWorks = -1;
717
            return;
718
        }
719
        slotWithFireWorks = slot;
720
721
        boolean inOffhand = mc.player.getOffhandItem().getItem() == Items.FIREWORK_ROCKET;
722
723
        int prevSlot = mc.player.getInventory().getSelectedSlot();
724
725
        if (!inOffhand && prevSlot != slot)
726
            sendPacket(new ServerboundSetCarriedItemPacket(slot));
727
728
        sendSequencedPacket(id -> new ServerboundUseItemPacket(inOffhand ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND, id, mc.player.getYRot(), mc.player.getXRot()));
729
730
        if (!inOffhand && prevSlot != mc.player.getInventory().getSelectedSlot())
731
            sendPacket(new ServerboundSetCarriedItemPacket(prevSlot));
732
733
        flying = true;
734
        lastFireworkTime = System.currentTimeMillis();
735
        pingTimer.reset();
736
        flightZonePos = mc.player.position();
737
    }
738
739
    private void equipElytra() {
740
        int elytraSlot = InventoryUtility.getElytra();
741
        if (elytraSlot == -1 && mc.player.containerMenu.getCarried().getItem() != Items.ELYTRA) {
742
            noElytra();
743
            return;
744
        }
745
        if (!shouldSwapToElytra()) return;
746
        if (prevElytraSlot == -1) {
747
            ItemStack is = mc.player.getItemBySlot(EquipmentSlot.CHEST);
748
            prevElytraSlot = elytraSlot;
749
            prevArmorItem = is.getItem();
750
            prevArmorItemCopy = is.copy();
751
        }
752
753
        clickSlot(elytraSlot);
754
        clickSlot(6);
755
        if (prevElytraSlot != -1)
756
            clickSlot(prevElytraSlot);
757
758
        elytraEquiped = true;
759
    }
760
761
    private void returnChestPlate() {
762
        if (prevElytraSlot != -1 && prevArmorItem != Items.AIR) {
763
            if (!elytraEquiped)
764
                return;
765
766
            ItemStack is = mc.player.getInventory().getItem(prevElytraSlot);
767
            boolean bl2 = is != ItemStack.EMPTY && !ItemStack.isSameItem(is, prevArmorItemCopy);
768
            int n2 = findInInventory(prevArmorItemCopy, prevArmorItem);
769
            n2 = n2 < 9 && n2 != -1 ? n2 + 36 : n2;
770
            if (mc.player.containerMenu.getCarried().getItem() != Items.AIR) {
771
                clickSlot(6);
772
                if (prevElytraSlot != -1)
773
                    clickSlot(prevElytraSlot);
774
                return;
775
            }
776
            if (n2 == -1) return;
777
778
            clickSlot(n2);
779
            clickSlot(6);
780
            if (!bl2) {
781
                clickSlot(n2);
782
            } else {
783
                int n4 = findEmpty(false);
784
                if (n4 != -1) {
785
                    clickSlot(n4);
786
                }
787
            }
788
        }
789
        resetPrevItems();
790
    }
791
792
    public static int findEmpty(boolean hotbar) {
793
        for (int i2 = hotbar ? 0 : 9; i2 < (hotbar ? 9 : 45); ++i2) {
794
            if (!mc.player.getInventory().getItem(i2).isEmpty()) continue;
795
            return i2;
796
        }
797
        return -1;
798
    }
799
800
    public void fireWorkOnPlayerUpdate() {
801
        boolean inAir = mc.level.isEmptyBlock(BlockPos.containing(mc.player.position()));
802
        boolean aboveLiquid = isAboveLiquid(0.1f) && inAir && mc.player.getDeltaMovement().y() < 0.0;
803
        if (mc.player.fallDistance > 0.0f && inAir || aboveLiquid) {
804
            equipElytra();
805
        } else if (mc.player.onGround()) {
806
            started = false;
807
            return;
808
        }
809
810
        if (!MovementUtility.isMoving())
811
            acceleration = 0;
812
        if (!canFly()) return;
813
814
        if (!mc.player.isFallFlying() && !started && mc.player.getDeltaMovement().y() < 0.0) {
815
            sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
816
            started = true;
817
        }
818
        if (Managers.PLAYER.ticksElytraFlying < 4) {
819
            mc.options.keyJump.setDown(false);
820
        }
821
        doFireWork(true);
822
    }
823
824
    public void fireworkOnSync() {
825
        if (grim.getValue().isEnabled() && rotate.getValue()) {
826
            if (mc.options.keyJump.isDown() && mc.player.isFallFlying() && flying)
827
                mc.player.setXRot(-45f);
828
829
            if (mc.options.keyShift.isDown() && mc.player.isFallFlying() && flying)
830
                mc.player.setXRot(45f);
831
832
            mc.player.setYRot(MovementUtility.getMoveDirection());
833
        }
834
835
        if (!MovementUtility.isMoving() && mc.options.keyJump.isDown() && mc.player.isFallFlying() && flying)
836
            mc.player.setXRot(-90f);
837
838
        if (Managers.PLAYER.ticksElytraFlying < 5 && !mc.player.onGround())
839
            mc.player.setXRot(-45f);
840
    }
841
842
    public void fireworkOnMove(EventMove e) {
843
        if (mc.player.isFallFlying() && flying) {
844
            if (mc.player.horizontalCollision || mc.player.verticalCollision) {
845
                acceleration = 0;
846
                accelerationY = 0;
847
            }
848
849
            if (Managers.PLAYER.ticksElytraFlying < 4) {
850
                e.setY(0.2f);
851
                e.cancel();
852
                return;
853
            }
854
855
            if (mc.options.keyJump.isDown()) {
856
                e.setY(ySpeed.getValue() * Math.min((accelerationY += 9) / 100.0f, 1.0f));
857
            } else if (mc.options.keyShift.isDown()) {
858
                e.setY(-ySpeed.getValue() * Math.min((accelerationY += 9) / 100.0f, 1.0f));
859
            } else if (bowBomb.getValue() && checkGround(2.0f)) {
860
                e.setY(mc.player.tickCount % 2 == 0 ? 0.42f : -0.42f);
861
            } else {
862
                switch (antiKick.getValue()) {
863
                    case Jitter -> e.setY(mc.player.tickCount % 2 == 0 ? 0.08f : -0.08f);
864
                    case Glide -> e.setY(-0.08f);
865
                    case Off -> e.setY(0f);
866
                }
867
            }
868
869
            if (!MovementUtility.isMoving())
870
                acceleration = 0;
871
872
            if (mc.player.input.getMoveVector().x > 0) {
873
                MovementUtility.setMovementInputX(1f);
874
            } else if (mc.player.input.getMoveVector().x < 0) {
875
                MovementUtility.setMovementInputX(-1f);
876
            }
877
878
            MovementUtility.modifyEventSpeed(e, xzSpeed.getValue() * Math.min((acceleration += 9) / 100.0f, 1.0f));
879
            if (stayMad.getValue() && !checkGround(3.0f) && Managers.PLAYER.ticksElytraFlying > 10)
880
                e.setY(0.42f);
881
            e.cancel();
882
        }
883
    }
884
885
    public static boolean checkGround(float f2) {
886
        if (mc.player.getY() < 0.0) return false;
887
        return !mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().move(0.0, -f2, 0.0)).iterator().hasNext();
888
    }
889
890
    public static boolean isAboveLiquid(float offset) {
891
        if (mc.player == null) return false;
892
        return mc.level.getBlockState(BlockPos.containing(mc.player.getX(), mc.player.getY() - (double) offset, mc.player.getZ())).getBlock() instanceof LiquidBlock;
893
    }
894
895
    public void fireworkOnEnable() {
896
        if (mc.player.getItemBySlot(EquipmentSlot.CHEST).getItem() != Items.ELYTRA && mc.player.containerMenu.getCarried().getItem() != Items.ELYTRA && InventoryUtility.getElytra() == -1) {
897
            noElytra();
898
            return;
899
        }
900
        if (getFireWorks(false) == -1) {
901
            noFireworks();
902
            return;
903
        }
904
        if (getFireWorks(true) != -1) return;
905
        getStackInSlotCopy = mc.player.getInventory().getItem(fireSlot.getValue() - 1).copy();
906
        prevItemInHand = mc.player.getInventory().getItem(fireSlot.getValue() - 1).getItem();
907
    }
908
909
    public void fireworkOnDisable() {
910
        started = false;
911
        if (keepFlying.getValue()) return;
912
        mc.player.setDeltaMovement(0, mc.player.getDeltaMovement().y(), 0);
913
        new Thread(() -> {
914
            sendPacket(new ServerboundPlayerCommandPacket(mc.player, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING));
915
            ThunderHack.TICK_TIMER = 0.1f;
916
            returnItem();
917
            reset();
918
            try {
919
                Thread.sleep(200L);
920
            } catch (InterruptedException interruptedException) {
921
                ThunderHack.TICK_TIMER = 1f;
922
                interruptedException.printStackTrace();
923
            }
924
            returnChestPlate();
925
            resetPrevItems();
926
            ThunderHack.TICK_TIMER = 1f;
927
        }).start();
928
    }
929
930
    private boolean isBoxCollidingGround() {
931
        return mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().inflate(-0.25, 0.0, -0.25).move(0.0, -0.3, 0.0)).iterator().hasNext();
932
    }
933
}
934