Making a plugin that uses forge mod

Hi,

I developed my own entities in a forge mod and I would like to use them in a sponge plugin. Is that possible? If so, how?

And in a larger way, is it possible to link mods source code to sponge plugins?

Thank you in advance,
Lepticed.

Sponge operates via mixins. Because of this, you can simply cast back and forth. Sponge does its hacks, and then not only do all the vanilla entities implement Sponge’s Entity, but so do yours. The same goes for ItemType, ItemStack, Player, etc.

So,

Entity entity = getSomeEntityFromSponge();
MyModdedEntity moddedEntity = (MyModdedEntity) entity;
1 Like

Hi,

I’ve my entities in my forge mod and nothing in my plugin. Moreover, my plugin and my mod are two different projects in eclipse.

For example, if I need to spawn an modded entity from my sponge plugin, and this entity is only defined in my forge mod, what can I do? Do I have to add some imports or to modify build path?

I’ve never done this before, but adding your mod project to the build path of your plugin might fix that.

What I would do if I ever had this problem is upload the Git repository of the mod, and then use it as a dependency in the plugin. This way the chain’s unbroken.

This is of course assuming that you’re making it open source; if not, just import it as a dependent module.

1 Like

Yes it is possible. I made for example bridge between griefprevention plugin and skyresources mod.

We work together with Lepticed, and here is what I encountered as I was following your instructions :slight_smile:

Here, we were trying to spawn a modded entity based on a command, but as we tried to access net.minecraft classes, we got a NoSuchMethodError each time… We tried to add the forgeSrc-XXX.jar to the Build Path, but nothing is working, despite eclipse being totally right with our code.

[150:46] [Server thread/ERROR] [Sponge]: Error occurred while executing command 'updateburrows' for source DedicatedServer: net.minecraft.entity.EntityCreature.setLocationAndAngles(DDDFF)V
java.lang.NoSuchMethodError: net.minecraft.entity.EntityCreature.setLocationAndAngles(DDDFF)V
        at net.mcfr.burrow.Burrow.spawnNewCreature(Burrow.java:60)

Have you set up forgegradle correctly?
You need to use a forgegradle project to launch in a development environment.

I had some problems too, so i used a usefull intellij plugin named Minecraft Development. With* this plugin i was able to create a forge + sponge mod/plugin, and then i just needed to add the .jar of the mod that i wanted* to use to my build.gradle :slight_smile:
(of course, you can do it without the plugin* too, just install forge’s mdk, and then add sponge and your mod to the build.gradle dependencies)

For more info on this plugin: https://minecraftdev.org
Feel free to direct questions related to the plugin to me.

2 Likes