···11import de.undercouch.gradle.tasks.download.Download
22import groovy.json.JsonSlurper
33-import org.eu.net.pool.mc_plugin.Environment
43import org.gradle.api.publish.maven.internal.publication.MavenPomInternal
54import org.gradle.kotlin.dsl.support.uppercaseFirstChar
65import kotlin.io.path.exists
···2726 id("maven-publish")
2827 id("idea")
2928 id("de.undercouch.download") version "5.6.0"
3030- id("org.eu.net.pool.mc-plugin")
2929+ //id("org.eu.net.pool.mc-plugin")
3130}
32313332allprojects {
···54535554val release: Boolean = !System.getenv("release").isNullOrEmpty()
5655allprojects {
5757- val p = P(project)
5656+ val p by lazy {
5757+ val p = P(project)
5858+ ext["p"] = p
5959+ p
6060+ }
5861 val modid: String by project.properties
5959- ext["p"] = p
6062 ext["release"] = release
6161- version = project.property("mod_version") as String
6262- if (!release) version = "${version}+${p.commit_id.take(7)}"
6363- group = rootProject.property("maven_group") as String
6464- println("configuring $modid ($project) v$version @ $group")
6363+ val isProject = project.projectDir.path.contains("/project/")
6464+6565 plugins.withId("java") {
6666- base {
6767- archivesBaseName = modid
6868- }
6966 java {
7067 toolchain.languageVersion = JavaLanguageVersion.of(17)
7168 withSourcesJar()
7269 }
7373- // be extra sure
7474- version = project.property("mod_version") as String
7070+ }
7171+7272+ if (isProject) {
7573 if (!release) version = "${version}+${p.commit_id.take(7)}"
7674 group = rootProject.property("maven_group") as String
7777-7878- tasks.named<Jar>("jar").configure {
7979- from("LICENSE") {
8080- rename { "LICENSE_$modid" }
7575+ println("configuring $modid ($project) v$version @ $group")
7676+ plugins.withId("java") {
7777+ base {
7878+ archivesBaseName = modid
7979+ }
8080+ tasks.named<Jar>("jar").configure {
8181+ from("LICENSE") {
8282+ rename { "LICENSE_$modid" }
8383+ }
8484+ duplicatesStrategy = DuplicatesStrategy.WARN
8185 }
8282- duplicatesStrategy = DuplicatesStrategy.WARN
8386 }
8484- }
85878686- plugins.withId("scala") {
8787- scala {
8888- scalaVersion = "3.7.1"
8989- }
9090- }
9191-9292- plugins.withId("fabric-loom") {
9393- extensions.getByType<LoomGradleExtensionAPI>().apply {
9494- splitEnvironmentSourceSets()
9595- runs["client"].programArgs += listOf("--username", "Player", "--uuid", "9e1b34e3-8031-4623-8918-eb7914ab564b")
8888+ plugins.withId("fabric-loom") {
8989+ extensions.getByType<LoomGradleExtensionAPI>().apply {
9090+ splitEnvironmentSourceSets()
9191+ runs["client"].programArgs += listOf(
9292+ "--username",
9393+ "Player",
9494+ "--uuid",
9595+ "9e1b34e3-8031-4623-8918-eb7914ab564b"
9696+ )
96979797- mods {
9898- register(modid) {
9999- sourceSet("main")
100100- sourceSet("client")
9898+ mods {
9999+ register(modid) {
100100+ sourceSet("main")
101101+ sourceSet("client")
102102+ }
101103 }
104104+105105+ mixin.useLegacyMixinAp = false
102106 }
103107104104- mixin.useLegacyMixinAp = false
105105- }
108108+ extensions.getByType<net.fabricmc.loom.api.fabricapi.FabricApiExtension>().apply {
109109+ configureTests {
110110+ modId = modid
111111+ eula = true
112112+ }
113113+ }
106114107107- extensions.getByType<net.fabricmc.loom.api.fabricapi.FabricApiExtension>().apply {
108108- configureTests {
109109- modId = modid
110110- eula = true
115115+ dependencies {
116116+ "modLocalRuntime"("maven.modrinth:ears:1.4.7+fabric-1.20")
111117 }
112112- }
113113-114114- dependencies {
115115- "modLocalRuntime"("maven.modrinth:ears:1.4.7+fabric-1.20")
116116- }
117118118118- if (project != rootProject) {
119119- tasks.named("runClient") {
120120- doFirst {
121121- val rootOptions = rootProject.file("run/options.txt").toPath()
122122- val options = file("run/options.txt").toPath()
123123- options.deleteIfExists()
124124- Files.createSymbolicLink(options, rootOptions)
119119+ if (project != rootProject) {
120120+ tasks.named("runClient") {
121121+ doFirst {
122122+ val rootOptions = rootProject.file("run/options.txt").toPath()
123123+ val options = file("run/options.txt").toPath()
124124+ options.deleteIfExists()
125125+ Files.createSymbolicLink(options, rootOptions)
126126+ }
125127 }
126128 }
127127- }
128129129129- tasks.processResources {
130130- val bookRoot = destinationDir.resolve("assets/hexcasting/patchouli_books/thehexbook")
131131- val langRoot = destinationDir.resolve("assets/$modid/lang")
130130+ tasks.processResources {
131131+ val bookRoot = destinationDir.resolve("assets/hexcasting/patchouli_books/thehexbook")
132132+ val langRoot = destinationDir.resolve("assets/$modid/lang")
132133133133- doLast {
134134- bookRoot.list()?.forEach { lang ->
135135- val langFile = langRoot.resolve("$lang.json")
136136- if (langFile.exists()) {
137137- val entries = JsonSlurper().parseText(langFile.readText()) as MutableMap<String, String>
138138- var n = 0
139139- for (bookFile in bookRoot.resolve(lang).walkTopDown()) {
140140- if (bookFile.isFile) {
141141- val json = JsonSlurper().parseText(bookFile.readText())
142142- if (json !is Map<*, *>) continue
143143- json as MutableMap<Any, Any>
144144- val name = json["name"]
145145- if (name is String) {
146146- entries["text.$modid.book.${n}"] = name
147147- json["name"] = "text.$modid.book.${n}"
148148- n++
149149- }
150150- val pages = json["pages"]
151151- if (pages !is MutableList<*>) continue
152152- pages as MutableList<Any>
153153- for (i in pages.indices) {
154154- val page = pages[i]
155155- if (page is String) {
156156- entries["text.$modid.book.${n}"] = page
157157- pages[i] = "text.$modid.book.${n}"
134134+ doLast {
135135+ bookRoot.list()?.forEach { lang ->
136136+ val langFile = langRoot.resolve("$lang.json")
137137+ if (langFile.exists()) {
138138+ val entries = JsonSlurper().parseText(langFile.readText()) as MutableMap<String, String>
139139+ var n = 0
140140+ for (bookFile in bookRoot.resolve(lang).walkTopDown()) {
141141+ if (bookFile.isFile) {
142142+ val json = JsonSlurper().parseText(bookFile.readText())
143143+ if (json !is Map<*, *>) continue
144144+ json as MutableMap<Any, Any>
145145+ val name = json["name"]
146146+ if (name is String) {
147147+ entries["text.$modid.book.${n}"] = name
148148+ json["name"] = "text.$modid.book.${n}"
158149 n++
159159- } else if (page is MutableMap<*, *>) {
160160- page as MutableMap<Any, Any>
161161- for (key in listOf("text", "title", "header")) {
162162- val text = page[key]
163163- if (text != null && text is String) {
164164- entries["text.$modid.book.${n}"] = text
165165- page[key] = "text.$modid.book.${n}"
166166- n++
150150+ }
151151+ val pages = json["pages"]
152152+ if (pages !is MutableList<*>) continue
153153+ pages as MutableList<Any>
154154+ for (i in pages.indices) {
155155+ val page = pages[i]
156156+ if (page is String) {
157157+ entries["text.$modid.book.${n}"] = page
158158+ pages[i] = "text.$modid.book.${n}"
159159+ n++
160160+ } else if (page is MutableMap<*, *>) {
161161+ page as MutableMap<Any, Any>
162162+ for (key in listOf("text", "title", "header")) {
163163+ val text = page[key]
164164+ if (text != null && text is String) {
165165+ entries["text.$modid.book.${n}"] = text
166166+ page[key] = "text.$modid.book.${n}"
167167+ n++
168168+ }
167169 }
168170 }
169171 }
172172+ bookFile.writeText(JsonOutput.toJson(json))
170173 }
171171- bookFile.writeText(JsonOutput.toJson(json))
172174 }
175175+ langFile.writeText(JsonOutput.toJson(entries))
173176 }
174174- langFile.writeText(JsonOutput.toJson(entries))
175177 }
176178 }
177179 }
180180+ }
181181+ }
182182+183183+ plugins.withId("scala") {
184184+ scala {
185185+ scalaVersion = "3.7.1"
178186 }
179187 }
180188
+1-15
gradle.properties
···11-# Done to increase the memory available to gradle.
21org.gradle.jvmargs=-Xmx1G
32org.gradle.java.installations.fromEnv=JDK17
44-# Fabric Properties
55-# check these on https://modmuss50.me/fabric.html
66-minecraft_version=1.20.1
77-yarn_mappings=1.20.1+build.10
88-loader_version=0.16.14
99-scala_loader_version=0.3.1.11
1010-# Mod Properties
1111-modid=hexic
1212-mod_version=2.0.0-alpha.01
1313-py_version=1.0
1414-maven_group=org.eu.net.pool
1515-# Dependencies
1616-# check this on https://modmuss50.me/fabric.html
1717-fabric_version=0.92.6+1.20.1
33+maven_group=org.eu.net.pool