Set Up a Cross-Loader Event Handler
Create Your Event Class
Start by creating a new class that will hold your event listeners. This class needs two annotations to work across both Forge and Fabric.
Apply the Wrapper Annotations
Add @EventBusSubscriberWrapper to your class declaration. This tells the mod system to recognize your event handlers on both loaders.
For each event method you want to handle:
1. Add the @SubscriberEventWrapper annotation
2. Make the method public static
3. Add a single parameter using the appropriate wrapper event type (like LivingHealEventWrapper)
Example Structure
`java
@EventBusSubscriberWrapper
public class MyEventHandlers {
@SubscriberEventWrapper
public static void onLivingHeal(LivingHealEventWrapper event) {
// Your healing logic here
}
}
`
The wrapper automatically handles the differences between Forge and Fabric event systems. You write your logic once, and it runs correctly on both platforms without additional setup or conditional code.