This commit is contained in:
parent
0e0d3a6283
commit
3d5c5f5a46
5 changed files with 80 additions and 58 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,23 +106,21 @@ 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;
|
||||
}
|
||||
|
||||
if(!noFlyKickBegin) {
|
||||
float d = (float) Math.sqrt(x * x + y * y + z * z) / ((conservative ? 0.06249f : 0.249f) * speed);
|
||||
|
||||
if(d == 0) {
|
||||
if(moving) {
|
||||
if (d == 0) {
|
||||
if (moving && verticalTimeout < 0) {
|
||||
moving = false;
|
||||
}
|
||||
if(ticksSinceMovement > 10) {
|
||||
if (ticksSinceMovement > 10) {
|
||||
sendPosition();
|
||||
sendForce();
|
||||
trackingTPPacket = 0;
|
||||
|
@ -129,6 +132,12 @@ public class PacketFly extends Feature {
|
|||
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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue