Set Up Dependency Injection in Your Mod
Understanding the Injector
Annotated DI Mod provides a central injector for your mod that automatically wires dependencies together. This replaces manual object creation and passing with clean, annotation-based injection.
Basic Setup
1. Create an injectable class by adding the @ImplementedBy annotation to your interface or class. This tells the injector how to instantiate it.
2. Access the injector through the mod's central injector instance. Each mod using Annotated DI gets its own injector automatically.
3. Request instances by calling the injector's injection methods with your class. The injector resolves all nested dependencies automatically.
Using Injected Classes
Once set up, you can request instances anywhere in your mod's code. The injector handles creating objects and satisfying their dependencies without you writing factory code or configuration files. This keeps your codebase organized and makes it easier to swap implementations later for testing or features.