Wiki 9Minecraft Wiki 9Minecraft

Add Custom Modules to the Injector

Java EditionModGuides 4FAQ 10Related mods 60
DownloadAnnotated DI Mod

Get the files on 9Minecraft

Contents (3)
  1. Module Registry System
  2. Adding a Module
  3. When to Use Custom Modules

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.

More guides for this mod