packetfly fixes!!
All checks were successful
/ Build BaseBand (push) Successful in 2m32s

This commit is contained in:
Daniella / Tove 2024-10-05 08:56:36 +02:00
parent 0e0d3a6283
commit 3d5c5f5a46
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
5 changed files with 80 additions and 58 deletions

View file

@ -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.Config;
import de.com.baseband.client.registry.annotation.Description; import de.com.baseband.client.registry.annotation.Description;
import de.com.baseband.client.registry.annotation.Range; 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.client.CPacketKeepAlive;
import net.minecraft.network.play.server.SPacketKeepAlive; import net.minecraft.network.play.server.SPacketKeepAlive;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
@ -70,12 +71,7 @@ public class Ping extends Feature {
if(holder == null || !holder.passed()) if(holder == null || !holder.passed())
break; break;
this.holderRecv.remove(); this.holderRecv.remove();
try { PacketUtils.emulatePacketRead(allowRecv = holder.packet);
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();
}
} }
} }
@ -88,17 +84,10 @@ public class Ping extends Feature {
return; return;
} }
while(!holderSend.isEmpty()) { while(!holderSend.isEmpty()) {
allowSend = holderSend.remove().packet; mc.player.connection.sendPacket(allowSend = holderSend.remove().packet);
mc.player.connection.sendPacket(allowSend);
} }
while(!holderRecv.isEmpty()) { while(!holderRecv.isEmpty()) {
allowRecv = holderRecv.remove().packet; PacketUtils.emulatePacketRead(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();
}
} }
} }

View file

@ -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.FieldFinder;
import de.com.baseband.client.util.adapt.Marker; import de.com.baseband.client.util.adapt.Marker;
import de.com.baseband.client.util.interact.ServerDataManager; 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.entity.Entity;
import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.play.client.CPacketEntityAction; import net.minecraft.network.play.client.CPacketEntityAction;

View file

@ -92,6 +92,11 @@ public class PacketFly extends Feature {
return; 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++; time++;
if(mc.getRenderViewEntity() == mc.player) { if(mc.getRenderViewEntity() == mc.player) {
@ -101,23 +106,21 @@ public class PacketFly extends Feature {
double x = movementVec.x * f2 - movementVec.y * f1; double x = movementVec.x * f2 - movementVec.y * f1;
double y = (mc.player.movementInput.jump ? 1 : 0) + (mc.player.movementInput.sneak ? -1 : 0); double y = (mc.player.movementInput.jump ? 1 : 0) + (mc.player.movementInput.sneak ? -1 : 0);
double z = movementVec.y * f2 + movementVec.x * f1; double z = movementVec.y * f2 + movementVec.x * f1;
if(noFlyKick && time % 20 == 0) if(y != 0 || noFlyKickBegin) {
y = -1;
if(noFlyKick && time % 20 == 1)
y = 1;
if(y != 0) {
verticalTimeout = ServerDataManager.asyncTimeToSurelyTicked(); verticalTimeout = ServerDataManager.asyncTimeToSurelyTicked();
} }
if(verticalTimeout-- > 0) { if(verticalTimeout-- > 0) {
x = z = 0; x = z = 0;
} }
if(!noFlyKickBegin) {
float d = (float) Math.sqrt(x * x + y * y + z * z) / ((conservative ? 0.06249f : 0.249f) * speed); float d = (float) Math.sqrt(x * x + y * y + z * z) / ((conservative ? 0.06249f : 0.249f) * speed);
if(d == 0) { if (d == 0) {
if(moving) { if (moving && verticalTimeout < 0) {
moving = false; moving = false;
} }
if(ticksSinceMovement > 10) { if (ticksSinceMovement > 10) {
sendPosition(); sendPosition();
sendForce(); sendForce();
trackingTPPacket = 0; trackingTPPacket = 0;
@ -129,6 +132,12 @@ public class PacketFly extends Feature {
x /= d; x /= d;
y /= d; y /= d;
z /= 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.posX += x;
mc.player.posY += y; mc.player.posY += y;
@ -149,7 +158,7 @@ public class PacketFly extends Feature {
HUD.notify("Synchronizing PacketFly.", 1000); HUD.notify("Synchronizing PacketFly.", 1000);
} else { } else {
mc.player.connection.sendPacket(new CPacketConfirmTeleport(++trackingTPPacket)); mc.player.connection.sendPacket(new CPacketConfirmTeleport(++trackingTPPacket));
sendPosition(); //sendPosition();
} }
} else { } else {
trackingTPPacket = 0; trackingTPPacket = 0;
@ -169,7 +178,6 @@ public class PacketFly extends Feature {
public void onPacket(PacketEvent.Receive event) { public void onPacket(PacketEvent.Receive event) {
if(event.getPacket() instanceof SPacketPlayerPosLook && !notIngame()) { if(event.getPacket() instanceof SPacketPlayerPosLook && !notIngame()) {
SPacketPlayerPosLook pppl = ((SPacketPlayerPosLook) event.getPacket()); SPacketPlayerPosLook pppl = ((SPacketPlayerPosLook) event.getPacket());
BaseBand.LOGGER.info("Diff: " + (pppl.getY() - mc.player.posY));
if(!predict) { if(!predict) {
trackingTPPacket = -1; trackingTPPacket = -1;
return; return;

View file

@ -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();
}
}
}

View file

@ -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;
}
}
}