Cleanup and improve expansions in metadata files (#30)

* Add more fields and cleanup expansions

* Make names consistent
This commit is contained in:
Witixin 2023-10-05 13:31:55 +02:00 committed by GitHub
parent 920129b7b9
commit 493ecc96d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 21 deletions

View File

@ -57,9 +57,27 @@ subprojects {
} }
processResources { processResources {
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'mods.toml', '*.mixins.json']) { def expandProps = [
expand project.properties "version": version,
"group": project.group, //Else we target the task's group.
"minecraft_version": minecraft_version,
"forge_version": forge_version,
"forge_loader_version_range": forge_loader_version_range,
"forge_version_range": forge_version_range,
"minecraft_version_range": minecraft_version_range,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"mod_name": mod_name,
"mod_author": mod_author,
"mod_id": mod_id,
"license": license,
"description": project.description
]
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) {
expand expandProps
} }
inputs.properties(expandProps)
} }
// Disables Gradle's custom module metadata from being published to maven. The // Disables Gradle's custom module metadata from being published to maven. The

View File

@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
public class Constants { public class Constants {
public static final String MOD_ID = "multiloader"; public static final String MOD_ID = "examplemod";
public static final String MOD_NAME = "Multi Loader Template"; public static final String MOD_NAME = "ExampleMod";
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);
} }

View File

@ -3,7 +3,7 @@
"id": "mod_id", "id": "mod_id",
"version": "${version}", "version": "${version}",
"name": "${mod_name}", "name": "${mod_name}",
"description": "This is an example description! Tell everyone what your mod is about!", "description": "${description}",
"authors": [ "authors": [
"${mod_author}" "${mod_author}"
], ],
@ -11,8 +11,8 @@
"homepage": "https://fabricmc.net/", "homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod" "sources": "https://github.com/FabricMC/fabric-example-mod"
}, },
"license": "CC0-1.0", "license": "${license}",
"icon": "assets/modid/icon.png", "icon": "assets/modid/${mod_id}.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"main": [ "main": [
@ -20,8 +20,8 @@
] ]
}, },
"mixins": [ "mixins": [
"examplemod.mixins.json", "${mod_id}.mixins.json",
"examplemod.fabric.mixins.json" "${mod_id}.fabric.mixins.json"
], ],
"depends": { "depends": {
"fabricloader": ">=0.14", "fabricloader": ">=0.14",

View File

@ -17,6 +17,8 @@ mixin {
minecraft { minecraft {
mappings channel: 'official', version: minecraft_version mappings channel: 'official', version: minecraft_version
copyIdeResources = true //Calls processResources when in dev
// Automatically enable forge AccessTransformers if the file exists // Automatically enable forge AccessTransformers if the file exists
// This location is hardcoded in Forge and can not be changed. // This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123 // https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123

View File

@ -1,28 +1,26 @@
modLoader = "javafml" #mandatory modLoader = "javafml" #mandatory
loaderVersion = "[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions. loaderVersion = "${forge_loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See https://files.minecraftforge.net/ for a list of versions.
license = "C0-1.0" # Review your options at https://choosealicense.com/. license = "${license}" # Review your options at https://choosealicense.com/.
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional #issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
[[mods]] #mandatory [[mods]] #mandatory
modId = "multiloader" #mandatory modId = "${mod_id}" #mandatory
version = "${file.jarVersion}" #mandatory version = "${version}" #mandatory
displayName = "${mod_name}" #mandatory displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/) #updateJSONURL="https://change.me.example.invalid/updates.json" #optional (see https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/)
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI) #displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional (displayed in the mod UI)
logoFile = "multiloader.png" #optional (needs to be in the root of your mod jar (root of your 'resources' folder)) logoFile = "${mod_id}.png" #optional (needs to be in the root of your mod jar (root of your 'resources' folder))
credits = "Thanks for this example mod goes to Java" #optional credits = "Thanks for this example mod goes to Java" #optional
authors = "${mod_author}" #optional authors = "${mod_author}" #optional
description = ''' description = '''${description}''' #mandatory (Supports multiline text)
This is a long form description of the mod. You can write whatever you want here [[dependencies.${mod_id}]] #optional
''' #mandatory (Supports multiline text)
[[dependencies.multiloader]] #optional
modId = "forge" #mandatory modId = "forge" #mandatory
mandatory = true #mandatory mandatory = true #mandatory
versionRange = "[46,)" #mandatory versionRange = "${forge_version_range}" #mandatory
ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory ordering = "NONE" # The order that this dependency should load in relation to your mod, required to be either 'BEFORE' or 'AFTER' if the dependency is not mandatory
side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER' side = "BOTH" # Side this dependency is applied on - 'BOTH', 'CLIENT' or 'SERVER'
[[dependencies.multiloader]] [[dependencies.${mod_id}]]
modId = "minecraft" modId = "minecraft"
mandatory = true mandatory = true
versionRange = "[1.20,1.21)" versionRange = "${minecraft_version_range}"
ordering = "NONE" ordering = "NONE"
side = "BOTH" side = "BOTH"

View File

@ -1,3 +1,7 @@
# Important Notes:
# fabric.mod.json's modid field cannot be expanded, you must change it manually.
# Every field you add must be added to the root build.gradle expandProps map.
# Project # Project
version=1.0.0 version=1.0.0
group=com.example.examplemod group=com.example.examplemod
@ -7,6 +11,9 @@ minecraft_version=1.20
# Forge # Forge
forge_version=46.0.12 forge_version=46.0.12
forge_loader_version_range=[46,)
forge_version_range=[46,)
minecraft_version_range=[1.20, 1.21)
# Fabric # Fabric
fabric_version=0.83.0+1.20 fabric_version=0.83.0+1.20
@ -16,6 +23,8 @@ fabric_loader_version=0.14.21
mod_name=ExampleMod mod_name=ExampleMod
mod_author=Jared mod_author=Jared
mod_id=examplemod mod_id=examplemod
license=C0-1.0
description=The description of your mod. \nAccepts multilines.
# Gradle # Gradle
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G