Shadows-of-Fire / Toast-Control

Because Mojang can't into popups.
MIT License
14 stars 6 forks source link

Bugfix/fix latest forge crash (#16) #17

Closed xdjoshuaaz closed 4 years ago

xdjoshuaaz commented 4 years ago

This PR fixes a crash as reported in #16 where Forge versions 32.0.96 and above crash with java.lang.IllegalArgumentException: Method public void shadows.toaster.ToastControl.clientTick(net.minecraftforge.event.TickEvent$ClientTickEvent) has @SubscribeEvent annotation, but takes an argument that is not a subtype of the base type interface net.minecraftforge.fml.event.lifecycle.IModBusEvent.

FMLJavaModLoadingContext.get().getModEventBus() requires all methods decorated with @SubscribeEvent to implement IModBusEvent which KeyInputEvent and ClientTickEvent does not implement. Currently, all @SubscribeEvent decorated methods are registered on both getModEventBus() and MinecraftForge.EVENT_BUS which was allowed up until 32.0.96.

To fix this, my PR separates these methods in ToastControl that use KeyInputEvent and ClientTickEvent into an anonymous object, and registers these methods on the MinecraftForge.EVENT_BUS independently of the methods intended for getModEventBus() (using FMLClientSetupEvent).