Skip to content

Commit

Permalink
Add support for Legacy Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Jun 27, 2024
1 parent 0a953b2 commit d43175d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ dependencies {
if (propertyBoolOr("loom.mappings.use", true)) {
propertyOr(
"loom.mappings", when {
mcData.isForge && mcData.version <= MinecraftVersion.VERSION_1_15_2 -> mcData.dependencies.forge.mcpDependency
mcData.isFabric -> "net.fabricmc:yarn:${mcData.dependencies.fabric.yarnVersion}"
mcData.isLegacyFabric -> "net.legacyfabric:yarn:${mcData.dependencies.legacyFabric.legacyYarnVersion}"
mcData.isForge && mcData.version <= MinecraftVersion.VERSION_1_15_2 -> mcData.dependencies.forge.mcpDependency
else -> "official"
}
).apply {
Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/dev/deftu/gradle/utils/MCData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ class MCDependencies(

}

inner class LegacyFabric {

val legacyYarnVersion: String
get() {
if (!mcData.isLegacyFabric) throw LoaderSpecificException(ModLoader.FABRIC)

return MinecraftInfo.LegacyFabric.getLegacyYarnVersion(mcData.version)
}

}

inner class ForgeLike {

val kotlinForForgeVersion: String
Expand Down Expand Up @@ -96,6 +107,7 @@ class MCDependencies(
}

val fabric = Fabric()
val legacyFabric = LegacyFabric()
val forgeLike = ForgeLike()
val forge = Forge()
val neoForged = NeoForged()
Expand All @@ -111,6 +123,9 @@ data class MCData(
val isFabric: Boolean
get() = loader == ModLoader.FABRIC

val isLegacyFabric: Boolean
get() = loader == ModLoader.FABRIC && version < MinecraftVersion.VERSION_1_13_2

val isForge: Boolean
get() = loader == ModLoader.FORGE

Expand Down
18 changes: 18 additions & 0 deletions src/main/kotlin/dev/deftu/gradle/utils/MinecraftInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ object MinecraftInfo {

}

object LegacyFabric {

private val legacyYarnVersions = MinecraftVersionMap(
MinecraftVersion.VERSION_1_13_2 to "1.13.2+build.541:v2",
MinecraftVersion.VERSION_1_12_2 to "1.12.2+build.541:v2",
MinecraftVersion.VERSION_1_11_2 to "1.11.2+build.541:v2",
MinecraftVersion.VERSION_1_10_2 to "1.10.2+build.541:v2",
MinecraftVersion.VERSION_1_9_4 to "1.9.4+build.541:v2",
MinecraftVersion.VERSION_1_8_9 to "1.8.9+build.541:v2"
)

@JvmStatic
fun getLegacyYarnVersion(version: MinecraftVersion): String {
return legacyYarnVersions[version] ?: throw IllegalArgumentException("Unknown version for (legacy) Yarn mappings: $version")
}

}

object ForgeLike {

@JvmStatic
Expand Down

0 comments on commit d43175d

Please sign in to comment.