add magic (please don't skid)

This commit is contained in:
Chayapak 2023-05-05 19:52:11 +07:00
parent 536fcdf62d
commit 40f29978ea

View file

@ -6,6 +6,7 @@ import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager; import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import net.minecraft.network.listener.PacketListener; import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -29,8 +30,18 @@ public class ClientConnectionMixin {
} }
} }
@Inject(method = "handlePacket", at = @At("HEAD")) @Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
private static void handlePacket (Packet packet, PacketListener _listener, CallbackInfo ci) { private static void handlePacket (Packet packet, PacketListener _listener, CallbackInfo ci) {
// please don't skid this.,.
// mabe mabe mabe
if (packet instanceof ParticleS2CPacket t_packet) {
final double max = 1000;
if (t_packet.getCount() > max) {
ci.cancel();
}
}
for (Listener listener : ListenerManager.listeners) { for (Listener listener : ListenerManager.listeners) {
listener.packetReceived(packet); listener.packetReceived(packet);
} }