Wiki 9Minecraft Wiki 9Minecraft
Event Wrapper Wiki › Guides › Migrate Existing Forge Events to Cross-Loader Code

Migrate Existing Forge Events to Cross-Loader Code

Identify Your Current Event Listeners

Locate all classes using @EventBusSubscriber and methods with Forge event parameters. These are candidates for migration.

Replace Annotations Step by Step

1. Change @EventBusSubscriber to @EventBusSubscriberWrapper

2. Change individual @SubscribeEvent annotations to @SubscriberEventWrapper

3. Replace Forge event types with their wrapper equivalents (e.g., LivingHealEvent becomes LivingHealEventWrapper)

Update Method Signatures

`java

// Before (Forge only)

@SubscribeEvent

public static void onHeal(LivingHealEvent event) { }

// After (Forge + Fabric)

@SubscriberEventWrapper

public static void onHeal(LivingHealEventWrapper event) { }

`

Verify Compatibility

Your event handling logic usually stays the same. Test on Forge first to ensure nothing broke, then test on Fabric. If you encounter issues, check that all wrapper types you're using are supported by the mod.