Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Retrieve JSON
run: |
curl -Ls -o "headlessmc.json" "https://api.github.com/repos/3arthqu4ke/headlessmc/releases/tags/2.7.1" --header "Authorization: ${{ secrets.GITHUB_TOKEN }}"
curl -Ls -o "mc-runtime-test.json" "https://api.github.com/repos/null2264/mc-runtime-test/releases/tags/5.2.3" --header "Authorization: ${{ secrets.GITHUB_TOKEN }}"
curl -Ls -o "mc-runtime-test.json" "https://api.github.com/repos/null2264/mc-runtime-test/releases/tags/5.2.5" --header "Authorization: ${{ secrets.GITHUB_TOKEN }}"

- name: Upload jar files
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -98,11 +98,12 @@ jobs:
8
17
21
25
gradle-no-cache-if: true

- name: Setup properties
run: |
echo "org.gradle.java.installations.fromEnv=JAVA_HOME,JAVA_HOME_8_X64,JAVA_HOME_17_X64,JAVA_HOME_21_X64" >> gradle.properties
echo "org.gradle.java.installations.fromEnv=JAVA_HOME,JAVA_HOME_8_X64,JAVA_HOME_17_X64,JAVA_HOME_21_X64,JAVA_HOME_25_X64" >> gradle.properties

- name: Build with Gradle
run: |
Expand Down
46 changes: 26 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import org.apache.tools.ant.filters.StripJavaComments

plugins {
id("java")
id("architectury-plugin") version "3.4-SNAPSHOT"
id("io.github.null2264.architectury-loom") version "1.13-SNAPSHOT" apply false
id("architectury-plugin") version "3.4.164"
id("io.github.null2264.architectury-loom-remap") version "1.14-SNAPSHOT" apply false
id("io.github.null2264.architectury-loom-no-remap") version "1.14-SNAPSHOT" apply false
id("com.gradleup.shadow") apply false
id("me.modmuss50.mod-publish-plugin") version "1.1.0"
}
Expand All @@ -19,21 +20,18 @@ val loaderName = project.properties["null2264.platform"] as? String ?: ""
val isForge = loaderName.endsWith("forge")
val isNeo = loaderName.endsWith("neoforge")
val isFabric = loaderName.endsWith("fabric")
val _mcVer = project.properties["mcVer"] as? String ?: ""
val mcVersionStr = if (_mcVer.startsWith("1.")) _mcVer else "2.$_mcVer"
val (major, minor, patch, hotfix) = mcVersionStr
val mcVersionStr = project.properties["mcVer"] as? String ?: ""
val (major, minor, patch) = mcVersionStr
.split(".")
.toMutableList()
.apply { while (this.size < 4) this.add("") }
val mcHotfix: Int = hotfix.toIntOrNull() ?: 0
.apply { while (this.size < 3) this.add("") }
val mcVersion: Int = "${major}${minor.padStart(2, '0')}${patch.padStart(2, '0')}".toInt()
val versionRange = supportedVersionRange(mcVersion, loaderName)

fun setupPreprocessor() {
val buildProps = buildString {
append("# DON'T TOUCH THIS FILE, This is handled by the build script\n")
append("MC=${mcVersion}\n")
append("BUILD=${mcHotfix}\n")
if (isFabric) append("FABRIC=1\n")
if (isForge) append("FORGE=${if (!isNeo) "1" else "2"}\n")
}
Expand All @@ -43,7 +41,7 @@ fun setupPreprocessor() {
setupPreprocessor()

architectury {
minecraft = MC.versioned(mcVersion, mcHotfix)
minecraft = MC.versioned(mcVersion)
}

allprojects {
Expand All @@ -52,7 +50,6 @@ allprojects {

ext["mcVersion"] = mcVersion
ext["mcVersionStr"] = mcVersionStr
ext["mcHotfix"] = mcHotfix
ext["loaderName"] = loaderName
ext["isFabric"] = isFabric
ext["isForge"] = isForge
Expand Down Expand Up @@ -132,11 +129,14 @@ subprojects {
if (isModModule) {
// NOTE: This must be set before archloom is applied!
extra.set("loom.platform", loaderName)
}

if (isMcModule) {
apply(plugin = "architectury-plugin")
apply(plugin = "io.github.null2264.architectury-loom")

if (mcVersion < 260100) {
apply(plugin = "io.github.null2264.architectury-loom-remap")
} else {
apply(plugin = "io.github.null2264.architectury-loom-no-remap")
}
val arch = project.extensions["architectury"] as ArchitectPluginExtension
arch.apply {
if (isModModule)
Expand Down Expand Up @@ -184,18 +184,18 @@ subprojects {
}

val loom by lazy {
if (!isMcModule) {
throw IllegalStateException("Loom only available for MC modules")
if (!isModModule) {
throw IllegalStateException("Loom only available for submodules that applied Loom")
}
project.the<LoomGradleExtensionAPI>()
}

dependencies {
if (isMcModule) {
if (isModModule) {
val minecraft by configurations
val mappings by configurations

minecraft(MC.versioned(mcVersion, mcHotfix))
minecraft(MC.versioned(mcVersion))
mappings(loom.officialMojangMappings())
}

Expand All @@ -207,8 +207,8 @@ subprojects {

if (isModModule) {
compileOnly(project(":stubs"))
compileInternal(project(":mclib", configuration = "namedElements")) { isTransitive = false }
shadeInternal(project(":mclib", configuration = "transformProduction$loaderProd")) {
compileInternal(project(":mclib")) { isTransitive = false }
shadeInternal(project(":mclib")) {
// Remove Junit test libraries
exclude(group = "org.junit.jupiter", module = "junit-jupiter")
exclude(group = "org.junit.jupiter", module = "junit-jupiter-engine")
Expand Down Expand Up @@ -302,7 +302,13 @@ subprojects {
}

val targetJavaVersion = if (!isApi) {
if (mcVersion >= 12006) 21 else (if (mcVersion >= 11700) 17 else 8)
when (mcVersion) {
in 11200..11605 -> 8
in 11700..11701 -> 16
in 11800..12004 -> 17
in 12005..12111 -> 21
else -> 25
}
} else {
8 // APIs should always target Java 8
}
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/VersionRange.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ fun supportedVersionRange(mcVersion: Int, loader: String): VersionRange {
in 12100..12101 -> VersionRange("1.20.x", "1.21.1")
in 12102..12104 -> VersionRange("1.21.1", "1.21.4")
in 12105..12110 -> VersionRange("1.21.4", "1.21.10")
12111 -> VersionRange("1.21.10", null)
12111 -> VersionRange("1.21.10", "1.21.11")
22601 -> VersionRange("1.21.11", null)
else -> VersionRange(null, null)
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependencies/Create.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fun createMod(isNeo: Boolean) = Dependency(
group = "com.simibubi.create",
// Create finally support Neo on 1.21.1
name = "create" + (if (!isNeo) "-1.18.2" else "-1.21.1"),
version = { mcVersion, hotfix ->
version = { mcVersion ->
val version = if (!isNeo) "0.5.1.e-318" else "6.0.4-59"
return@Dependency "$version:slim"
},
Expand Down
36 changes: 26 additions & 10 deletions buildSrc/src/main/kotlin/dependencies/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,42 @@ package dependencies
data class Dependency(
private val group: String,
private val name: String,
private val version: (Int, Int) -> String,
private val version: (Int) -> String,
) {
fun versioned(mcVersion: Int, mcBuild: Int): String = "${group}:${name}:${version(mcVersion, mcBuild)}"
fun versioned(mcVersion: Int): String = "${group}:${name}:${version(mcVersion)}"
}

fun versionStr(versionCode: Int, hotfix: Int = 0, alwaysShowHotfix: Boolean = false): String {
fun legacyVersionStr(versionCode: Int): String {
val versionCodeStr = versionCode.toString()
val major = versionCodeStr.getOrNull(0)?.toString() ?: "0"
val minor = versionCodeStr
.substring(1, 3 + (versionCodeStr.length - 5)) // Future proofing, in case "1.100.0" happened
.substring(1, 3)
.padStart(2, '0')
.trimStart('0')
val patch = versionCodeStr
.substring(3 + (versionCodeStr.length - 5))
.substring(3)
.padEnd(1, '0').trimStart('0')

if (patch.isEmpty()) return "$major.$minor"
return "$major.$minor.$patch"
}

/**
* Transform version code (e.g. 260100) back to formatted string (e.g. 26.01).
*/
fun versionStr(versionCode: Int, alwaysShowHotfix: Boolean = false): String {
val versionCodeStr = versionCode.toString()
if (versionCodeStr.length == 5) return legacyVersionStr(versionCode)

if (major.toInt() <= 1) {
if (patch.isEmpty()) return "$major.$minor"
return "$major.$minor.$patch"
}
val year = versionCodeStr.substring(0, 2)
val release = versionCodeStr
.substring(2, 4)
.trimStart('0')
.let { if (it == "") "0" else it }
val hotfix = versionCodeStr
.substring(4)
.trimStart('0')
.let { if (it == "" && alwaysShowHotfix) "0" else it }

return if (hotfix > 0 || alwaysShowHotfix) "$minor.$patch.$hotfix" else "$minor.$patch"
return if (hotfix != "") "$year.$release.$hotfix" else "$year.$release"
}
11 changes: 7 additions & 4 deletions buildSrc/src/main/kotlin/dependencies/FabricAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dependencies
val fapi = Dependency(
group = "net.fabricmc.fabric-api",
name = "fabric-api",
version = { mcVersion, hotfix ->
version = { mcVersion ->
when (mcVersion) {
11605 -> "0.42.0+1.16"
11802 -> "0.76.0+1.18.2"
Expand All @@ -16,6 +16,7 @@ val fapi = Dependency(
in 12102..12104 -> "0.106.1+1.21.3"
in 12105..12110 -> "0.119.9+1.21.5"
12111 -> "0.139.5+1.21.11"
260100 -> "0.141.1+26.1"
else -> throw IllegalStateException("$mcVersion is not yet supported!")
}
},
Expand All @@ -24,9 +25,11 @@ val fapi = Dependency(
val fapiGameTest = Dependency(
group = "net.fabricmc.fabric-api",
name = "fabric-gametest-api-v1",
version = { mcVersion, hotfix ->
version = { mcVersion ->
when (mcVersion) {
12105 -> "3.1.2+2a6ec84b49"
in 12105..12110 -> "3.1.2+2a6ec84b49"
12111 -> "3.1.27+4fc5413f3e"
260100 -> "4.0.0+574290bac9"
else -> throw IllegalStateException("$mcVersion is not yet supported!")
}
},
Expand All @@ -35,7 +38,7 @@ val fapiGameTest = Dependency(
val fapiResourceLoader = Dependency(
group = "net.fabricmc.fabric-api",
name = "fabric-resource-loader-v0",
version = { mcVersion, hotfix ->
version = { mcVersion ->
when (mcVersion) {
12105 -> "3.1.6+02ca679649"
else -> throw IllegalStateException("$mcVersion is not yet supported!")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/dependencies/LexForge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dependencies
val lexForge = Dependency(
group = "net.minecraftforge",
name = "forge",
version = { mcVersion, hotfix ->
version = { mcVersion ->
val version = when (mcVersion) {
11605 -> "36.2.41"
11802 -> "40.2.9"
Expand Down
5 changes: 3 additions & 2 deletions buildSrc/src/main/kotlin/dependencies/Minecraft.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package dependencies
val minecraft = Dependency(
group = "com.mojang",
name = "minecraft",
version = { mcVersion, hotfix ->
version = { mcVersion ->
when (mcVersion) {
// For snapshots
//12100 -> "some snapshot"
else -> versionStr(mcVersion, hotfix)
260100 -> "26.1-snapshot-1"
else -> versionStr(mcVersion)
}
},
)
15 changes: 6 additions & 9 deletions buildSrc/src/main/kotlin/dependencies/NeoForge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ package dependencies
val neoForge = Dependency(
group = "net.neoforged",
name = "neoforge",
version = { mcVersion, hotfix ->
version = { mcVersion ->
val version = when (mcVersion) {
// snapshot version format:
// "0-alpha.${mc[mcVersion]}.+"
in 12002..12003 -> "86"
12004 -> "237"
in 12005..12006 -> "121"
in 12100..12101 -> "129"
in 12102..12104 -> "1-beta"
in 12105..12110 -> "25-beta"
12111 -> "24-beta"
22601 -> when (hotfix) {
0 -> "0-alpha.4+snapshot-1"
else -> throw IllegalStateException("Hotfix $hotfix is not yet supported!")
}
in 12102..12104 -> "96"
in 12105..12110 -> "97"
12111 -> "42"
260100 -> "19-beta"
else -> throw IllegalStateException("Version $mcVersion is not yet supported!")
}
val mc = versionStr(mcVersion, hotfix, true).substring(2)
val mc = versionStr(mcVersion, true).let { if (mcVersion>=260100) it else it.substring(2) }

"${mc}.${version}"
},
Expand Down
13 changes: 9 additions & 4 deletions buildSrc/src/main/kotlin/dependencies/RecipeViewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fun emi(mcVersion: Int, loader: String? = null, api: Boolean = false) = Dependen
// EMI migrate to NeoForge after 1.20.2
if (loader != "fabric" && mcVersion <= 12002) "emi-forge" else "emi-$loader"
} else "emi",
version = { _, _ ->
version = { _ ->
buildString {
if (mcVersion <= 11802) {
append("0.7.3+${versionStr(mcVersion)}") // There are no multi-loader support in 1.18.2
Expand All @@ -22,6 +22,7 @@ fun emi(mcVersion: Int, loader: String? = null, api: Boolean = false) = Dependen
12003 -> "1.20.2"
in 12005..12006 -> "1.20.6"
in 12100..12111 -> "1.21.1"
260100 -> "1.21.1" // FIXME: Not confirmed, but EMI might skip 1.21.11 for 26.1
else -> throw IllegalStateException("$mcVersion is not yet supported!")
}
)
Expand All @@ -38,7 +39,7 @@ fun rei(loader: String, api: Boolean = false) = Dependency(
} else {
"RoughlyEnoughItems-$loader"
},
version = { mcVersion, hotfix ->
version = { mcVersion ->
// They didn't break API on MC version upgrade so mismatch should be fine
when (mcVersion) {
11802 -> "8.3.618"
Expand All @@ -48,7 +49,9 @@ fun rei(loader: String, api: Boolean = false) = Dependency(
in 12002..12004 -> "13.0.685"
in 12005..12006 -> "15.0.787"
in 12100..12101 -> "16.0.788"
in 12102..12111 -> "17.0.789"
in 12102..12110 -> "17.0.789"
12111 -> "17.0.789" // FIXME: Broken in 1.21.11, waiting for new release
260100 -> "17.0.789"
else -> throw IllegalStateException("$mcVersion is not yet supported!")
}
},
Expand All @@ -69,6 +72,7 @@ fun jei(mcVersion: Int, loader: String, common: Boolean = false, api: Boolean =
in 12005..12006 -> versionStr(mcVersion)
in 12100..12110 -> "1.21.1"
12111 -> "1.21.11"
260100 -> "1.21.11"
else -> throw IllegalStateException("$mcVersion is not yet supported!")
}
)
Expand All @@ -83,7 +87,7 @@ fun jei(mcVersion: Int, loader: String, common: Boolean = false, api: Boolean =
append ("-api")
}
},
version = { _, _ ->
version = { _ ->
// They didn't break API on MC version upgrade so mismatch should be fine
when (mcVersion) {
11802 -> "10.2.1.1009"
Expand All @@ -94,6 +98,7 @@ fun jei(mcVersion: Int, loader: String, common: Boolean = false, api: Boolean =
in 12005..12006 -> "18.0.0.62"
in 12100..12110 -> "19.21.1.248"
12111 -> "27.3.0.14"
260100 -> "27.3.0.14"
else -> throw IllegalStateException("$mcVersion is not yet supported!")
}
},
Expand Down
Loading
Loading