From 3d5c5f5a4656848b470bb6f738cec2433b3230e4 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sat, 5 Oct 2024 08:56:36 +0200 Subject: [PATCH] packetfly fixes!! --- .../client/feature/modules/client/Ping.java | 19 ++----- .../feature/modules/movement/NoFall.java | 2 +- .../feature/modules/movement/PacketFly.java | 50 +++++++++++-------- .../client/util/adapt/PacketUtils.java | 46 +++++++++++++++++ .../client/util/misc/PacketUtils.java | 21 -------- 5 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 Client/src/main/java/de/com/baseband/client/util/adapt/PacketUtils.java delete mode 100644 Client/src/main/java/de/com/baseband/client/util/misc/PacketUtils.java diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/client/Ping.java b/Client/src/main/java/de/com/baseband/client/feature/modules/client/Ping.java index d18a78f..1b2e3ca 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/client/Ping.java +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/client/Ping.java @@ -8,6 +8,7 @@ import de.com.baseband.client.feature.category.ClientCategory; import de.com.baseband.client.registry.annotation.Config; import de.com.baseband.client.registry.annotation.Description; import de.com.baseband.client.registry.annotation.Range; +import de.com.baseband.client.util.adapt.PacketUtils; import net.minecraft.network.play.client.CPacketKeepAlive; import net.minecraft.network.play.server.SPacketKeepAlive; import net.minecraft.network.Packet; @@ -70,12 +71,7 @@ public class Ping extends Feature { if(holder == null || !holder.passed()) break; this.holderRecv.remove(); - try { - mc.player.connection.getNetworkManager().channelRead(null, allowRecv = holder.packet); - } catch (Exception e) { - BaseBand.notifyAll("!! BaseBand encountered a BUG. Please report as soon as possible and include the game log."); - new RuntimeException("[BaseBand BUG] Cannot emulate packet read", e).printStackTrace(); - } + PacketUtils.emulatePacketRead(allowRecv = holder.packet); } } @@ -88,17 +84,10 @@ public class Ping extends Feature { return; } while(!holderSend.isEmpty()) { - allowSend = holderSend.remove().packet; - mc.player.connection.sendPacket(allowSend); + mc.player.connection.sendPacket(allowSend = holderSend.remove().packet); } while(!holderRecv.isEmpty()) { - allowRecv = holderRecv.remove().packet; - try { - mc.player.connection.getNetworkManager().channelRead(null, allowRecv); - } catch (Exception e) { - BaseBand.notifyAll("!! BaseBand encountered a BUG. Please report as soon as possible and include the game log."); - new RuntimeException("[BaseBand BUG] Cannot emulate packet read", e).printStackTrace(); - } + PacketUtils.emulatePacketRead(allowRecv = holderRecv.remove().packet); } } diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/movement/NoFall.java b/Client/src/main/java/de/com/baseband/client/feature/modules/movement/NoFall.java index 3e0e777..2af928a 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/movement/NoFall.java +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/movement/NoFall.java @@ -8,7 +8,7 @@ import de.com.baseband.client.registry.annotation.*; import de.com.baseband.client.util.adapt.FieldFinder; import de.com.baseband.client.util.adapt.Marker; import de.com.baseband.client.util.interact.ServerDataManager; -import de.com.baseband.client.util.misc.PacketUtils; +import de.com.baseband.client.util.adapt.PacketUtils; import net.minecraft.entity.Entity; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.play.client.CPacketEntityAction; diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/movement/PacketFly.java b/Client/src/main/java/de/com/baseband/client/feature/modules/movement/PacketFly.java index f723cfa..a5fb537 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/modules/movement/PacketFly.java +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/movement/PacketFly.java @@ -92,6 +92,11 @@ public class PacketFly extends Feature { return; } + boolean noFlyKick = this.noFlyKick; + if(!mc.world.getCollisionBoxes(mc.player, mc.player.getEntityBoundingBox().shrink(0.0625)).isEmpty()) + noFlyKick = false; + boolean noFlyKickBegin = noFlyKick && time % 30 <= 1; + time++; if(mc.getRenderViewEntity() == mc.player) { @@ -101,34 +106,38 @@ public class PacketFly extends Feature { double x = movementVec.x * f2 - movementVec.y * f1; double y = (mc.player.movementInput.jump ? 1 : 0) + (mc.player.movementInput.sneak ? -1 : 0); double z = movementVec.y * f2 + movementVec.x * f1; - if(noFlyKick && time % 20 == 0) - y = -1; - if(noFlyKick && time % 20 == 1) - y = 1; - if(y != 0) { + if(y != 0 || noFlyKickBegin) { verticalTimeout = ServerDataManager.asyncTimeToSurelyTicked(); } if(verticalTimeout-- > 0) { x = z = 0; } - float d = (float) Math.sqrt(x * x + y * y + z * z) / ((conservative ? 0.06249f : 0.249f) * speed); - if(d == 0) { - if(moving) { - moving = false; + if(!noFlyKickBegin) { + float d = (float) Math.sqrt(x * x + y * y + z * z) / ((conservative ? 0.06249f : 0.249f) * speed); + + if (d == 0) { + if (moving && verticalTimeout < 0) { + moving = false; + } + if (ticksSinceMovement > 10) { + sendPosition(); + sendForce(); + trackingTPPacket = 0; + positions.clear(); + } + return; } - if(ticksSinceMovement > 10) { - sendPosition(); - sendForce(); - trackingTPPacket = 0; - positions.clear(); - } - return; + + x /= d; + y /= d; + z /= d; } - x /= d; - y /= d; - z /= d; + if(noFlyKick && time % 30 == 0) + y = -0.05; + if(noFlyKick && time % 30 == 1) + y = 0.05; mc.player.posX += x; mc.player.posY += y; @@ -149,7 +158,7 @@ public class PacketFly extends Feature { HUD.notify("Synchronizing PacketFly.", 1000); } else { mc.player.connection.sendPacket(new CPacketConfirmTeleport(++trackingTPPacket)); - sendPosition(); + //sendPosition(); } } else { trackingTPPacket = 0; @@ -169,7 +178,6 @@ public class PacketFly extends Feature { public void onPacket(PacketEvent.Receive event) { if(event.getPacket() instanceof SPacketPlayerPosLook && !notIngame()) { SPacketPlayerPosLook pppl = ((SPacketPlayerPosLook) event.getPacket()); - BaseBand.LOGGER.info("Diff: " + (pppl.getY() - mc.player.posY)); if(!predict) { trackingTPPacket = -1; return; diff --git a/Client/src/main/java/de/com/baseband/client/util/adapt/PacketUtils.java b/Client/src/main/java/de/com/baseband/client/util/adapt/PacketUtils.java new file mode 100644 index 0000000..e1f63ac --- /dev/null +++ b/Client/src/main/java/de/com/baseband/client/util/adapt/PacketUtils.java @@ -0,0 +1,46 @@ +package de.com.baseband.client.util.adapt; + +import de.com.baseband.client.BaseBand; +import de.com.baseband.client.event.events.PacketEvent; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.CPacketPlayer; +import net.minecraft.network.play.server.SPacketPlayerPosLook; + +import java.lang.reflect.Field; + +import static de.com.baseband.client.BaseBand.mc; + +public class PacketUtils { + + public static void removeRotationsFrom(PacketEvent.Send event, CPacketPlayer packet) { + if(packet instanceof CPacketPlayer.Rotation) { + event.setCancelled(true); + return; + } + if(packet instanceof CPacketPlayer.PositionRotation) { + mc.player.connection.sendPacket(new CPacketPlayer.Position(packet.getX(0), packet.getY(0), packet.getZ(0), packet.isOnGround())); + event.setCancelled(true); + return; + } + } + + public static void removeRotationsFrom(SPacketPlayerPosLook packet) { + Field yaw = FieldFinder.findUnmarked(SPacketPlayerPosLook.class, float.class, 0); + Field pitch = FieldFinder.findUnmarked(SPacketPlayerPosLook.class, float.class, 1); + try { + yaw.setFloat(packet, mc.player.rotationYaw); + pitch.setFloat(packet, mc.player.rotationPitch); + } catch (IllegalAccessException e) { + throw new RuntimeException("BaseBand BUG - Code PURRFA", e); + } + } + + public static void emulatePacketRead(Packet packet) { + try { + mc.player.connection.getNetworkManager().channelRead(null, packet); + } catch (Exception e) { + BaseBand.notifyAll("!! BaseBand encountered a BUG. Please report as soon as possible and include the game log."); + new RuntimeException("BaseBand BUG - Code PUEMPR", e).printStackTrace(); + } + } +} diff --git a/Client/src/main/java/de/com/baseband/client/util/misc/PacketUtils.java b/Client/src/main/java/de/com/baseband/client/util/misc/PacketUtils.java deleted file mode 100644 index 7bc6a35..0000000 --- a/Client/src/main/java/de/com/baseband/client/util/misc/PacketUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.com.baseband.client.util.misc; - -import de.com.baseband.client.event.events.PacketEvent; -import net.minecraft.network.play.client.CPacketPlayer; - -import static de.com.baseband.client.BaseBand.mc; - -public class PacketUtils { - - public static void removeRotationsFrom(PacketEvent.Send event, CPacketPlayer packet) { - if(packet instanceof CPacketPlayer.Rotation) { - event.setCancelled(true); - return; - } - if(packet instanceof CPacketPlayer.PositionRotation) { - mc.player.connection.sendPacket(new CPacketPlayer.Position(packet.getX(0), packet.getY(0), packet.getZ(0), packet.isOnGround())); - event.setCancelled(true); - return; - } - } -}