-
-
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
Closed
Packetfly module #813
Changes from 1 commit
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
311 changes: 311 additions & 0 deletions
311
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,311 @@ | ||
| package minegame159.meteorclient.systems.modules.movement; | ||
gigglingbed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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.misc.Timer; | ||
| import net.minecraft.client.gui.screen.DownloadingTerrainScreen; | ||
| 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.Map; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| public class PacketFly extends Module { | ||
|
|
||
| private final Set<PlayerMoveC2SPacket> packets = new ConcurrentSet(); | ||
| private final Map<Integer, IDtime> teleportmap = new ConcurrentHashMap<Integer,IDtime>(); | ||
|
|
||
| private int flightCounter = 0; | ||
| private int teleportID = 0; | ||
| private float yaw; | ||
| private float pitch; | ||
gigglingbed marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private final SettingGroup sgGeneral = settings.getDefaultGroup(); | ||
|
|
||
| private final Setting<Boolean> flight = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Flight") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Integer> flightMode = sgGeneral.add(new IntSetting.Builder() | ||
| .name("Flight Mode") | ||
| .defaultValue(0) | ||
| .sliderMin(0) | ||
| .sliderMax(1) | ||
| .min(0) | ||
| .max(1) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> doAntiFactor = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Do AntiFactor") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Double> antiFactor = sgGeneral.add(new DoubleSetting.Builder() | ||
| .name("AntiFactor") | ||
| .defaultValue(2.5) | ||
| .sliderMin(0.1) | ||
| .sliderMax(3.0) | ||
| .min(0.1) | ||
| .max(3.0) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Double> extraFactor = sgGeneral.add(new DoubleSetting.Builder() | ||
| .name("ExtraFactor") | ||
| .defaultValue(1.0) | ||
| .sliderMin(0.1) | ||
| .sliderMax(3.0) | ||
| .min(0.1) | ||
| .max(3.0) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> strafeFactor = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("StrafeFactor") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Integer> loops = sgGeneral.add(new IntSetting.Builder() | ||
| .name("Loops") | ||
| .defaultValue(1) | ||
| .sliderMin(1) | ||
| .sliderMax(10) | ||
| .min(1) | ||
| .max(10) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> clearTeleMap = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Clear Teleport Map") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Integer> mapTime = sgGeneral.add(new IntSetting.Builder() | ||
| .name("Clear Time") | ||
| .defaultValue(30) | ||
| .sliderMin(1) | ||
| .sliderMax(500) | ||
| .min(1) | ||
| .max(500) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> clearIDs = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Clear IDs") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setYaw = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Set Yaw") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setID = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Set ID") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setMove = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Set Move") | ||
| .defaultValue(false) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> noClip = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("NoClip") | ||
| .defaultValue(false) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> sendTeleport = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Teleport") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> resetID = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Reset ID") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> setPos = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Set Pos") | ||
| .defaultValue(false) | ||
| .build() | ||
| ); | ||
|
|
||
| private final Setting<Boolean> invalidPacket = sgGeneral.add(new BoolSetting.Builder() | ||
| .name("Invalid Packet") | ||
| .defaultValue(true) | ||
| .build() | ||
| ); | ||
|
|
||
| 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)) ? (flight.get() && !checkCollisionBoxes ? (flightMode.get() == 0 ? (resetCounter(10) ? -0.032 : 0.062) : (resetCounter(20) ? -0.032 : 0.062)) : 0.062) : (mc.player.input.sneaking ? -0.062 : (!checkCollisionBoxes ? (resetCounter(4) ? (flight.get() ? -0.04 : 0.0) : 0.0) : 0.0)); | ||
| if(doAntiFactor.get() && checkCollisionBoxes && (mc.player.input.movementForward != 0.0 || mc.player.input.movementSideways != 0.0) && speed != 0.0) { | ||
| speed /= antiFactor.get(); | ||
| } | ||
| double[] strafing = this.getMotion(strafeFactor.get() != false && checkCollisionBoxes ? 0.031 : 0.26); | ||
| for (int i = 1; i < loops.get() + 1; ++i) { | ||
| mc.player.setVelocity(strafing[0] * (double) i * extraFactor.get(), speed * (double) i, strafing[1] * (double) i * extraFactor.get()); | ||
| 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) { | ||
| PlayerMoveC2SPacket packet; | ||
|
||
| if (event.packet instanceof PlayerMoveC2SPacket && !packets.remove(packet = (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 (mc.player.isAlive() && mc.world.isChunkLoaded(mc.world.getChunk(pos).getPos().x, mc.world.getChunk(pos).getPos().z) && !(mc.currentScreen instanceof DownloadingTerrainScreen) && clearIDs.get()) { | ||
| teleportmap.remove(packet.getTeleportId()); | ||
| } | ||
| 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 double[] getMotion(double speed) { | ||
|
||
| float moveForward = mc.player.input.movementForward; | ||
| float moveStrafe = mc.player.input.movementSideways; | ||
| float rotationYaw = mc.player.prevYaw + (mc.player.yaw - mc.player.prevYaw) * mc.getTickDelta(); | ||
| if (moveForward != 0.0f) { | ||
| if (moveStrafe > 0.0f) { | ||
| rotationYaw += (float) (moveForward > 0.0f ? -45 : 45); | ||
| } else if (moveStrafe < 0.0f) { | ||
| rotationYaw += (float) (moveForward > 0.0f ? 45 : -45); | ||
| } | ||
| moveStrafe = 0.0f; | ||
| if (moveForward > 0.0f) { | ||
| moveForward = 1.0f; | ||
| } else if (moveForward < 0.0f) { | ||
| moveForward = -1.0f; | ||
| } | ||
| } | ||
| double posX = (double) moveForward * speed * -Math.sin(Math.toRadians(rotationYaw)) + (double) moveStrafe * speed * Math.cos(Math.toRadians(rotationYaw)); | ||
| double posZ = (double) moveForward * speed * Math.cos(Math.toRadians(rotationYaw)) - (double) moveStrafe * speed * -Math.sin(Math.toRadians(rotationYaw)); | ||
| return new double[]{posX,posZ}; | ||
| } | ||
|
|
||
| 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)); | ||
| teleportmap.put(teleportID, new IDtime(pos, new Timer())); | ||
| } | ||
| } | ||
|
|
||
| private Vec3d outOfBoundsVec(Vec3d offset, Vec3d position) { | ||
| return position.add(0.0, 1337.0, 0.0); | ||
| } | ||
|
|
||
| private void packetSender(PlayerMoveC2SPacket packet) { | ||
| packets.add(packet); | ||
| mc.player.networkHandler.sendPacket(packet); | ||
| } | ||
|
|
||
| private void clean() { | ||
| teleportmap.clear(); | ||
| flightCounter = 0; | ||
| if (resetID.get()) { | ||
| teleportID = 0; | ||
| } | ||
| packets.clear(); | ||
| } | ||
|
|
||
| public static class IDtime { | ||
| private final Vec3d pos; | ||
| private final Timer timer; | ||
|
|
||
| public IDtime(Vec3d pos, Timer timer) { | ||
| this.pos = pos; | ||
| this.timer = timer; | ||
| this.timer.reset(); | ||
| } | ||
|
|
||
| public Vec3d getPos() { | ||
| return this.pos; | ||
| } | ||
|
|
||
| public Timer getTimer() { | ||
| return this.timer; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
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.