Jump to content

IMessageHandler not sending IMessage when first player joins


Blackop778

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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