Skip to content

Instantly share code, notes, and snippets.

@hohserg1
Last active March 31, 2021 23:56
Show Gist options
  • Save hohserg1/db19850b6aa0ef3926d3f4a9c26a858e to your computer and use it in GitHub Desktop.
Save hohserg1/db19850b6aa0ef3926d3f4a9c26a858e to your computer and use it in GitHub Desktop.
@SubscribeEvent
def blacklistResearchCategory1(e: FMLNetworkEvent.ServerConnectionFromClientEvent): Unit = { //Adding custom handler at server side
e.getManager.channel.pipeline
.addLast(Main.modid + ":hook_packet_handler", new PacketHook) //Work
//using addFirst gives effect, but packets look as CPacketCustomPayload
}
class PacketHook extends ChannelInboundHandlerAdapter {
override def channelRead(ctx: ChannelHandlerContext, msg: Any): Unit = {
super.channelRead(ctx, msg)
println("channelRead", msg) //nope printed
msg match {
case packet: PacketStartTheoryToServer => //Packet from thaumcraft 6
//do something
case _ =>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment