1- import dev.kikugie.stonecutter.build.StonecutterBuildExtension
1+ import gg.meza.stonecraft.mod
22import me.modmuss50.mpp.ReleaseType
33
4- val kotlinVersion: String by rootProject
5- val modId = project.properties[" mod_id" ].toString()
6- val modName = project.properties[" mod_name" ].toString()
7- val modVersion = project.properties[" mod_version" ].toString()
8- val license = project.properties[" mod_license" ].toString()
9-
10- val publishType = project.properties[" publish.type" ]?.toString()
4+ val publishType = if (mod.hasProp(" build.release_type" )) mod.prop(" build.release_type" ) else null
115val isBeta = publishType != null && publishType == " beta"
126val isAlpha = publishType != null && publishType == " alpha"
7+ val kotlinVersion: String by rootProject
138
149plugins {
10+ id(" gg.meza.stonecraft" )
1511 kotlin(" jvm" )
1612 kotlin(" plugin.serialization" )
17-
18- id(" dev.isxander.modstitch.base" )
19- id(" me.modmuss50.mod-publish-plugin" )
20- }
21-
22- base.archivesName = " ${modName} -${stonecutter.modPlatform} "
23- version = " ${stonecutter.minecraftVersion} -${project.properties[" mod_version" ].toString()}${when {
24- isBeta -> " -B"
25- isAlpha -> " -A"
26- else -> " "
27- }} "
28-
29- val StonecutterBuildExtension .modPlatform get() = current.project.substringAfterLast(' -' )
30- val StonecutterBuildExtension .minecraftVersion get() = project.properties[" minecraft_version" ]?.toString() ? : current.project.substringBeforeLast(' -' )
31-
32- val modLoaderVersions = mutableMapOf (
33- " fabric" to mutableMapOf (" loader" to " 0.19.2" , // or can use {mc-ver}-loader
34- " 1.19.2-api" to " 0.77.0+1.19.2" , " 1.20.1-api" to " 0.92.2+1.20.1" , " 1.21-api" to " 0.102.0+1.21" ,
35- " 1.21.1-api" to " 0.116.4+1.21.1" , " 1.21.2-api" to " 0.106.1+1.21.2" , " 1.21.3-api" to " 0.114.1+1.21.3" ,
36- " 1.21.4-api" to " 0.119.4+1.21.4" , " 1.21.5-api" to " 0.128.2+1.21.5" , " 1.21.6-api" to " 0.128.2+1.21.6" ,
37- " 1.21.7-api" to " 0.129.0+1.21.7" , " 1.21.8-api" to " 0.136.1+1.21.8" , " 1.21.9-api" to " 0.134.1+1.21.9" ,
38- " 1.21.10-api" to " 0.138.4+1.21.10" , " 1.21.11-api" to " 0.141.1+1.21.11" , " 26.1-api" to " 0.145.1+26.1"
39- ),
40- // forge is dead lol. no more versions need
41- " forge" to mutableMapOf (" 1.19.2" to " 1.19.2-43.4.2" , " 1.20.1" to " 1.20.1-47.4.3" , " 1.21" to " 1.21-51.0.8" ,),
42- " neoforge" to mutableMapOf (" 1.21" to " 21.0.167" , " 1.21.1" to " 21.1.197" , " 1.21.2" to " 21.2.1-beta" ,
43- " 1.21.3" to " 21.3.95" , " 1.21.4" to " 21.4.156" , " 1.21.5" to " 21.5.96" , " 1.21.6" to " 21.6.20-beta" ,
44- " 1.21.7" to " 21.7.25-beta" , " 1.21.8" to " 21.8.52" , " 1.21.9" to " 21.9.16-beta" , " 1.21.10" to " 21.10.64" ,
45- " 1.21.11" to " 21.11.36-beta" , " 26.1" to " 26.1.0.19-beta"
46- )
47- )
48-
49- val parchmentVersion = mutableMapOf (
50- " 1.19.2" to " 2022.11.27" , " 1.20.1" to " 2023.09.03" , " 1.21" to " 2024.07.28" , " 1.21.1" to " 2024.11.17" ,
51- " 1.21.3" to " 2024.12.07" , " 1.21.4" to " 2025.03.23" , " 1.21.5" to " 2025.06.15" , " 1.21.6" to " 2025.06.29" ,
52- " 1.21.7" to " 2025.07.18" , " 1.21.8" to " 2025.09.14" , " 1.21.9" to " 2025.10.05" , " 1.21.10" to " 2025.10.12"
53- )
54-
55- java.toolchain.languageVersion = JavaLanguageVersion .of(when {
56- stonecutter.eval(stonecutter.minecraftVersion, " >1.21.11" ) -> 25
57- stonecutter.eval(stonecutter.minecraftVersion, " <=1.21.11" ) && stonecutter.eval(stonecutter.minecraftVersion, " >1.19.4" ) -> 21
58- else -> 17
59- })
60-
61- modstitch {
62- minecraftVersion = stonecutter.minecraftVersion
63-
64- loom {
65- val verArr = modLoaderVersions[" fabric" ]!!
66- fabricLoaderVersion = verArr[" ${stonecutter.minecraftVersion} -loader" ]
67- ? : verArr[" loader" ]
68- ? : error(" Failed to find loader version for ${stonecutter.minecraftVersion} on fabric" )
69-
70- configureLoom {
71- mixin.useLegacyMixinAp = false
72- }
73- }
74-
75- moddevgradle {
76- val verArr = modLoaderVersions[" neoforge" ]!!
77- neoForgeVersion = verArr[stonecutter.minecraftVersion] ? : error(" Failed to find loader version for ${stonecutter.minecraftVersion} on neoforge" )
78- }
79-
80- parchmentVersion[stonecutter.minecraftVersion]?.let { ver ->
81- parchment {
82- version = ver
83- }
84- }
85-
86- metadata {
87- modId = project.properties[" mod_id" ].toString()
88- modVersion = project.properties[" mod_version" ].toString()
89- modName = project.properties[" mod_name" ].toString()
90- modGroup = " com.algorithmlx"
91- modLicense = project.properties[" mod_license" ].toString()
92- modDescription = project.properties[" mod_description" ].toString()
93- modCredits = project.properties[" mod_credits" ].toString()
94- modAuthor = project.properties[" mod_authors" ].toString()
95-
96- replacementProperties.put(" mc_version" , stonecutter.minecraftVersion)
97- if (modstitch.isLoom) {
98- val fabricLoader = modLoaderVersions[" fabric" ]!! [" ${stonecutter.minecraftVersion} -loader" ]
99- ? : modLoaderVersions[" fabric" ]!! [" loader" ]
100- ? : error(" Failed to find loader version for ${stonecutter.minecraftVersion} on fabric" )
101- val flkVersion = project.properties[" flk_version" ].toString()
102-
103- replacementProperties.put(" fabric_loader" , fabricLoader)
104- replacementProperties.put(" java_version" , project.java.toolchain.languageVersion.toString())
105- replacementProperties.put(" fabric_api" , modLoaderVersions[" fabric" ]!! [" ${stonecutter.minecraftVersion} -api" ]!! )
106- replacementProperties.put(" flk_version" , " $flkVersion +kotlin.$kotlinVersion " )
107- } else {
108- val klfVersion = project.properties[" klf_version" ].toString()
109- replacementProperties.put(" neoforge_version" , modLoaderVersions[" neoforge" ]!! [stonecutter.minecraftVersion]!! )
110- replacementProperties.put(" klf_version" , klfVersion)
111- }
112- }
113-
114- mixin {
115- addMixinsToModManifest = true
116- configs.register(modId)
117- }
11813}
11914
12015repositories {
@@ -123,39 +18,56 @@ repositories {
12318}
12419
12520dependencies {
126- if (modstitch.isLoom ) {
21+ if (mod.isFabric ) {
12722 val flkVersion = project.properties[" flk_version" ].toString()
128- if (stonecutter.eval(stonecutter.minecraftVersion, " <=1.21.11" )) {
129- " modImplementation" (" net.fabricmc.fabric-api:fabric-api:${modLoaderVersions[" fabric" ]!! [" ${stonecutter.minecraftVersion} -api" ]} " )
130- " modImplementation" (" net.fabricmc:fabric-language-kotlin:$flkVersion +kotlin.$kotlinVersion " )
131- } else {
132- implementation(" net.fabricmc.fabric-api:fabric-api:${modLoaderVersions[" fabric" ]!! [" ${stonecutter.minecraftVersion} -api" ]} " )
133- implementation(" net.fabricmc:fabric-language-kotlin:$flkVersion +kotlin.$kotlinVersion " )
134- }
23+
24+ implementMod(" net.fabricmc:fabric-language-kotlin:$flkVersion +kotlin.$kotlinVersion " )
13525 } else {
13626 val klfVersion = project.properties[" klf_version" ].toString()
13727 val klfLoaderVersion = project.properties[" klf_loader_version" ].toString()
13828 implementation(" dev.nyon:KotlinLangForge:$klfVersion -k$kotlinVersion -$klfLoaderVersion +neoforge" )
13929 }
14030}
14131
142- stonecutter {
143- constants {
144- put(" fabric" , modstitch.isLoom)
145- put(" neoforge" , modstitch.isModDevGradleRegular)
146- put(" forge" , modstitch.isModDevGradleLegacy)
147- put(" forgelike" , modstitch.isModDevGradle)
148- }
32+ modSettings {
33+ val replaces = mutableMapOf (
34+ " fabric_loader" to mod.prop(" loader_version" ), " java_version" to java.toolchain.languageVersion.get().toString(),
35+ " fabric_api" to mod.prop(" fabric_version" ),
36+ " flk_version" to " ${mod.prop(" flk_version" )} +kotlin.$kotlinVersion " ,
37+ " neoforge_version" to mod.prop(" loader_version" ), " klf_version" to mod.prop(" klf_version" )
38+ )
39+ variableReplacements.putAll(replaces)
14940}
15041
15142publishMods {
43+ val dependType = when {
44+ mod.isFabricLike -> " fabriclike"
45+ mod.isForge -> " forge"
46+ mod.isForgeLike -> " forgelike"
47+ mod.isNeoforge -> " neoforge"
48+ else -> " fabric"
49+ }
50+
15251 dryRun = false
15352
154- if (project.file(" nopub" ).exists()) {
155- println (" No publish file exists (${project.name} /nopub). Skipping" )
53+ if (
54+ mod.hasProp(" build.no_publish" )
55+ && (
56+ mod.prop(" build.no_publish" ) == " true"
57+ || ((mod.prop(" build.no_publish" ) == " neoforge" ) && mod.isNeoforge)
58+ || ((mod.prop(" build.no_publish" ) == " fabric" ) && mod.isFabric)
59+ || ((mod.prop(" build.no_publish" ) == " forge" ) && mod.isForge)
60+ || ((mod.prop(" build.no_publish" ) == " fabriclike" ) && mod.isFabricLike)
61+ || ((mod.prop(" build.no_publish" ) == " forgelike" ) && mod.isForgeLike)
62+ )
63+ ) {
64+ println (" Publishing disabled. Skipping..." )
15665 return @publishMods
15766 }
158- file = modstitch.finalJarTask.flatMap { it.archiveFile }
67+
68+ val additionalMinecraftVersions = if (mod.hasProp(" minecraft_version.additional" ))
69+ mod.prop(" minecraft_version.additional" ).split(' ,' ).map { it.trim() }
70+ else listOf ()
15971
16072 changelog = rootProject.file(" CHANGELOG.md" ).readText()
16173
@@ -165,41 +77,51 @@ publishMods {
16577 else -> ReleaseType .STABLE
16678 }
16779
168- displayName = " [${stonecutter.modPlatform } -${stonecutter .minecraftVersion} ] ${modstitch.metadata.modName.get() } (v.${project.properties[ " mod_version " ].toString() } )"
169- modLoaders.add(stonecutter.modPlatform )
80+ displayName = " [${mod.loader } -${mod .minecraftVersion} ] ${mod.name } (v.${mod.version } )"
81+ modLoaders.add(mod.loader )
17082
171- val modrinthProject: String? = rootProject.properties[ " modrinth_project " ]?.toString()
83+ val modrinthProject: String? = if (mod.hasProp( " publish.modrinth.project_id " )) mod.prop( " publish.modrinth.project_id " ) else null
17284 val modrinthToken = System .getenv(" MODRINTH_TOKEN" )
17385
174- val curseProject: String? = rootProject.properties[ " curseforge_project " ]?.toString()
86+ val curseProject: String? = if (mod.hasProp( " publish.curseforge.project_id " )) mod.prop( " publish.modrinth.project_id " ) else null
17587 val curseToken = System .getenv(" CURSE_TOKEN" )
17688
17789 if (modrinthToken != null && modrinthProject != null ) modrinth {
17890 projectId = modrinthProject
17991 accessToken = modrinthToken
18092
181- if (modstitch.isLoom)
182- requires(" fabric-api" , " fabric-language-kotlin" )
183- else requires(" kotlin-lang-forge" )
93+ if (mod.hasProp(" publish.modrinth.$dependType .depends" )) {
94+ val depends = mod.prop(" publish.modrinth.$dependType .depends" ).split(' ,' )
95+ requires(* depends.toTypedArray())
96+ }
18497
185- minecraftVersions.add(stonecutter.minecraftVersion)
98+ minecraftVersions.add(mod.minecraftVersion)
99+ minecraftVersions.addAll(additionalMinecraftVersions)
186100 }
187101
188102 if (curseToken != null && curseProject != null ) curseforge {
189103 projectId = curseProject
190104 accessToken = curseToken
191105
192- if (modstitch.isLoom)
193- requires(" fabric-api" , " fabric-language-kotlin" )
194- else requires(" kotlinlangforge" )
106+ if (mod.hasProp(" publish.curseforge.$dependType .depends" )) {
107+ val depends = mod.prop(" publish.curseforge.$dependType .depends" ).split(' ,' )
108+ requires(* depends.toTypedArray())
109+ }
195110
196- if (stonecutter .minecraftVersion.contains(" snapshot" )) {
111+ if (mod .minecraftVersion.contains(" snapshot" )) {
197112 val modifiedVersion = buildString {
198- val oldVersion = stonecutter .minecraftVersion
113+ val oldVersion = mod .minecraftVersion
199114 val splitted = oldVersion.split(" -" )
200115 append(splitted[0 ] + " -snapshot" )
201116 }
202117 minecraftVersions.add(modifiedVersion)
203- } else minecraftVersions.add(stonecutter.minecraftVersion)
118+ } else minecraftVersions.add(mod.minecraftVersion)
119+ minecraftVersions.addAll(additionalMinecraftVersions)
204120 }
205121}
122+
123+ fun DependencyHandlerScope.implementMod (dependencyNotation : Any ) {
124+ if (stonecutter.eval(mod.minecraftVersion, " >=26.1.0" ))
125+ implementation(dependencyNotation)
126+ else " modImplementation" (dependencyNotation)
127+ }
0 commit comments