package com.ambientaddons.mixin; import com.ambientaddons.events.ReceivePacketEvent; import io.netty.channel.ChannelHandlerContext; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; // credit Harry282/Skyblock-Client, under AGPL 3.0 @Mixin(NetworkManager.class) public class MixinNetworkManager { @Inject(method = "channelRead0*", at = @At("HEAD"), cancellable = true) private void onReceivePacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { if (MinecraftForge.EVENT_BUS.post(new ReceivePacketEvent(packet))) ci.cancel(); } }