Posted August 14, 201510 yr Hello fellow Modders, for my current Project I need to store all IMessages the Client sends to the Server (and the other way around) in a File and load them later. Therefore, I'm hooking into the FML Channel using the following code: NetworkManager nm = event.manager; Channel channel = nm.channel(); for(String channelName : NetworkRegistry.INSTANCE.channelNamesFor(Side.CLIENT)) { FMLEmbeddedChannel embeddedChannel = NetworkRegistry.INSTANCE.getChannel(channelName, Side.CLIENT); embeddedChannel.pipeline().addFirst(new IMessageInboundListener()); } for(String channelName : NetworkRegistry.INSTANCE.channelNamesFor(Side.SERVER)) { FMLEmbeddedChannel embeddedChannel = NetworkRegistry.INSTANCE.getChannel(channelName, Side.SERVER); embeddedChannel.pipeline().addFirst(new IMessageOutboundListener()); } The IMessageInboundListener looks the following way: public class IMessageInboundListener extends ChannelInboundHandlerAdapter { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { int somehting = 0; if(msg instanceof FMLProxyPacket) { FMLProxyPacket proxyPacket = (FMLProxyPacket)msg; String channelName = proxyPacket.channel(); Side target = proxyPacket.getTarget(); ByteBuf buf = proxyPacket.payload(); byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); buf.readerIndex(0); //some code to store the Packet is here } super.channelRead(ctx, msg); } } Now, my question is - how do I re-send these Packets to the Server? How can I reconstruct the Packet from the byte array, channel name and target Side and where do I need to inject it? Thanks in advance, Pixel
August 15, 201510 yr The FMLProxyPacket has a constructor that takes the ByteBuf payload and a string for channel name. Before the SimpleNetworkWrapper was working, I actually made a packet system using FMLProxyPackets. I had a tutorial here: https://www.blogger.com/blogger.g?blogID=8871285205929815684#editor/target=page;pageID=4638645929701985216;onPublishedMenu=pages;onClosedMenu=pages;postNum=23;src=pagename That tutorial should show how to send and receive FMLProxyPackets. What are you trying to achieve? You realize that it might be a LOT of data to store... Check out my tutorials here: http://jabelarminecraft.blogspot.com/
August 15, 201510 yr Author Do you know the Replay Mod? https://replaymod.com We're trying to expand it to support Mod's Packets as well.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.