diff --git a/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientConnectionMixin.java b/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientConnectionMixin.java index 93cb4fe..c4d3f20 100644 --- a/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientConnectionMixin.java +++ b/src/main/java/land/chipmunk/chipmunkmod/mixin/ClientConnectionMixin.java @@ -6,6 +6,7 @@ import land.chipmunk.chipmunkmod.listeners.Listener; import land.chipmunk.chipmunkmod.listeners.ListenerManager; import net.minecraft.network.listener.PacketListener; import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket; import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; @@ -47,8 +48,15 @@ public class ClientConnectionMixin { } } - @Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("TAIL")) - private static void sendPacket (Packet packet, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) + private void sendPacket (Packet packet, CallbackInfo ci) { + if (packet instanceof RequestCommandCompletionsC2SPacket t_packet) { + if (t_packet.getPartialCommand().length() > 2048) { + ci.cancel(); + return; + } + } + for (Listener listener : ListenerManager.listeners) { listener.packetSent(packet); }