Making a Sponge/Forge Coremod hybrid (Sponge Plugin w/ Mixins)

Hello,

So I’m currently evaluating the use of Sponge to serve my needs, but a flaw is apparent. In the past (with Bukkit/Spigot), although discouraged, there were methods available for advanced developers to directly interact with the Minecraft server (such as casting to the implementation’s wrapper [CraftItem]). From what I’ve observed, the only way to do so is with Forge’s tweaker server (net.minecraftforge.gradle.tweaker-server in [https://github.com/SpongePowered/SpongeCommon/blob/master/build.gradle#L20][1]). Personally, I’ve only used Maven for dependency and build management in the past, so I’m fairly new to Gradle. So, my question is: has anyone successfully been able to access net.minecraft.server imports using Gradle without the rest of Sponge’s implantation spiel (or the Forge Modding environment as I still would like to use Sponge)? If so, could they provide an example of their build.gradle (or any other relevant Gradle files)?

Best regards,
Horus
[1]: https://github.com/SpongePowered/SpongeCommon/blob/master/build.gradle#L20

SpongeForge provides an SDK which uses ForgeGradle - the system that’s allows you to integrate MCP into your environment.
There is a link on the SpongeForge downloads page, you can also get the source from this link:
https://github.com/SpongePowered/Sponge/tree/master/sdk

2 Likes

The sdk is broken. It uses fg1 and lacks a gradle wrapper.

A little patience please, the SDK will get updated to FG2 asap :wink:

Actually the sdk is not that useful. The sdk is for a plugin that works on SpongeForge but not multiple platforms. If it wants to work on multiple platforms, it just need to compile SpongeAPI.

@liach

Actually, I had a long conversation with some Sponge devs on IRC, and they told me to create my own Forge CoreMod. Essentially their reasoning was that is the only way to have Sponge + Mixins/NMS imports. So from what I understand, create a Forge Mod/CoreMod and then add the Sponge API on top? Sorry to digress off your topic, but that’s ultimately the issue in question here. Let me know if you’re aware of an alternate method, instead.

As Zidane (?) has told you already:
Only Forge coremods can use Mixins, so if you want to use them you have to develop a coremod. You create your coremod and use Sponge as a dependency. This way you can use Sponge to build your plugin/mod (and hopefully be safe when MC 1.9 is released) and use Forge stuff + mixins (which will probably break with 1.9).

1 Like

@Tzk @ZephireNZ @jk_5 @gabizou

Again, my thankfulness for all the help I’ve received.

So what I’ve done is setup the FML dev environment, and then attempted to mimic what Sponge does. Of course note that I’m just testing this so excuse the fact that I’m using the example package/mod-I’m just trying to get this to function.

Does this look even remotely close to what should be done? Again, I’m just trying to get this to function.




Use newest Forge instead of FML. Your DummyModContainer does not need to implement PluginContainer actually, as mixin injects. Btw you do not need a coremod for now; just a normal mod that requires after sponge mod is good enough. If you want to use mixin it might be better to make a tweaker instead of using a coremod.

2 Likes

@Horus
I had the same issue a while back with a older sponge/forge version, but I managed to get it working (but not in eclipse). I just updated it to the latest ForgeGradle (like Sponge did), I also needed it in one of my small projects so you can use that one as example: GitHub - Cybermaxke/Weathers: Brings more types of weather to your minecraft server.

You should probably also step a bit back from using custom tweakers if you are planning on only using the Mixin environment, I have had some issues with it and you can easily add your own mixins through a core mod.

@Cybermaxke
Thanks for the advice. I’m actually not planning on using any custom tweakers, rather sticking with Mixins only. I attempted to recreate the environment setup on Weathers but I have been continuously getting a:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

Do you possibly know anything about that? Also, is the Mod mandatory with the Coremod?

Regards,
Horus

@Horus
Are you shadowing dependencies into you jar? Because that seems to be the main cause that can throw that error. (http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar)
And if you don’t need a mod, you can just make ‘getModContainerClass’ return null.

@Cybermaxke

So for it to operate it correctly, shall I add the dependencies as “compile” in the build.gradle, but remove any extracted sources from the build artifact?

EDIT: So removing all the extracted sources did the trick. I also created a manifest and added the Coremod’s definition, so that’s loading now. The final remaining issue is that now that the Coremod is loading, Sponge is no longer detecting the plugin class (even though it’s annotated).

1 Like

@Horus You can add: 'FMLCorePluginContainsFMLMod':true to your manifest attributes to make forge/sponge search for mods/plugins. :wink: