Search in sources :

Example 1 with PlayerMoveC2SPacketAccessor

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;
        }
    }
}
Also used : PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) PlayerMoveC2SPacketAccessor(meteordevelopment.meteorclient.mixin.PlayerMoveC2SPacketAccessor) EventHandler(meteordevelopment.orbit.EventHandler)

Aggregations

PlayerMoveC2SPacketAccessor (meteordevelopment.meteorclient.mixin.PlayerMoveC2SPacketAccessor)1 EventHandler (meteordevelopment.orbit.EventHandler)1 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)1