Communication between SpongeForge Plugin and Forge Mod

Hi there.

My question was posted a few times, like here and here, but I didn’t find an concrete answer :smiley:.
To clarify: I’ve ported my really old Bukkit plugin to Forge and now I want to include some mods, communicating with this specific plugin. It handles stuff like role-specific skins (browser-roleplay-system), or a browser-driven eco-system.

Let’s say, I want to sync a money-mod with the eco-system of my plugin. Where do I start? Are there already examples? The problem is I think I know how to realize this - in theory - but I don’t know forge well enough :frowning:

Man thanks in advance

Either you or the mod needs to make a bridge from the mod to Sponge. What the actual process is, though, entirely depends on what the mod is and how it functions. For example, how does the money mod work? Do you mean that it uses money items? Does it keep track of money as part of player data?

Mmh, maybe the money part is a bad example, since I can catch the money item events like dropping within my plugin - I guess.
But yes, the plugin holds information that I want to access via the mod… the race of a player, the landmark the player is standing in, browser-based buffs and debuffs… sure, I could reimplement the plugin logic within the mod, but I thought it would be easier if I’m able to let them communicate with each other.

Exactly. So, rather than reimplementing plugin logic within the mod, add Sponge functionality to the mod. Use the Data API and mixins to add accessors for the race, landmark, etc. Add new catalog classes with all the ItemTypes and BlockTypes in the mod. Make an API for the mod in as near a style as Sponge’s as you can. ThaumicSponge is a good example.

Tanks for the link ^^ Sadly, I don’t understand the approach in this example. Since I’m not an experienced forge modder, I thought that core mods are used for manipulating vanilla stuff that “can’t” be reached via forge. Or is this a precondition for mixins, cause of bytecode-stuff? I should probably start diving into this mixin things :sweat:
I guess this is the most common way for this sort of communication? Seems quite complicated.

I think(I really don’t know it for sure) that you could rely in your mod on sponge just by adding a sponge api dependency in the build.gradle of your mod. Then at runtime the mod gets the plugin container of the plugin by its id. Then you can cast the plugin instance to the actual plugin instance. Now you can access the plugin “main” class with your mod.
The other way around is exactly the same.

You don’t need to be a coremod to use mixins. Sponge is the thing that handles mixins. You need to be a coremod to do the Forge equivalent.