From a5a70cd65b7ff7373896abc0c59859283e7cac17 Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Thu, 27 Jan 2022 12:50:19 +1030 Subject: [PATCH] Made stuff about mod get from gradle.properties so it is easier to edit --- fabric/build.gradle | 29 ++++++++++++++++++--- fabric/src/main/resources/fabric.mod.json | 12 +++------ forge/build.gradle | 29 ++++++++++++++++++--- forge/src/main/resources/META-INF/mods.toml | 6 ++--- gradle.properties | 4 +++ 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index a29807427..998afb3be 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -111,12 +111,35 @@ runClient { finalizedBy(deleteResources) } +// Put stuff from gradle.properties into the mod info stuff +def resourceTargets = ["fabric.mod.json"] +def intoTargets = ["$buildDir/resources/main/"] +def replaceProperties = [ + version: mod_version, + mod_name: mod_name, + authors: mod_authors, + description: mod_description +] + processResources { dependsOn(copyAccessWidener) - inputs.property "version", rootProject.mod_version - filesMatching("fabric.mod.json") { - expand "version": rootProject.mod_version + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties + } + + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 820f3d012..216a12cb9 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -3,15 +3,9 @@ "id": "lod", "version": "${version}", - "name": "Distant Horizons Fabric", - "description": "This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow.", - "authors": [ - "James Seibel", - "Leonardo Amato", - "Cola", - "coolGi2007", - "Ran" - ], + "name": "${mod_name}", + "description": "${description}", + "authors": ["${authors}"], "contact": { "homepage": "https://www.curseforge.com/minecraft/mc-mods/lod-level-of-detail", diff --git a/forge/build.gradle b/forge/build.gradle index f909ed47b..44d5b0997 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -57,15 +57,36 @@ task copyCommonResources(type: Copy) { into file("build/resources/main") } +// Put stuff from gradle.properties into the mod info stuff +def resourceTargets = ["META-INF/mods.toml"] +def intoTargets = ["$buildDir/resources/main/"] +def replaceProperties = [ + version: mod_version, + mod_name: mod_name, + authors: mod_authors, + description: mod_description +] + processResources { dependsOn(copyCoreResources) dependsOn(copyCommonResources) - // Put all the stuff about the mod - inputs.property "version", rootProject.mod_version + inputs.properties replaceProperties + replaceProperties.put 'project', project + filesMatching(resourceTargets) { + expand replaceProperties + } - filesMatching("META-INF/mods.toml") { - expand "version": rootProject.mod_version + intoTargets.each { target -> + if (file(target).exists()) { + copy { + from(sourceSets.main.resources) { + include resourceTargets + expand replaceProperties + } + into target + } + } } } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 7688f0805..ccd7a060c 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -8,15 +8,15 @@ issueTrackerURL="https://gitlab.com/jeseibel/minecraft-lod-mod/-/issues" [[mods]] #//mandatory modId="lod" #//mandatory version= "${version}" #//mandatory, gets the version number from jar populated by the build.gradle script - displayName="Distant Horizons" #//mandatory + displayName="${mod_name}" #//mandatory #//updateJSONURL="https://change.me.example.invalid/updates.json" # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ displayURL="https://www.curseforge.com/minecraft/mc-mods/lod-level-of-detail" logoFile="logo.png" catalogueImageIcon="icon.png" credits="Massive thanks to: Leonardo, Cola, Ran, and CoolGi. For their hard work to bring Distant Horizons to where it is today. - James" - authors="James Seibel, Leonardo Amato, Cola, Ran, and coolGi2007" + authors="${authors}" #//mandatory. The description text for the mod - description= ''' This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow. ''' + description= ''' ${description} ''' #// if not set defaults to "false" clientSideOnly="true" #// if not set defaults to "BOTH" diff --git a/gradle.properties b/gradle.properties index d857a60d4..184369f76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,10 @@ mod_version=1.6.0a-pre maven_group=com.seibel.lod toml_version=3.6.0 +# Mod info +mod_name=Distant Horizons +mod_description=This mod generates and renders simplified terrain beyond the normal view distance at a low performance cost. Allowing you to see much farther without turning your game into a slideshow. +mod_authors_string=James Seibel, Leonardo Amato, Cola, coolGi2007, Ran # Fabric loader fabric_loader_version=0.12.12