Back to 9Minecraft
Wiki 9Minecraft Wiki 9Minecraft
Annotated Di Forge Wiki › Guides › Add Custom Modules to the Injector

Add Custom Modules to the Injector

Module Registry System

Annotated DI Mod includes a registry where you can add custom modules before the injector is created. This lets you define complex bindings and custom injection rules specific to your mod.

Adding a Module

1. Create a custom module that extends Guice's Module class and defines your bindings.

2. Register it early using the mod's module registry before the injector initializes. The registry accepts modules and applies them when the injector is built.

3. Define bindings in your module for interfaces, implementations, and any special cases where automatic @ImplementedBy annotation won't work.

When to Use Custom Modules

Use custom modules when you need to bind multiple implementations to the same interface, configure singletons, or handle third-party classes that can't be annotated. This keeps your injection setup flexible and centralized in one place rather than scattered across annotations.