Skip to content

Commit

Permalink
OneConfig 😊😄😃
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Dec 29, 2024
1 parent 414f97d commit e9b4e65
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,23 @@ abstract class LoomHelperExtension(
project.dependencies.add("implementation", fullLoaderDependency)
}

if (builder.usePolyMixin) {
if (builder.usePolyMixin && isUsingLoader()) {
val polyMixinVersion = builder.polyMixinVersion ?: throw NullPointerException("polyMixinVersion must be set when using PolyMixin.")
val polyMixinDependency = "org.polyfrost:polymixin"
project.dependencies.add(if (isUsingLoader()) "compileOnly" else "implementation", "$polyMixinDependency:$polyMixinVersion")
project.dependencies.add("annotationProcessor", "$polyMixinDependency:$polyMixinVersion")
}

val dependencies = builder.modules + "${minecraftVersion}-${modLoader}"
for (dep in dependencies) {
val dependencies = builder.modules.map { it to false } + ("${minecraftVersion}-${modLoader}" to true)
for ((dep, isMod) in dependencies) {
val dependency = "org.polyfrost.oneconfig:$dep"
project.dependencies.add(if (isUsingLoader()) "modCompileOnly" else "modImplementation", "$dependency:${builder.version}")
val configuration = if (isMod) {
if (isUsingLoader()) "modCompileOnly" else "modImplementation"
} else {
if (isUsingLoader()) "compileOnly" else "implementation"
}

project.dependencies.add(configuration, "$dependency:${builder.version}")
}
}

Expand Down Expand Up @@ -333,6 +340,7 @@ abstract class LoomHelperExtension(
val mixinExtras = "io.github.llamalad7:mixinextras-common"
val mixinExtrasVersion = DependencyHelper.fetchLatestReleaseOrCached(repository, mixinExtras, File(project.gradle.projectCacheDir, "mixinextras-common.txt"))
project.dependencies.add(if (usingOneConfig && mcData.loader == ModLoader.FORGE && mcData.version <= MinecraftVersion.VERSION_1_12_2) "modCompileOnly" else "modImplementation", "$mixinExtras:$mixinExtrasVersion")
project.dependencies.add("annotationProcessor", "$mixinExtras:$mixinExtrasVersion")
}

/**
Expand Down

0 comments on commit e9b4e65

Please sign in to comment.