blob: 8dc4b2472cb124d9f6bca71e9947ed0fb868b412 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package com.arslaancodes.arslaansmagichax.modules.impl;
import com.arslaancodes.arslaansmagichax.modules.Category;
import com.arslaancodes.arslaansmagichax.modules.Module;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
public class Flight extends Module {
private int flyingTickCounter = 0;
private boolean sentFirstPacket = false;
public Flight() {
super("Flight", "Enables creative flight in survival.", GLFW.GLFW_KEY_G, Category.MOVEMENT);
}
@Override
protected void onEnable() {
if (mc.player == null) return;
mc.player.sendMessage(Text.literal("[Flight] It is recommended to use this hack in combination with NoFall."), false);
}
@Override
public void tick() {
if (!this.isEnabled() || mc.player == null) return;
mc.player.getAbilities().allowFlying = true;
mc.player.getAbilities().flying = true;
if (flyingTickCounter >= 20) {
if (!sentFirstPacket) {
sendYPacket(-0.0625);
sentFirstPacket = true;
} else {
sendYPacket(0);
sentFirstPacket = false;
flyingTickCounter = 0;
}
}
flyingTickCounter++;
}
@Override
protected void onDisable() {
if (mc.player != null) {
mc.player.getAbilities().allowFlying = false;
mc.player.getAbilities().flying = false;
}
}
private static void sendYPacket(double height) {
double x = mc.player.getX();
double y = mc.player.getY();
double z = mc.player.getZ();
PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.PositionAndOnGround(x, y + height, z, false, mc.player.horizontalCollision);
mc.player.networkHandler.sendPacket(packet);
}
}
|