Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
182 lines (161 loc) · 6.86 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
182 lines (161 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import gg.meza.stonecraft.mod
plugins {
id("gg.meza.stonecraft")
}
val minecraft = stonecutter.current.version
val unobfuscated = stonecutter.eval(minecraft, ">=26.1")
repositories {
mavenCentral()
maven("https://maven.creeperhost.net/") { name = "CreeperHost" }
maven("https://api.modrinth.com/maven") {
name = "Modrinth"
content { includeGroup("maven.modrinth") }
}
maven("https://cursemaven.com") {
name = "CurseMaven"
content { includeGroup("curse.maven") }
}
maven("https://maven.shedaniel.me/") { name = "Shedaniel" }
maven("https://maven.terraformersmc.com/releases/") { name = "TerraformersMC" }
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") { name = "DevAuth" }
}
// Refined Storage 1.x is only on Modrinth's maven; 2.x and later publish a jar per loader to CreeperHost
val refinedStorage = when {
mod.hasProp("rs_modrinth_id") -> "maven.modrinth:refined-storage:${mod.prop("rs_modrinth_id")}"
else -> "com.refinedmods.refinedstorage:refinedstorage-${mod.loader}:${mod.prop("rs_version")}"
}
dependencies {
val compile = if (unobfuscated) "compileOnly" else "modCompileOnly"
val runtime = if (unobfuscated) "localRuntime" else "modLocalRuntime"
add(compile, refinedStorage)
add(runtime, refinedStorage)
// Reborn Storage's Advanced Wireless Transmitter takes the cards too. Compile only, as it's optional
if (mod.hasProp("rebornstorage_file")) {
add(compile, "curse.maven:rebornstorage-256662:${mod.prop("rebornstorage_file")}")
}
if (mod.isFabric) {
// Cloth Config backs the config on Fabric; ModMenu is optional and only adds the in-game config button
add(if (unobfuscated) "api" else "modApi", "me.shedaniel.cloth:cloth-config-fabric:${mod.prop("cloth_config_version")}") {
exclude(group = "net.fabricmc.fabric-api")
}
add(compile, "com.terraformersmc:modmenu:${mod.prop("modmenu_version")}")
add(runtime, "com.terraformersmc:modmenu:${mod.prop("modmenu_version")}")
// Refined Storage jar-in-jars Team Reborn Energy, but dev runs don't pick the nested copy up
add(runtime, "teamreborn:energy:${mod.prop("tr_energy_version")}")
}
// Lets runClient sign in with a real Microsoft account. Dev runtime only, so it isn't in the built jar
add(runtime, "me.djtheredstoner:DevAuth-${if (mod.isForge) "forge-latest" else mod.loader}:${property("devauth_version")}")
}
stonecutter {
// Refined Storage 2 (1.21+) is a rewrite with a different API to Refined Storage 1
constants.put("rs2", stonecutter.eval(minecraft, ">=1.21"))
// Minecraft renamed ResourceLocation to Identifier in 1.21.11
replacements.string(stonecutter.current.parsed < "1.21.11") {
replace("Identifier", "ResourceLocation")
}
}
// Fabric has no datagen here, so it reuses the NeoForge recipes and models for the same Minecraft version
if (mod.isFabric) {
sourceSets.main {
// From 1.21.4 the generated files land in a client/ folder
val client = if (stonecutter.eval(minecraft, ">=1.21.4")) "/client" else ""
resources.srcDir(rootProject.file("versions/$minecraft-neoforge/src/main/generated$client"))
}
}
// Forge 1.20.1 treats every classpath folder as its own mod and crashes on the bare generated folder Stonecraft adds,
// so fold the generated files into the normal resources instead
if (mod.isForge) {
val generated = file("src/main/generated")
sourceSets.main {
resources.srcDir(generated)
}
afterEvaluate {
tasks.withType<JavaExec>().configureEach {
classpath = classpath.filter { it != generated }
}
}
}
// Forge 1.15.2 and 1.16.5 run on Java 8, but Stonecraft compiles everything from 1.20.5 down with Java 17
if (stonecutter.eval(minecraft, "<1.17")) {
tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}
}
// The game test framework arrived in 1.17, so there's nothing for chiseledGameTest to run before that. Forge's older
// userdev has no game test run either, and Loom fails on a run without a main class even when it's skipped
if (stonecutter.eval(minecraft, "<1.17")) {
loom.runs.named("gameTestServer") {
mainClass.set("none")
}
gradle.projectsEvaluated {
tasks.named("runGameTestServer") {
enabled = false
}
}
}
// Forge 1.15.2 itself only starts on Java 8, as it needs the Nashorn engine that later Java versions removed
if (stonecutter.eval(minecraft, "<1.16")) {
tasks.withType<JavaExec>().configureEach {
javaLauncher.set(javaToolchains.launcherFor { languageVersion.set(JavaLanguageVersion.of(8)) })
}
}
// DevAuth supplies the real account name, and Minecraft refuses a second --username from Stonecraft's defaults
afterEvaluate {
loom.runs.named("client") {
programArguments.set(programArguments.get().filterNot { it.startsWith("--username") })
}
}
tasks.named<Jar>("jar") {
// Datagen bookkeeping stays in git but not in the jar
exclude(".cache/**")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
loom {
runs.named("client") {
jvmArguments.add("-Ddevauth.enabled=true")
}
// Forge 1.15's early loading window needs LWJGL natives that don't exist for Apple Silicon, and datagen has no use for it
if (stonecutter.eval(minecraft, "<1.16")) {
runs.configureEach {
jvmArguments.add("-Dfml.earlyprogresswindow=false")
}
}
if (mod.isForge) {
forge {
mixinConfig("${mod.id}.mixins.json")
}
// Without this Forge loads the classes and resources folders as two separate mods
mods {
register(mod.id) {
sourceSet(sourceSets.main.get())
}
}
}
}
modSettings {
runDirectory = rootProject.layout.projectDirectory.dir("run/${project.name}")
variableReplacements = mapOf(
"authors" to project.property("mod.authors").toString(),
"license" to project.property("mod.license").toString(),
"rsVersionRange" to mod.prop("rs_version_range"),
// e.g. 21.1.264 -> [21.1,) so players aren't forced onto the exact NeoForge build we compiled against
"neoforgeVersionRange" to "[${mod.prop("neoforge_version", "0.0").substringBeforeLast('.')},)",
"forgeLoaderVersion" to mod.prop("forge_loader_version", ""),
)
}
publishMods {
// Forge only started shipping Mixin in 1.16
val needsMixinBootstrap = stonecutter.eval(minecraft, "<1.16")
modrinth {
requires("refined-storage")
if (needsMixinBootstrap) requires("mixinbootstrap")
if (mod.isFabric) requires("fabric-api")
}
curseforge {
client = true
server = true
requires("refined-storage")
if (needsMixinBootstrap) requires("mixinbootstrap")
if (mod.isFabric) requires("fabric-api")
}
}