Forge Mod and Sponge Plugin Event

I am looking to fire a custom event from a forge mod that is processed by a sponge plugin as well as do the opposite. It is my understanding that the event bus is shared so this should be possible, but at the same time the base Forge API has a different Event class that must be extended than Sponge’s Event interface. How do I make an event that can be understood in both the mod and the plugin?

1 Like

If your event extends from one of the forge events that sponge mixes into, pure sponge plugins will be able to see the basic usage of the event as your mod’s event will be mixed into also.

If it’s a completely custom event, you could make a tiny sponge plugin as a compatibility module that contains the event interface which extends the forge one, then implement that in your mod, that way people wanting to act on the event only need the compatibility plugin/mod(since it relies on forge it’s now implementation dependent so maybe not technically a plugin, but since it’s compatibility for a forge mod I don’t see the issue with this.) in order to manipulate it.

There is probably a simpler way but this seems like an easy start.

Just implement org.spongepowered.api.event.Event (or an appropriate sub-interface) in your event for sponge plugins to listen to it.