-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Packetfly module #813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+236
−0
Closed
Packetfly module #813
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
12a5e57
Packetfly module
hashalite afffb9f
Fixes/Cleanup
hashalite 1b53a4c
License header
hashalite 820e62b
Cleanup
hashalite 9c88c10
removed sgGeneral
hashalite e4da23c
Merge branch 'MeteorDevelopment:master' into packetfly
hashalite dc298e9
Small fix
hashalite fdd7881
Merge branch 'packetfly' of github.com:hashalite/meteor-client into p…
hashalite b4f0b56
Merge branch 'master' into packetfly
gigglingbed a707665
Remove typo
hashalite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
225 changes: 225 additions & 0 deletions
225
src/main/java/minegame159/meteorclient/systems/modules/movement/PacketFly.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,225 @@ | ||
| /* | ||
| * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client/). | ||
| * Copyright (c) 2021 Meteor Development. | ||
| */ | ||
|
|
||
| package minegame159.meteorclient.systems.modules.movement; | ||
|
|
||
| import io.netty.util.internal.ConcurrentSet; | ||
| import meteordevelopment.orbit.EventHandler; | ||
| import minegame159.meteorclient.events.entity.player.PlayerMoveEvent; | ||
| import minegame159.meteorclient.events.entity.player.SendMovementPacketsEvent; | ||
| import minegame159.meteorclient.events.packets.PacketEvent; | ||
| import minegame159.meteorclient.mixin.PlayerPositionLookS2CPacketAccessor; | ||
| import minegame159.meteorclient.settings.*; | ||
| import minegame159.meteorclient.systems.modules.Categories; | ||
| import minegame159.meteorclient.systems.modules.Module; | ||
| import minegame159.meteorclient.utils.player.PlayerUtils; | ||
| import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; | ||
| import net.minecraft.network.packet.c2s.play.TeleportConfirmC2SPacket; | ||
| import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.util.math.Vec3d; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| public class PacketFly extends Module { | ||
| private final Set<PlayerMoveC2SPacket> packets = new ConcurrentSet(); | ||
| private final SettingGroup sgMovement = settings.createGroup("Movement"); | ||
| private final SettingGroup sgClient = settings.createGroup("Client"); | ||
| private final SettingGroup sgBypass = settings.createGroup("Bypass"); | ||
|
|
||
| private final Setting<Double> horizontalSpeed = sgMovement.add(new DoubleSetting.Builder() | ||
| .name("Horizontal Speed") | ||
| .description("Horizontal speed in blocks per second.") | ||
| .defaultValue(5.2) | ||
| .min(0.0) | ||
| .max(20.0) | ||
| .sliderMin(0.0) | ||
| .sliderMax(20.0) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Double> verticalSpeed = sgMovement.add(new DoubleSetting.Builder() | ||
| .name("Vertical Speed") | ||
| .description("Vertical speed in blocks per second.") | ||
| .defaultValue(1.24) | ||
| .min(0.0) | ||
| .max(5.0) | ||
| .sliderMin(0.0) | ||
| .sliderMax(20.0) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> sendTeleport = sgMovement.add(new BoolSetting.Builder() | ||
| .name("Teleport") | ||
| .description("Sends teleport packets.") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setYaw = sgClient.add(new BoolSetting.Builder() | ||
| .name("Set Yaw") | ||
| .description("Sets yaw client side.") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setMove = sgClient.add(new BoolSetting.Builder() | ||
| .name("Set Move") | ||
| .description("Sets movement client side.") | ||
| .defaultValue(false) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setPos = sgClient.add(new BoolSetting.Builder() | ||
| .name("Set Pos") | ||
| .description("Sets position client side.") | ||
| .defaultValue(false) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setID = sgClient.add(new BoolSetting.Builder() | ||
| .name("Set ID") | ||
| .description("Updates teleport id when a position packet is received.") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> noClip = sgClient.add(new BoolSetting.Builder() | ||
| .name("NoClip") | ||
| .description("Makes the client ignore walls.") | ||
| .defaultValue(false) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> antiKick = sgBypass.add(new BoolSetting.Builder() | ||
| .name("Anti Kick") | ||
| .description("Moves down occasionally to prevent kicks.") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Integer> downDelay = sgBypass.add(new IntSetting.Builder() | ||
| .name("Down Delay") | ||
| .description("How often you move down when not flying upwards. (ticks)") | ||
| .defaultValue(4) | ||
| .sliderMin(1) | ||
| .sliderMax(30) | ||
| .min(1) | ||
| .max(30) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Integer> downDelayFlying = sgBypass.add(new IntSetting.Builder() | ||
| .name("Down Delay (Flying)") | ||
| .description("How often you move down when flying upwards. (ticks)") | ||
| .defaultValue(10) | ||
| .sliderMin(1) | ||
| .sliderMax(30) | ||
| .min(1) | ||
| .max(30) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> invalidPacket = sgBypass.add(new BoolSetting.Builder() | ||
| .name("Invalid Packet") | ||
| .description("Sends invalid movement packets.") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private int flightCounter = 0; | ||
| private int teleportID = 0; | ||
|
|
||
| public PacketFly() { | ||
| super(Categories.Movement, "Packet Fly", "Fly using packets."); | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onSendMovementPackets(SendMovementPacketsEvent.Pre event) { | ||
| mc.player.setVelocity(0.0,0.0,0.0); | ||
| double speed = 0.0; | ||
| boolean checkCollisionBoxes = checkHitBoxes(); | ||
|
|
||
| speed = mc.player.input.jumping && (checkCollisionBoxes || !(mc.player.input.movementForward != 0.0 || mc.player.input.movementSideways != 0.0)) ? (antiKick.get() && !checkCollisionBoxes ? (resetCounter(downDelayFlying.get()) ? -0.032 : verticalSpeed.get()/20) : verticalSpeed.get()/20) : (mc.player.input.sneaking ? verticalSpeed.get()/-20 : (!checkCollisionBoxes ? (resetCounter(downDelay.get()) ? (antiKick.get() ? -0.04 : 0.0) : 0.0) : 0.0)); | ||
|
|
||
| Vec3d horizontal = PlayerUtils.getHorizontalVelocity(horizontalSpeed.get()); | ||
|
|
||
| mc.player.setVelocity(horizontal.x, speed, horizontal.z); | ||
| sendPackets(mc.player.getVelocity().x, mc.player.getVelocity().y, mc.player.getVelocity().z, sendTeleport.get()); | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onMove (PlayerMoveEvent event) { | ||
| if (setMove.get() && flightCounter != 0) { | ||
| event.movement = new Vec3d(mc.player.getVelocity().x, mc.player.getVelocity().y, mc.player.getVelocity().z); | ||
| if (noClip.get() && checkHitBoxes()) { | ||
| mc.player.noClip = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onPacketSent(PacketEvent.Send event) { | ||
| if (event.packet instanceof PlayerMoveC2SPacket && !packets.remove((PlayerMoveC2SPacket) event.packet)) { | ||
| event.setCancelled(true); | ||
| } | ||
| } | ||
|
|
||
| @EventHandler | ||
| public void onPacketReceive(PacketEvent.Receive event) { | ||
| if (event.packet instanceof PlayerPositionLookS2CPacket && !(mc.player == null || mc.world == null)) { | ||
| BlockPos pos = new BlockPos(mc.player.getPos().x, mc.player.getPos().y, mc.player.getPos().z); | ||
| PlayerPositionLookS2CPacket packet = (PlayerPositionLookS2CPacket) event.packet; | ||
| if (setYaw.get()) { | ||
| ((PlayerPositionLookS2CPacketAccessor) event.packet).setPitch(mc.player.pitch); | ||
| ((PlayerPositionLookS2CPacketAccessor) event.packet).setYaw(mc.player.yaw); | ||
| } | ||
| if (setID.get()) { | ||
| teleportID = packet.getTeleportId(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private boolean checkHitBoxes() { | ||
| return !(mc.world.getBlockCollisions(mc.player, mc.player.getBoundingBox().expand(-0.0625,-0.0625,-0.0625)).count() == 0); | ||
| } | ||
|
|
||
| private boolean resetCounter(int counter) { | ||
| if (++flightCounter >= counter) { | ||
| flightCounter = 0; | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private void sendPackets(double x, double y, double z, boolean teleport) { | ||
| Vec3d vec = new Vec3d(x, y, z); | ||
| Vec3d position = mc.player.getPos().add(vec); | ||
| Vec3d outOfBoundsVec = outOfBoundsVec(vec, position); | ||
| packetSender(new PlayerMoveC2SPacket.PositionOnly(position.x, position.y, position.z, mc.player.isOnGround())); | ||
| if (invalidPacket.get()) { | ||
| packetSender(new PlayerMoveC2SPacket.PositionOnly(outOfBoundsVec.x, outOfBoundsVec.y, outOfBoundsVec.z, mc.player.isOnGround())); | ||
| } | ||
| if (setPos.get()) { | ||
| mc.player.setPos(position.x, position.y, position.z); | ||
| } | ||
| teleportPacket(position, teleport); | ||
| } | ||
|
|
||
| private void teleportPacket(Vec3d pos, boolean shouldTeleport) { | ||
| if (shouldTeleport) { | ||
| mc.player.networkHandler.sendPacket(new TeleportConfirmC2SPacket(++teleportID)); | ||
| } | ||
| } | ||
|
|
||
| private Vec3d outOfBoundsVec(Vec3d offset, Vec3d position) { | ||
| return position.add(0.0, 1500.0, 0.0); | ||
| } | ||
|
|
||
| private void packetSender(PlayerMoveC2SPacket packet) { | ||
| packets.add(packet); | ||
| mc.player.networkHandler.sendPacket(packet); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.