From 294a402447391db183cc3960ec96a20bcec6597c Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Mon, 23 Oct 2023 00:13:26 +0300 Subject: [PATCH] mod/toml version != jar version --- build.gradle.kts | 25 ++++++++++++++++++------- src/main/resources/META-INF/mods.toml | 10 ++++------ src/main/resources/pack.mcmeta | 5 ++--- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 82603e92c..1b3d60f66 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,14 +48,12 @@ data class GitInfo(val version: String, val tag: String, val buildNumber: String } val modVersion: String get() { - if (tag != "") - return mod_version + val version = if (buildNumber != "") "$mod_version.$buildNumber" else mod_version - if (version != "") { - return "$mod_version-SNAPSHOT-$version" - } else { - return "$mod_version-SNAPSHOT" - } + if (tag != "") + return version + + return "$version-SNAPSHOT" } } @@ -341,6 +339,19 @@ tasks.jar.configure { archiveVersion.set(gitVersion.jarName) } +tasks.withType(ProcessResources::class.java) { + val replaceProperties = mapOf( + "mc_version" to mc_version, + "mod_id" to mod_id, + "mod_version" to gitVersion.modVersion + ) + inputs.properties(replaceProperties) + + filesMatching(arrayListOf("META-INF/mods.toml", "pack.mcmeta")) { + expand(replaceProperties) + } +} + tasks { create("sourceJar", org.gradle.jvm.tasks.Jar::class.java) { archiveClassifier.set("sources") diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 841489a93..018965bee 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -15,11 +15,9 @@ license="2 Clause BSD" # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod -modId="overdrive_that_matters" #mandatory +modId="${mod_id}" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata -# see the associated build.gradle script for how to populate this completely automatically during a build -version="${file.jarVersion}" #mandatory +version="${mod_version}" #mandatory # A display name for the mod displayName="Overdrive That Matters" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ @@ -37,7 +35,7 @@ description=''' Matter. Energy. Combined. ''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.overdrive_that_matters]] #optional +[[dependencies.${mod_id}]] #optional # the modid of the dependency modId="forge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified @@ -49,7 +47,7 @@ Matter. Energy. Combined. # Side this dependency is applied on - BOTH, CLIENT or SERVER side="BOTH" # Here's another dependency -[[dependencies.overdrive_that_matters]] +[[dependencies.${mod_id}]] modId="minecraft" mandatory=true # This version range declares a minimum of the current minecraft version up to but not including the next major version diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index cb47551b4..07bda9007 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,7 +1,6 @@ { "pack": { - "description": "Overdrive That Matters Resources", - "pack_format": 6, - "_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods." + "description": "${mod_id} resources", + "pack_format": 18 } }