Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Network messages from client-side mod [1.14.4]


kirstym
 Share

Recommended Posts

TL;DR: Is it possible for client-side-only mods to send messages to a server using SimpleChannel.registerMessage? If so, what server config options might allow / disallow the messages? I'm getting reports of some servers working with my mods and others won't execute any of the messages.

 

I maintain some mods to allow disabled gamers to play Minecraft using eye gaze. These mods don't add any content (new blocks etc), they just make changes to the controls and automate some things. I've set it up to be client-side only, using the pattern recommended in the docs, e.g.:

 

@Mod(EyeGaze.MODID)
public class EyeGaze {

	public EyeGaze() {

		// Only load things if on client - this means if mod is loaded on server, nothing happens.
		DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {

			// Register ourselves for server and other game events we are interested in
			MinecraftForge.EVENT_BUS.register(this);

			FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
	        
			// Make sure the mod being absent on the other network side does not cause the client to display the server as incompatible	
			ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
			
			... more setup ... 
	 	}

		... more stuff ...
}

 

Some of the mods do need to send messages to the network, for instance to place a block programmatically. I use SimpleChannel.registerMessage in these situations and everything works fine when testing locally, or with a LAN world.

 

Users have reported that on some remote servers they can use the mod fine, but on other servers, any of the functionality that required message passing is failing. I don't know much about Minecraft server setup/admin, so I'm not sure what to suggest. What is the basic requirement to play on a server while using a client-side mod which requires message passing? I assume it needs the same version of Forge installed on the server, but doesn't require the same mods to be installed. Is this correct? Are there any other server config options that might change this behaviour? For example, allowing cheats? Are there any other variables that might affect whether or not my mods work with a given server?

Link to comment
Share on other sites

I am not sure how you expect this to work. If you send a custom network message to the server, but nobody is there to receive it (vanilla Minecraft certainly won't care about it), it will just be dropped. If you want to send custom network messages, you have to have the mod installed on the server to handle them.

Link to comment
Share on other sites

34 minutes ago, diesieben07 said:

I am not sure how you expect this to work. If you send a custom network message to the server, but nobody is there to receive it (vanilla Minecraft certainly won't care about it), it will just be dropped. If you want to send custom network messages, you have to have the mod installed on the server to handle them.

I'm on the same line of thought as DieSieben - or do you mean that your client-side-only mod sends vanilla messages (or "custom" messages that masquerade as vanilla messages)?

 

Could you implement your desired functionality using vanilla packets only?  The use-cases you described sound like it might be possible (eg changes to controls, placing blocks, etc)

 

-TGG

Link to comment
Share on other sites

Okay, that makes sense, thanks. I certainly wouldn't expect vanilla Minecraft to know what to do, but I wasn't sure whether having Forge installed would be sufficient - mainly because I had some users report success playing on public servers which wouldn't have the mods installed on them.

 

Trying to limit usage to vanilla packets sounds like a good idea - where would I look to see what packets are available?

Link to comment
Share on other sites

From memory; All the packets that  your client could send are named CXXXXXPacket

eg CInputPacket

 

IServerPlayNetHandler also lists the interesting ones (that is the class on the server that processes the incoming packets).

 

-TGG

 

 

 

 

 

 

 

 

 

 

 

 

Edited by TheGreyGhost
1.16.4 not 1.12.2
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.

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.