PacketFly module

PacketFly: 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/PacketFly.javaJava · 254 lines · 10.4 KB

NCP fly bypass.

SettingsModeTypePhaseLimitAntiKickIntervalUpIntervalanticKickOffsetSpeedUpSpeedTimerIncreaseTicksFactorOffset
PacketFly.javaJava · Minecraft 26.2 · 254 lines · 10.4 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.client.gui.screens.LevelLoadingScreen;
5
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
6
import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket;
7
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
8
import net.minecraft.world.entity.PositionMoveRotation;
9
import net.minecraft.world.phys.Vec3;
10
import org.jetbrains.annotations.NotNull;
11
import thunder.hack.ThunderHack;
12
import thunder.hack.events.impl.EventMove;
13
import thunder.hack.events.impl.EventSync;
14
import thunder.hack.events.impl.PacketEvent;
15
import thunder.hack.injection.accesors.IPlayerPositionLookS2CPacket;
16
import thunder.hack.features.modules.Module;
17
import thunder.hack.setting.Setting;
18
import thunder.hack.setting.impl.BooleanSettingGroup;
19
import thunder.hack.utility.player.MovementUtility;
20
21
import java.util.ArrayList;
22
import java.util.concurrent.ConcurrentHashMap;
23
import java.util.concurrent.ThreadLocalRandom;
24
25
public class PacketFly extends Module {
26
    public PacketFly() {
27
        super("PacketFly", Category.MOVEMENT);
28
    }
29
30
    private final Setting<Mode> mode = new Setting<>("Mode", Mode.Fast);
31
    private final Setting<Type> type = new Setting<>("Type", Type.Preserve);
32
    private final Setting<Phase> phase = new Setting<>("Phase", Phase.Full);
33
    private final Setting<Boolean> limit = new Setting<>("Limit", true);
34
    private final Setting<BooleanSettingGroup> antiKick = new Setting<>("AntiKick", new BooleanSettingGroup(true));
35
    private final Setting<Integer> interval = new Setting<>("Interval", 4, 1, 50).addToGroup(antiKick);
36
    private final Setting<Integer> upInterval = new Setting<>("UpInterval", 20, 1, 50).addToGroup(antiKick);
37
    private final Setting<Float> anticKickOffset = new Setting<>("anticKickOffset", 0.04f, 0.008f, 1f).addToGroup(antiKick);
38
    private final Setting<Float> speed = new Setting<>("Speed", 1.0f, 0.0f, 10.0f);
39
    private final Setting<Float> upSpeed = new Setting<>("UpSpeed", 0.062f, 0.001f, 0.1f);
40
    private final Setting<Float> timer = new Setting<>("Timer", 1f, 0.1f, 5f);
41
    private final Setting<Integer> increaseTicks = new Setting<>("IncreaseTicks", 1, 1, 20);
42
    private final Setting<Float> factor = new Setting<>("Factor", 1f, 1f, 10f);
43
    private final Setting<Float> offset = new Setting<>("Offset", 1337f, 1f, 1337f, v-> type.is(Type.Up) || type.is(Type.Down));
44
45
    private final ConcurrentHashMap<Integer,Teleport> teleports = new ConcurrentHashMap<>();
46
    private final ArrayList<ServerboundMovePlayerPacket> movePackets = new ArrayList<>();
47
    private int ticks, factorTicks, teleportId = -1;
48
    private boolean flip = false;
49
50
    @Override
51
    public void onEnable() {
52
        teleportId = -1;
53
        if (fullNullCheck() && mc.player != null) {
54
            ticks = 0;
55
            teleportId = 0;
56
            movePackets.clear();
57
            teleports.clear();
58
        }
59
        factorTicks = 0;
60
    }
61
62
    @Override
63
    public void onDisable() {
64
        ThunderHack.TICK_TIMER = 1.0f;
65
        movePackets.clear();
66
        teleports.clear();
67
        if (mc.player != null)
68
            mc.player.noPhysics = false;
69
    }
70
71
    public boolean getTickCounter(int n) {
72
        ++ticks;
73
        if (ticks >= n) {
74
            ticks = 0;
75
            return true;
76
        }
77
        return false;
78
    }
79
80
    private int getWorldBorder() {
81
        if (mc.isLocalServer()) {
82
            return 1;
83
        }
84
        int n = ThreadLocalRandom.current().nextInt(29000000);
85
        if (ThreadLocalRandom.current().nextBoolean()) {
86
            return n;
87
        }
88
        return -n;
89
    }
90
91
    public Vec3 getVectorByMode(@NotNull Vec3 vec3d, Vec3 vec3d2) {
92
        Vec3 vec3d3 = vec3d.add(vec3d2);
93
        switch (type.getValue()) {
94
            case Preserve -> vec3d3 = vec3d3.add(getWorldBorder(), 0.0, getWorldBorder());
95
            case Up -> vec3d3 = vec3d3.add(0.0, offset.getValue(), 0.0);
96
            case Down -> vec3d3 = vec3d3.add(0.0, -offset.getValue(), 0.0);
97
            case Bounds -> vec3d3 = new Vec3(vec3d3.x, mc.player.getY() <= 10.0 ? 255.0 : 1.0, vec3d3.z);
98
        }
99
        return vec3d3;
100
    }
101
102
    public void sendPackets(Vec3 vec3d, boolean confirm) {
103
        Vec3 motion = mc.player.position().add(vec3d);
104
        Vec3 rubberBand = getVectorByMode(vec3d, motion);
105
106
        ServerboundMovePlayerPacket motionPacket =  new ServerboundMovePlayerPacket.Pos(motion.x, motion.y, motion.z, mc.player.onGround(), mc.player.horizontalCollision);
107
        movePackets.add(motionPacket);
108
        sendPacket(motionPacket);
109
110
        ServerboundMovePlayerPacket rubberBandPacket = new ServerboundMovePlayerPacket.Pos(rubberBand.x, rubberBand.y, rubberBand.z, mc.player.onGround(), mc.player.horizontalCollision);
111
        movePackets.add(rubberBandPacket);
112
        sendPacket(rubberBandPacket);
113
114
        if (confirm) {
115
            sendPacket(new ServerboundAcceptTeleportationPacket(++teleportId));
116
            teleports.put(teleportId, new Teleport(motion.x, motion.y, motion.z, System.currentTimeMillis()));
117
        }
118
    }
119
120
    @EventHandler
121
    public void onPacketReceive(PacketEvent.Receive event) {
122
        if (fullNullCheck()) return;
123
        if (mc.player != null && event.getPacket() instanceof ClientboundPlayerPositionPacket pac) {
124
            Teleport teleport = teleports.remove(pac.id());
125
            Vec3 pos = pac.change().position();
126
            if (
127
                    mc.player.isAlive()
128
                    && mc.level.hasChunk((int) mc.player.getX() >> 4, (int) mc.player.getZ() >> 4)
129
                    && !(mc.gui.screen() instanceof LevelLoadingScreen)
130
                    && mode.getValue() != Mode.Rubber
131
                    && teleport != null
132
                    && teleport.x == pos.x
133
                    && teleport.y == pos.y
134
                    && teleport.z == pos.z
135
            ) {
136
                event.cancel();
137
                return;
138
            }
139
            PositionMoveRotation change = pac.change();
140
            PositionMoveRotation updated = new PositionMoveRotation(change.position(), change.deltaMovement(), mc.player.getYRot(), mc.player.getXRot());
141
            ((IPlayerPositionLookS2CPacket) (Object) pac).setChange(updated);
142
            teleportId = pac.id();
143
        }
144
    }
145
146
    @EventHandler
147
    public void onPacketSend(PacketEvent.@NotNull Send event) {
148
        if (event.getPacket() instanceof ServerboundMovePlayerPacket) {
149
            if (movePackets.contains((ServerboundMovePlayerPacket) event.getPacket())) {
150
                movePackets.remove((ServerboundMovePlayerPacket) event.getPacket());
151
                return;
152
            }
153
            event.cancel();
154
        }
155
    }
156
157
    @Override
158
    public void onUpdate() {
159
        teleports.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue().time > 30000);
160
    }
161
162
    @EventHandler
163
    public void onMove(@NotNull EventMove event) {
164
        if (!event.isCancelled()) {
165
            if (mode.getValue() != Mode.Rubber && teleportId == 0)
166
                return;
167
168
            event.cancel();
169
            event.setX(mc.player.getDeltaMovement().x);
170
            event.setY(mc.player.getDeltaMovement().y);
171
            event.setZ(mc.player.getDeltaMovement().z);
172
            if (phase.getValue() != Phase.Off && (phase.getValue() == Phase.Semi || mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().inflate(-0.0625, -0.0625, -0.0625)).iterator().hasNext())) {
173
                mc.player.noPhysics = true;
174
            }
175
        }
176
    }
177
178
    @EventHandler
179
    public void onSync(EventSync eventPlayerUpdateWalking) {
180
        if (timer.getValue() != 1.0)
181
            ThunderHack.TICK_TIMER = timer.getValue();
182
183
        mc.player.setDeltaMovement(0.0, 0.0, 0.0);
184
185
        if (mode.getValue() != Mode.Rubber && teleportId == 0) {
186
            if (getTickCounter(4))
187
                sendPackets(Vec3.ZERO, false);
188
            return;
189
        }
190
191
        boolean insideBlock = mc.level.getBlockCollisions(mc.player, mc.player.getBoundingBox().inflate(-0.0625, -0.0625, -0.0625)).iterator().hasNext();
192
193
        double upMotion = 0;
194
195
        if (mc.options.keyJump.isDown() && (insideBlock || !MovementUtility.isMoving())) {
196
            if (antiKick.getValue().isEnabled() && !insideBlock)
197
                upMotion = getTickCounter(mode.is(Mode.Rubber) ? upInterval.getValue() / 2 : upInterval.getValue()) ? -upSpeed.getValue() / 2f : upSpeed.getValue();
198
            else
199
                upMotion = upSpeed.getValue();
200
        } else if (mc.options.keyShift.isDown())
201
            upMotion = -upSpeed.getValue();
202
        else if(antiKick.getValue().isEnabled() && !insideBlock)
203
            upMotion = getTickCounter(interval.getValue()) ? -anticKickOffset.getValue() : 0.0;
204
205
        if (phase.is(Phase.Full) && insideBlock && MovementUtility.isMoving() && upMotion != 0.0)
206
            upMotion = mc.options.keyJump.isDown()  ? upMotion / 2.5 : upMotion / 1.5;
207
208
        double[] motion = MovementUtility.forward(phase.is(Phase.Full) && insideBlock ? 0.034444444444444444 : (double) (speed.getValue()) * 0.26);
209
210
        int factorInt = 1;
211
        if (mode.getValue() == Mode.Factor && mc.player.tickCount % increaseTicks.getValue() == 0) {
212
            factorInt = (int) Math.floor(factor.getValue());
213
            factorTicks++;
214
            if (factorTicks > (int) (20D / ((factor.getValue() - factorInt) * 20D))) {
215
                factorInt += 1;
216
                factorTicks = 0;
217
            }
218
        }
219
220
        for (int i = 1; i <= factorInt; ++i) {
221
            if (mode.getValue() == Mode.Limit) {
222
                if (mc.player.tickCount % 2 == 0) {
223
                    if (flip && upMotion >= 0.0) {
224
                        flip = false;
225
                        upMotion = -upSpeed.getValue() / 2f;
226
                    }
227
                    mc.player.setDeltaMovement(motion[0] * i,upMotion * i,motion[1] * i);
228
                    sendPackets(mc.player.getDeltaMovement(), !limit.getValue());
229
                    continue;
230
                }
231
                if (!(upMotion < 0.0)) continue;
232
                flip = true;
233
                continue;
234
            }
235
            mc.player.setDeltaMovement(motion[0] * i,upMotion * i,motion[1] * i);
236
            sendPackets(mc.player.getDeltaMovement(), !mode.is(Mode.Rubber));
237
        }
238
    }
239
240
    public enum Mode {
241
        Fast, Factor, Rubber, Limit
242
    }
243
244
    public enum Phase {
245
        Full, Off, Semi
246
    }
247
248
    public enum Type {
249
        Preserve, Up, Down, Bounds
250
    }
251
252
    public record Teleport(double x, double y, double z, long time){}
253
}
254