diff options
Diffstat (limited to 'src/main/java/rosegoldaddons/mixins/MixinNetworkManager.java')
-rw-r--r-- | src/main/java/rosegoldaddons/mixins/MixinNetworkManager.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/rosegoldaddons/mixins/MixinNetworkManager.java b/src/main/java/rosegoldaddons/mixins/MixinNetworkManager.java new file mode 100644 index 0000000..29fc19d --- /dev/null +++ b/src/main/java/rosegoldaddons/mixins/MixinNetworkManager.java @@ -0,0 +1,20 @@ +package rosegoldaddons.mixins; + +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; +import rosegoldaddons.events.ReceivePacketEvent; + +@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(); + } +} |