From 93a8ffa2e005e0a6f31b9031f2bccc549b4957f4 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 7 May 2023 16:07:29 +0700 Subject: [PATCH] fix stuff and patch timmy exploit... --- .../chipmunkmod/mixin/ClientConnectionMixin.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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); }