Skip to content

Getting Started

The_Fireplace edited this page Jun 21, 2022 · 5 revisions

Fabric Setup

To use this with your mod, include the following in build.gradle:

dependencies {
  modImplementation "dev.the-fireplace:Annotated-DI-Fabric:${project.annotateddi_version}"
  annotationProcessor "dev.the-fireplace:Annotated-DI-Fabric-Processor:${project.annotateddi_version}"
}

And in gradle.properties:

annotateddi_version=<mod version>+<minecraft version>

After that, the easiest way to get access to the Injector (and make sure it's ready to use by the time your mod initializes) is to use the DI versions of the standard entrypoints, which are called after all custom modules have been registered. To do so, edit your fabric.mod.json to add di- in front of the main, client, or server entrypoint name, making it di-main, di-client, or di-server, respectively. As of Annotated DI 4.0.0, there is no need to switch the interface your entrypoint file implements from the Fabric default interfaces. To get your mod's Injector, use Injectors.INSTANCE.getAutoInjector(yourModId).

Forge Setup

To use this with your mod, include the following in build.gradle:

dependencies {
  implementation(fg.deobf("dev.the-fireplace:Annotated-DI-Forge:${project.annotateddi_version}"))
  annotationProcessor "dev.the-fireplace:Annotated-DI-Forge-Processor:${project.annotateddi_version}"
}

And in gradle.properties:

annotateddi_version=<mod version>+<minecraft version>

To get your mod's Injector, you can call Injectors.INSTANCE.getAutoInjector(yourModId) within Forge's entrypoint.

Multiproject common module setup

Assuming you're using Forge/Fabric modules to initialize your mod and you're just in need of Annotated DI files for compiling the common module, you can include the following in your common build.gradle:

dependencies {
  implementation "dev.the-fireplace:Annotated-DI-Common:${project.annotateddi_version}"
}
Clone this wiki locally