As the title suggests, I am developing a Forge mod and my friend is developing a Sponge plugin. Basically, he is developing a PvP plugin and I am developing a Forge mod to add custom stuff (entities, blocks, items, …) and I also would like to create an interface (GUI) to facilitate the PvP management of his plugin.
Regarding the way to develop it, I was thinking about - when the player opens the interface - sending a packet to the plugin so that the plugin can send back a packet with all the data needed to fill the interface.
Is it possible to do it so ? If yes, how could we achieve this ?
Okay, so I need to weigh in on this, as so far I’m the only person who has actually done this.
It is not NEARLY as easy as it should be.
Why? Because fucking Forge. Yes I’ve already screamed at LexManos. No he didn’t listen to me.
Forge does not allow you to register only a single side of a network channel. It requires you to register BOTH network channels together. This means that if a plugin and a mod both want to register a channel, you CANNOT have the server plugin installed on the client.
This MIGHT be fine for some things, but not always.
My plugin FoxCore has a way of resolving this issue, by abstracting away the implementation details of registering networking channels on both the client and the server, but it’s not the cleanest solution in the world. In fact, it’s anything but.
I need to handle what happens when both the client mod and the server plugin are installed simultaneously (on the client):
Basically what’s happening here, is that the server plugin always registers its network channels before the client mod does, so the client checks if the network channel has already been registered on the client side. If it has, it grabs the client channel and modifies the Netty pipeline, inserting its own handler into it and removing the sponge handler.
I’m actually going to be switching over to LiteLoader sometime in the near future, as it is much better suited for CUI stuff than Forge is, but this is how you would need to do it on Forge if you want the Sponge plugin to be install-able on the client as well.
I am VERY tempted to make a PR to forge to fix this issue, but I have a vague feeling it wouldn’t be pulled. Maybe if I have time. There’s no hurt in trying i suppose. Most of the effort is actually setting up the forge workspace, rather than making the code changes. Maybe i’ll just make the changes in an ordinary editor or something.
Okay, right now I’ve never been more confused in the modding/plugin development.
That’s not a Sponge question, that’s a Forge question. Just send the packet as you would normally.
I’m sorry about that (and I feel sorry if I didn’t post my question on the right forum). It’s just that I don’t understand how networking works from a Forge mod side and from a Sponge plugin side, that is what are the differences between them.
Thus again, @gravityfox is talking about a ““dirty way”” to solve this (which I don’t understand a thing at all), and @ZephireNZ is telling me that it is totally possible with ChannelRegistrar. I don’t know what to do right now, really.
I really feel sorry to bother you guys, I’m trying my best to understand fully what are the concepts and what can I do to go towards in my development, I tried to find some tutorials or GitHub samples regarding ChannelRegistrar usage and implementation but I didn’t find anything concrete. I tried to look the documentation and I didn’t find a thing, I took a look at the javadocs but I can’t achieve a thing just with descriptions of classes. Regarding the Forge development, I already achieved packets sending/receiving in the past, but it seems that it’s at a new hardcore level for me on how to communicate between a mod and a plugin. The thing I also don’t understand is why should we implement Sponge things in a Forge (or vice-versa) like Events or something else, since mod and plugins aren’t the same things ?
Basically what you should get out of this is that it’s a giant pain in the ass to get sponge plugins to talk to forge mods. You really need to know what you’re doing, and while people can kinda direct you toward what you need to do, there is no EASY way of doing it.
And as you mentioned it’s due to a limitation in Forge, not in Sponge.
It’s worth mentioning that because Sponge is [currently] server-only, and liteloader is [mainly] client-only, liteLoader will let you register a channel on either side selectively because it’s designed for using channels in this way.
If you want to make a client-side mod for controlling a server-side plugin, you should consider liteloader because that’s basically what it’s for.
I am assuming that there is no way that I can send or receive any data from a Sponge plugin into a Forge, right ?
EDIT : could you provide me an example of usage and implementation of ChannelBinding and ChannelRegistrar ? Since @ZephireNZ said it is possible for a modded client to communicate to Sponge and vice versa, maybe I can do it.
Late to the party here - I assumed you were simply asking how to send packets. We’ve had a recent influx of people who don’t understand that Sponge and Forge can actually access each other’s classes. Sorry.