Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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/

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.