use of meteordevelopment.meteorclient.mixin.PlayerMoveC2SPacketAccessor in project meteor-client by MeteorDevelopment.
the class Flight method onSendPacket.
/**
* @see ServerPlayNetworkHandler#onPlayerMove(PlayerMoveC2SPacket)
*/
@EventHandler
private void onSendPacket(PacketEvent.Send event) {
if (!(event.packet instanceof PlayerMoveC2SPacket) || antiKickMode.get() != AntiKickMode.Packet)
return;
PlayerMoveC2SPacket packet = (PlayerMoveC2SPacket) event.packet;
long currentTime = System.currentTimeMillis();
double currentY = packet.getY(Double.MAX_VALUE);
if (currentY != Double.MAX_VALUE) {
// maximum time we can be "floating" is 80 ticks, so 4 seconds max
if (currentTime - lastModifiedTime > 1000 && lastY != Double.MAX_VALUE && mc.world.getBlockState(mc.player.getBlockPos().down()).isAir()) {
// actual check is for >= -0.03125D but we have to do a bit more than that
// probably due to compression or some shit idk
((PlayerMoveC2SPacketAccessor) packet).setY(lastY - 0.03130D);
lastModifiedTime = currentTime;
} else {
lastY = currentY;
}
}
}
Aggregations