Skip to content

Commit 880d1ed

Browse files
committed
use modstitch for resource processing
Signed-off-by: Octol1ttle <[email protected]>
1 parent 8a156ab commit 880d1ed

File tree

6 files changed

+23
-33
lines changed

6 files changed

+23
-33
lines changed

build.gradle.kts

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ stonecutter {
3737
}
3838

3939
base { archivesName.set("${mod.id}-$loader") }
40+
group = mod.group
41+
version = "${mod.version}+mc$minecraft"
4042

4143
modstitch {
4244
minecraftVersion = minecraft
@@ -53,11 +55,28 @@ modstitch {
5355
ifFindProperty("deps.parchment") { mappingsVersion = it }
5456
}
5557

56-
// This metadata is used by Modstitch to annoyingly overwrite some Gradle properties (like "version")
5758
metadata {
59+
overwriteProjectVersionAndGroup = false
60+
5861
modId = mod.id
59-
modGroup = mod.group
60-
modVersion = "${mod.version}+mc$minecraft"
62+
modName = mod.name
63+
modVersion = mod.version
64+
65+
fun <K, V> MapProperty<K, V>.populate(block: MapProperty<K, V>.() -> Unit) {
66+
block()
67+
}
68+
69+
val refmapString = """
70+
,"refmap": "${modId}.refmap.json"
71+
"""
72+
replacementProperties.populate {
73+
// You can put any other replacement properties/metadata here that
74+
// modstitch doesn't initially support. Some examples below.
75+
put("mc", minecraftVersionRange)
76+
put("fml", if (loader == "neoforge") "1" else "45")
77+
put("mnd", if (loader == "neoforge") "type = \"required\"" else "mandatory = true")
78+
put("refmap", if (loader == "forge") refmapString else "")
79+
}
6180
}
6281

6382
// Fabric Loom (Fabric)
@@ -136,35 +155,6 @@ yamlang {
136155
inputDir.set("assets/${mod.id}/lang")
137156
}
138157

139-
// Resources
140-
tasks.processResources {
141-
inputs.property("loader", loader)
142-
inputs.property("mod_id", mod.id)
143-
inputs.property("mod_version", mod.version)
144-
inputs.property("mod_name", mod.name)
145-
inputs.property("mc", minecraftVersionRange)
146-
147-
val loader = inputs.properties["loader"]
148-
val modId = inputs.properties["mod_id"]
149-
val map = mapOf(
150-
"mod_id" to modId,
151-
"mod_version" to inputs.properties["mod_version"],
152-
"mod_name" to inputs.properties["mod_name"],
153-
"mc" to inputs.properties["mc"],
154-
"fml" to if (loader == "neoforge") "1" else "45",
155-
"mnd" to if (loader == "neoforge") "type = \"required\"" else "mandatory = true"
156-
)
157-
158-
fun FileCopyDetails.expandOrExclude(expand: Boolean, map: Map<String, *>): Any = if (expand) expand(map) else exclude()
159-
160-
filesMatching("fabric.mod.json") { expandOrExclude(loader == "fabric", map) }
161-
filesMatching("META-INF/mods.toml") { expandOrExclude(loader == "forge", map) }
162-
filesMatching("META-INF/neoforge.mods.toml") { expandOrExclude(loader == "neoforge", map) }
163-
filesMatching("${modId}.mixins.json") { expand(mapOf("refmap" to if (loader == "forge") """
164-
,"refmap": "${modId}.refmap.json"
165-
""".trimIndent() else ""))}
166-
}
167-
168158
// Publishing
169159
publishMods {
170160
val modrinthToken = findProperty("modrinthToken")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pack": {
3-
"description": "FlightAssistant",
3+
"description": "${mod_name} resources",
44
"pack_format": 15
55
}
66
}

0 commit comments

Comments
 (0)