Skip to content

Commit

Permalink
feat: Prepare to port to MC1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Oct 14, 2024
1 parent baed985 commit d90a1c7
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 62 deletions.
139 changes: 78 additions & 61 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ val supportedVersionRange: List<String?> = mapOf(
12001 to listOf("1.20-", "1.20.1"),
12002 to listOf("1.20.2-", "1.20.4"),
12005 to listOf("1.20.5-", "1.20.6"),
12100 to listOf("1.21-", null),
12100 to listOf("1.21-", "1.21.1"),
12102 to listOf("1.21.2-", null),
)[mcVersion] ?: listOf()

preprocess {
Expand Down Expand Up @@ -57,7 +58,7 @@ repositories {
mavenLocal()
}

base.archivesBaseName = project.properties["archives_base_name"] as? String ?: ""
base.archivesName.set(project.properties["archives_base_name"] as? String ?: "")

val buildNumber: String? = System.getenv("GITHUB_RUN_NUMBER")
project.version = (project.properties["mod_version"] as? String ?: "") + "+${mcVersionStr}" + (if (buildNumber != null) "b${buildNumber}-" else "-") + (project.properties["version_stage"] ?: "") + (if (isFabric) "-fabric" else (if (isNeo) "-neoforge" else "-forge"))
Expand All @@ -81,7 +82,7 @@ loom {
if (!isFabric && !isNeo) {
forge {
mixinConfigs = listOf(
"cobblegen.mixins.json"
"cobblegen.mixins.json"
)
}
}
Expand All @@ -94,6 +95,7 @@ val shade: Configuration by configurations.creating {
dependencies {
// TODO(addingVersion): For snapshots
val mc: Map<Int, String> = mapOf(
12102 to "1.21.2-pre3"
)
minecraft("com.mojang:minecraft:${mc[mcVersion] ?: mcVersionStr}")

Expand All @@ -105,39 +107,42 @@ dependencies {
else if (mcVersion <= 12001)
modImplementation("net.fabricmc:fabric-loader:0.14.21")
else
modImplementation("net.fabricmc:fabric-loader:0.15.11")
modImplementation("net.fabricmc:fabric-loader:0.16.7")

// For testing
if (project.properties["recipe_viewer"] != "none" && mcVersion > 11605)
// TODO: addingVersion
modLocalRuntime("net.fabricmc.fabric-api:fabric-api:" + mapOf(
11605 to "0.42.0+1.16",
11802 to "0.76.0+1.18.2",
11902 to "0.76.0+1.19.2",
11904 to "0.83.0+1.19.4",
12001 to "0.83.1+1.20.1",
12002 to "0.89.0+1.20.2",
12005 to "0.97.8+1.20.5",
12100 to "0.100.1+1.21",
11605 to "0.42.0+1.16",
11802 to "0.76.0+1.18.2",
11902 to "0.76.0+1.19.2",
11904 to "0.83.0+1.19.4",
12001 to "0.83.1+1.20.1",
12002 to "0.89.0+1.20.2",
12005 to "0.97.8+1.20.5",
12100 to "0.100.1+1.21",
12102 to "0.105.4+1.21.2",
)[mcVersion])
} else {
if (!isNeo) {
"forge"("net.minecraftforge:forge:${mcVersionStr}-" + mapOf(
11605 to "36.2.41",
11802 to "40.2.9",
11902 to "43.2.14",
11904 to "45.1.0",
12001 to "47.0.3",
12002 to "48.0.13",
11605 to "36.2.41",
11802 to "40.2.9",
11902 to "43.2.14",
11904 to "45.1.0",
12001 to "47.0.3",
12002 to "48.0.13",
// LexForge is no longer supported
)[mcVersion])
} else {
// TODO: addingVersion
// snapshot version format:
// "20.5.0-alpha.${mc[mcVersion]}.+"
"neoForge"("net.neoforged:neoforge:" + mapOf(
12002 to "20.2.86",
12005 to "20.5.21-beta",
12100 to "21.0.2-beta",
// snapshot version format:
// "20.5.0-alpha.${mc[mcVersion]}.+"
12002 to "20.2.86",
12005 to "20.5.21-beta",
12100 to "21.0.2-beta",
// FIXME: 1.21.2
)[mcVersion])
}
}
Expand Down Expand Up @@ -168,35 +173,38 @@ dependencies {
if (project.properties["recipe_viewer"] == "emi")
modLocalRuntime("dev.emi:emi:0.7.3+${mcVersionStr}")
} else {
// TODO: addingVersion - EMI
// TODO: addingVersion - EMI. They didn't break API on MC version upgrade so mismatch should be fine
val suffix = mapOf(
11902 to "1.19.2",
11904 to "1.19.4",
12001 to "1.20.1",
12002 to "1.20.2",
12005 to "1.20.6",
12100 to "1.20.6", // FIXME: Use 1.21 version of EMI
11902 to "1.19.2",
11904 to "1.19.4",
12001 to "1.20.1",
12002 to "1.20.2",
12005 to "1.20.6",
12100 to "1.21",
12105 to "1.21.1", // FIXME: .
)
val emiVersion = "1.1.16+${if (mcVersion >= 11902) (suffix[mcVersion] ?: "1.20.2") else "1.19.2"}"
// EMI support multiple platform since 1.0.0
// EMI seems to also skip 1.19 and 1.19.1
modCompileOnly("dev.emi:emi-${if (isFabric) "fabric" else (if (mcVersion >= 12005) "neoforge" else "forge")}:${project.properties["emi_version"]}+${if (mcVersion >= 11902) (suffix[mcVersion] ?: "1.20.2") else "1.19.2"}:api")
modCompileOnly("dev.emi:emi-${if (isFabric) "fabric" else (if (mcVersion >= 12005) "neoforge" else "forge")}:$emiVersion:api")
if (project.properties["recipe_viewer"] == "emi" && suffix[mcVersion] != null)
modLocalRuntime("dev.emi:emi-${if (isFabric) "fabric" else (if (mcVersion >= 12005) "neoforge" else "forge")}:${project.properties["emi_version"]}+${if (mcVersion >= 11902) suffix[mcVersion] else "1.19.2"}")
modLocalRuntime("dev.emi:emi-${if (isFabric) "fabric" else (if (mcVersion >= 12005) "neoforge" else "forge")}:$emiVersion")
}
// EMI ->

// <- REI
// TODO: addingVersion - REI
val reiVersions = mapOf(
11802 to "8.3.618",
11902 to "9.1.619",
11904 to "11.0.621",
12001 to "12.0.625",
12002 to "13.0.685",
12005 to "15.0.728",
12100 to null,
11802 to "8.3.618",
11902 to "9.1.619",
11904 to "11.0.621",
12001 to "12.0.625",
12002 to "13.0.685",
12005 to "15.0.728",
12100 to "16.0.783",
12102 to null,
)
val reiFallback = "15.0.728"
val reiFallback = "16.0.783"
if (isFabric)
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${reiVersions[mcVersion] ?: reiFallback}")
// NOTE: I need the full package for Forge(-like) loaders since for whatever reason @REIPluginClient
Expand All @@ -219,22 +227,29 @@ dependencies {
// <- JEI
// TODO: addingVersion - JEI
val jeiVersions = mapOf(
11802 to "10.2.1.1004",
11902 to "11.6.0.1015",
11904 to "13.1.0.13",
12001 to "15.0.0.12",
12002 to "16.0.0.28",
11802 to "10.2.1.1004",
11902 to "11.6.0.1015",
11904 to "13.1.0.13",
12001 to "15.0.0.12",
12002 to "16.0.0.28",
12005 to "18.0.0.62", // JEI skipped 1.20.5, so we use 1.20.6 version instead.
12100 to "19.21.0.246",
12102 to null,
)
val fallbackJeiVer = "18.0.0.62"
val fallbackJeiMcVer = "1.20.6"
val jeiVersion = jeiVersions[mcVersion]
// <- fallback - should be the latest version
val fallbackJeiVer = "19.21.0.246"
val fallbackJeiMcVer = "1.21.1"
// fallback ->
val jeiMc = mapOf(
12005 to fallbackJeiMcVer, // JEI skipped 1.20.5
12100 to fallbackJeiMcVer,
12005 to "1.20.6", // JEI skipped 1.20.5
12100 to "1.21.1", // Works for both 1.21 and 1.21.1, but internally defined 1.21.1
12102 to fallbackJeiMcVer,
)
modCompileOnly("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-common-api:${jeiVersions[mcVersion] ?: fallbackJeiVer}")
modCompileOnly("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-${if (isFabric) "fabric" else "forge"}-api:${jeiVersions[mcVersion] ?: fallbackJeiVer}")
if (project.properties["recipe_viewer"] == "jei" && jeiVersions[mcVersion] != null)
modLocalRuntime("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-${if (isFabric) "fabric" else "forge"}:${jeiVersions[mcVersion]}")
modCompileOnly("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-common-api:${jeiVersion ?: fallbackJeiVer}")
modCompileOnly("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-${if (isFabric) "fabric" else "forge"}-api:${jeiVersion ?: fallbackJeiVer}")
if (project.properties["recipe_viewer"] == "jei" && jeiVersion != null)
modLocalRuntime("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-${if (isFabric) "fabric" else "forge"}:${jeiVersion}")
// JEI ->

/* FIXME: Broken, somehow
Expand Down Expand Up @@ -339,7 +354,7 @@ java {

tasks.jar {
from("LICENSE") {
rename { "${it}_${base.archivesBaseName}" }
rename { "${it}_${base.archivesName.get()}" }
}
}

Expand All @@ -358,19 +373,21 @@ if (JavaVersion.current() != JavaVersion.VERSION_1_8 &&

// TODO: addingVersion
val mcReleaseVersions = mapOf(
11605 to listOf("1.16.5"),
11802 to listOf("1.18.2"),
11902 to listOf("1.19", "1.19.1", "1.19.2"),
12001 to listOf("1.20", "1.20.1"),
12002 to listOf("1.20.2", "1.20.3", "1.20.4"),
12005 to listOf("1.20.5", "1.20.6"),
12100 to listOf("1.21", "1.21.1"),
11605 to listOf("1.16.5"),
11802 to listOf("1.18.2"),
11902 to listOf("1.19", "1.19.1", "1.19.2"),
12001 to listOf("1.20", "1.20.1"),
12002 to listOf("1.20.2", "1.20.3", "1.20.4"),
12005 to listOf("1.20.5", "1.20.6"),
12100 to listOf("1.21", "1.21.1"),
)[mcVersion] ?: listOf()

val cfSnapshots = mapOf<Int, List<String>>(
12102 to listOf("1.21.2-Snapshot"),
)[mcVersion]

val mrSnapshots = mapOf<Int, List<String>>(
12102 to listOf("1.21.2-pre3"),
)[mcVersion]

publishMods {
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ recipe_viewer=none

# Dependencies
jankson_version=1.2.3
emi_version=1.1.6
manifold_version=2024.1.11

# Version Specific Dependencies
Expand Down
4 changes: 4 additions & 0 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ plugins {
}

preprocess {
//val neo12102 = createNode("1.21.2-neoforge", 12102, "mojang")
val fabric12102 = createNode("1.21.2-fabric", 12102, "mojang")
val neo12100 = createNode("1.21-neoforge", 12100, "mojang")
val fabric12100 = createNode("1.21-fabric", 12100, "mojang")
val neo12005 = createNode("1.20.5-neoforge", 12005, "mojang")
Expand All @@ -18,6 +20,7 @@ preprocess {
val forge11605 = createNode("1.16.5-forge", 11605, "mojang")
val fabric11605 = createNode("1.16.5-fabric", 11605, "mojang")

//neo12102.link(fabric12102)
neo12100.link(fabric12100)
neo12005.link(fabric12005)
neo12002.link(fabric12002)
Expand All @@ -27,6 +30,7 @@ preprocess {
forge11802.link(fabric11802)
forge11605.link(fabric11605)

fabric12102.link(fabric12100)
fabric12100.link(fabric12005)
fabric12005.link(fabric12002)
fabric12002.link(fabric12001)
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ listOf(
"1.20.5-neoforge",
"1.21-fabric",
"1.21-neoforge",
"1.21.2-fabric",
//"1.21.2-neoforge",
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down
Empty file added versions/1.21.2-fabric/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions versions/1.21.2-neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge

0 comments on commit d90a1c7

Please sign in to comment.