"Fail Silently" Mixins

I have a mixin that often conflicts with other mods. Since my mixin isn’t very important for the functionality of my mod, I want it to simply be skipped if it throws an InvalidInjectionException or anything. Is there a way to do this?

Hello!
You can’t directly catch InvalidInjectionException in Mixin, but you can make your mixin optional by using require = 0 in your @Inject annotations so failed injections are skipped silently. For more control, you can use a Mixin plugin’s shouldApplyMixin method or @Pseudo to conditionally apply mixins only when safe, ensuring conflicts don’t crash your mod.

Hello!
In Mixin you can’t just “catch” an InvalidInjectionException at runtime — the framework treats failed injections as fatal. The way to make a mixin optional is to mark your injection with require = 0 (or expect = 0 depending on the annotation). That tells Mixin to skip the handler if the target isn’t found, instead of throwing. Alternatively, you can conditionally load the mixin or separate it into its own config, but the simplest fix is to set require = 0 so it won’t crash when conflicts occur.