Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
import net.minecraft.network.protocol.game.ServerboundClientTickEndPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.server.network.EventLoopGroupHolder;
import org.jspecify.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand Down Expand Up @@ -82,6 +86,26 @@ private void onSendPacketTail(Packet<?> packet, @Nullable ChannelFutureListener
MeteorClient.EVENT_BUS.post(new PacketEvent.Sent(packet, (Connection) (Object) this));
}

@Unique
private boolean sentPositionThisTick;

@Inject(method = "doSendPacket(Lnet/minecraft/network/protocol/Packet;Lio/netty/channel/ChannelFutureListener;Z)V", at = @At("HEAD"))
private void onDoSendPacket(Packet<?> packet, @Nullable ChannelFutureListener listener, boolean flush, CallbackInfo ci) {
if (packet instanceof ServerboundClientTickEndPacket) {
sentPositionThisTick = false;
return;
}

if (!(packet instanceof ServerboundMovePlayerPacket move) || !move.hasPosition()) return;

if (sentPositionThisTick) sendPacket(ServerboundClientTickEndPacket.INSTANCE, null, false);

sentPositionThisTick = true;
}

@Shadow
private void sendPacket(Packet<?> packet, @Nullable ChannelFutureListener listener, boolean flush) {}

@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
private void exceptionCaught(ChannelHandlerContext ctx, Throwable cause, CallbackInfo ci) {
AntiPacketKick apk = Modules.get().get(AntiPacketKick.class);
Expand Down