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

My mod sends a packet to clients that are supposed to send the contents back. The server doesn't have any problems sending the packet to clients, and the first player to connect receives the packet, but the return message never gets sent. If the first player reconnects then everything functions properly. To be clear I want the ModCheckMessageHandler to send a HasModMessage to the server, which never receives the message.

Client Handler: 

public static class ModCheckMessageHandler implements IMessageHandler<ModCheckMessage, HasModMessage> {

	@Override
	public HasModMessage onMessage(ModCheckMessage message, MessageContext ctx) {
	    MineCalc.LOGGER.info("Server has MineCalc installed");
	    return new HasModMessage(message.name);
	}

    }

Server Handler:

public static class HasModMessageHandler implements IMessageHandler<HasModMessage, IMessage> {

	@Override
	public IMessage onMessage(HasModMessage message, MessageContext ctx) {
	    MineCalc.LOGGER.info(message.name + " returned HasModMessage");
	    Calculate.hasMod.add(message.name);
	    return null;
	}

    }

How handlers are registered on client and server:

NetHub.NETWORKWRAPPER.registerMessage(ModCheckMessageHandler.class, ModCheckMessage.class,
		NetHub.packetDiscriminator++, Side.CLIENT);
NetHub.NETWORKWRAPPER.registerMessage(HasModMessageHandler.class, HasModMessage.class,
		NetHub.packetDiscriminator++, Side.SERVER);

What's wrong?

Edited by Blackop778
Being clear

  • Author

So I was writing a response but it turns out the vanilla client disconnects when I send it a modded packet from a forge server running my mod compiled into a jar, which it didn't do while running a server with gradle runServer. Maybe you can help me figure that out for now. Error message from server is "Internal Exception: io.netty.handler.codec.EncoderException: java.io.IOException: Can't serialize unregistered packet"

 

I'm creating a system that translates error messages server-side for players that don't have my mod installed. When a client connects the server sends a packet that contains the player that joined's name, which is message.name. The client sends the packet back to let the server know it has my mod and doesn't need pre-translated messages.

Edited by Blackop778

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.