blob: 29fc19d2834dc73db08ffcdc98466430b2ba7e87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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();
}
}
|