Integration as Dependency (Jar-in-Jar / JarJar / JiJ)
Goal: Embed this library in your mod so players don't need separate installation. This section provides approaches for both Fabric (Loom) and NeoForge (ModDevGradle).
Important Convention: Only embed the "common" artifact (without loader metadata) to avoid duplicate modId conflicts; don't embed fabric/neoforge submodules as JiJ dependencies.
Local JAR
This project is not published to any Maven repository, so you can only integrate via this method.
Steps:
- Build common artifact in this library's repository
./gradlew :common:buildBuild artifacts typically located at: TritiumConfiguration/common/build/libs/, filename like: tritium_configuration-common-<MC Version>-<Version>.jar (e.g., tritium_configuration-common-1.21-0.2.0.jar).
Copy that JAR to your mod project's
libs/directory (create if doesn't exist).Declare dependency and embed in your mod:
- Fabric (Loom):
// build.gradle (fabric module)
dependencies {
// Local JAR dependency
def tritiumCommon = files('libs/tritium_configuration-common-1.21-0.2.0.jar')
implementation tritiumCommon
include tritiumCommon // Bundle into your mod JAR (META-INF/jars)
// If needing auto UI (Cloth Config):
modImplementation "me.shedaniel.cloth:cloth-config-fabric:${fabric_cloth_config_version}"
}- NeoForge (ModDevGradle):
// build.gradle (neoforge module)
dependencies {
implementation(jarJar(files('libs/tritium_configuration-common-1.21-0.2.0.jar')))
implementation "me.shedaniel.cloth:cloth-config-neoforge:${cloth_config_version}"
}
jarJar {
relocate 'me.zcraft.tc', 'your.mod.libs.tritium'
}Tip: If your Loom/MDG version has poor support for include(files(...)) or jarJar(files(...)), use Shadow plugin as fallback:
plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' }
dependencies { implementation files('libs/tritium_configuration-common-1.21-0.2.0.jar') }
tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
relocate 'me.zcraft.tc', 'your.mod.libs.tritium'
}After configuration completes, build your mod to embed the library.
Runtime Considerations
- Only need to provide Cloth Config at runtime when using auto UI (
TritiumAutoConfig); pure config read/write doesn't need Cloth Config. - Don't call library's built-in
TritiumCommon.init()in your initialization flow; that's the library's platform entry point when running as standalone "mod". When embedded, just callTritiumConfig.register(modId, YourConfig.class). - Supported types:
boolean,int,long,double,String, enums,List\<String\>. - If you've embedded this library, don't let players install external mod with same name to avoid version conflicts.