forked from Traben-0/Entity_Model_Features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
253 lines (218 loc) · 8.77 KB
/
build.gradle.kts
File metadata and controls
253 lines (218 loc) · 8.77 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
//import gg.essential.gradle.multiversion.StripReferencesTransform.Companion.registerStripReferencesAttribute
import gg.essential.gradle.util.*
//import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// If you're using Kotlin, it needs to be applied before the multi-version plugin
// kotlin("jvm")
// Apply the multi-version plugin, this does all the configuration necessary for the preprocessor to
// work. In particular it also applies `com.replaymod.preprocess`.
// In addition it primarily also provides a `platform` extension which you can use in this build script
// to get the version and mod loader of the current project.
id("gg.essential.multi-version")
// If you do not care too much about the details, you can just apply essential-gradle-toolkits' defaults for
// Minecraft, fabric-loader, forge, mappings, etc. versions.
// You can also overwrite some of these if need be. See the `gg.essential.defaults.loom` README section.
// Otherwise you'll need to configure those as usual for (architectury) loom.
id("gg.essential.defaults")
}
//tasks.compileKotlin.setJvmDefault("all")
//tasks.withType<KotlinCompile> {
// kotlinOptions {
// languageVersion = "1.9"
// apiVersion = "1.9"
// }
//}
repositories {
mavenCentral()
maven("https://api.modrinth.com/maven")
maven("https://mvnrepository.com/artifact/com.demonwav.mcdev/annotations")
maven("https://maven.terraformersmc.com/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven ("https://repo.redlance.org/public")
}
val mcVersion = platform.mcVersion
val modVersion = properties["mod_version"].toString()
base.archivesName.set("entity_model_features-$modVersion-${project.name}")
// todo figure out why preprocessor wont work with these
val accessWidener = "entity_model_features_" + when {
mcVersion >= 12111 -> 13
mcVersion >= 12109 -> 12
mcVersion >= 12106 -> 11
mcVersion >= 12105 -> 10
mcVersion >= 12104 -> 9
mcVersion >= 12102 -> 8
mcVersion >= 12100 -> 7
mcVersion >= 12006 -> 6
mcVersion >= 12004 -> 5
mcVersion >= 12002 -> 4
mcVersion >= 12001 -> 3
else -> throw IllegalStateException("Unsupported version: $mcVersion")
} + ".accesswidener"
//val common = registerStripReferencesAttribute("common") {
// excludes.add("net.minecraft")
//}
dependencies {
// If you are depending on a multi-version library following the same scheme as the Essential libraries (that is
// e.g. `elementa-1.8.9-forge`), you can `toString` `platform` directly to get the respective artifact id.
// api("gg.essential:elementa:710")
// universalcraft neoforge is just forge currently
// val ucVer =
// if(platform.isNeoForge) platform.toString().replace("neo","")
// else platform.toString()
//
// compileOnly("gg.essential:universalcraft-$ucVer:415"){
// // Setting the attribute to `true` will cause the transformer to apply to this specific artifact
// attributes { attribute(common, true) }
// }
// compileOnly("gg.essential:elementa:710"){
// attributes { attribute(common, true) }
// }
// compileOnly("gg.essential:vigilance:306"){
// attributes { attribute(common, true) }
// exclude(group = "gg.essential", module = "elementa")
// }
//
// implementation(include("gg.essential:elementa:710")!!)
// implementation(include("gg.essential:universalcraft-$ucVer:415")!!)
// implementation(include("gg.essential:vigilance:306")!!)
fun modImpl(modPrefix: String, vararg versions: Pair<Int, String?>) {
for ((versionMC, versionMod) in versions) {
if (platform.mcVersion >= versionMC) {
if (versionMod != null) {
modImplementation("$modPrefix$versionMod") {
exclude("net.fabricmc.fabric-api")
isTransitive = true
}
}
break
}
}
}
fun ver(fabric: String?, forge: String?, neoforge: String?): String? = when {
platform.isFabric -> fabric
platform.isForge -> forge
else -> neoforge
}
if (properties["use_local_etf"] == "true") {
// used to run with a local ETF repo that may have changes
val etf = "entity_texture_features-${properties["etf_version"]}-${project.name}"
modImplementation(files(File(rootDir.parent, "Entity_Texture_Features/jars/$etf.jar")))
} else {
// public modrinth ETF builds
val etf = "${properties["etf_version"]}-${platform.loaderStr.lowercase()}-${platform.mcVersionStr}"
modImplementation("maven.modrinth:entitytexturefeatures:$etf")
}
// modImpl("maven.modrinth:ebe:",
// 12104 to "YokFoILZ",
// 12102 to "fOVHsM6M",
// 12100 to "HBZAPs3u",
// )
modImpl("maven.modrinth:iris:",
12105 to "N0ln8GKQ",
12100 to "kuOV4Ece",
12006 to "1bvcmYOc",
12004 to "hq98tuSS",
12002 to "Cjwm9s3i",
12000 to ver("s5eFLITc", null, null),
)
modImpl("maven.modrinth:oculus:",
12002 to null,
12000 to ver(null, "iQ1SwGc3", null),
)
modImpl("maven.modrinth:modmenu:",
12105 to "R7uVB42W",
12102 to "PcJvQYqu",
12100 to "9FL4cmP7",
12006 to "mtTzRMV2",
12004 to "sjtVVlsA",
12002 to "TwfjidT5",
12000 to "RTFDnTKf",
)
if (!platform.isForge) {
if (mcVersion >= 12109) {
compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCommon:1.1.0+alpha.1+mc.1.21.9")
compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCore:1.1.0+alpha.1+mc.1.21.9")
} else if (mcVersion >= 12100) {
compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCommon:1.0.14+mc.1.21.1")
compileOnly("com.zigythebird.playeranim:PlayerAnimationLibCore:1.0.14+mc.1.21.1")
}
}
if (platform.isNeoForge && mcVersion < 12002) { // NeoForge 20.2.84+ added it themselves
include("io.github.llamalad7:mixinextras-neoforge:0.4.1:slim")
}
if (platform.isForge) {
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1")!!)
implementation(include("io.github.llamalad7:mixinextras-forge:0.4.1")!!)
}
implementation("com.demonwav.mcdev:annotations:2.1.0")
}
tasks.processResources {
// Expansions are already set up for `version` (or `file.jarVersion`) and `mcVersionStr`.
// You do not need to set those up manually.
}
loom {
// If you need to use a tweaker on legacy (1.12.2 and below) forge:
// if (platform.isLegacyForge) {
// launchConfigs.named("client") {
// arg("--tweakClass", "gg.essential.loader.stage0.EssentialSetupTweaker")
// // And maybe a core mod?
// property("fml.coreMods.load", "com.example.asm.CoreMod")
// }
// }
// // Mixin on forge? (for legacy forge you will still need to register a tweaker to set up mixin)
accessWidenerPath = project.parent!!.file("src/main/resources/$accessWidener")
if (isForge) {
forge {
mixinConfig("entity_model_features.mixins.json")
// And maybe an access transformer?
// Though try to avoid these, cause they are not automatically translated to Fabric's access widener
//accessTransformer(project.parent!!.file("src/main/resources/entity_model_features.access"))
convertAccessWideners = true
}
}
if (isNeoForge) {
neoForge {
}
}
}
loom.noServerRunConfigs()
tasks.remapJar {
injectAccessWidener = true
if (!platform.isFabric) atAccessWideners.add(accessWidener)
}
tasks.processResources {
inputs.property("project_version", modVersion)
filesMatching("fabric.mod.json") {
expand(mapOf("version" to modVersion))
}
filesMatching("META-INF/mods.toml") {
if (platform.isNeoForge || platform.isFabric) {
exclude()
} else {
expand(mapOf("version" to modVersion))
}
}
filesMatching("META-INF/neoforge.mods.toml") {
if (platform.isFabric || platform.isForge) {
exclude()
} else {
expand(mapOf("version" to modVersion))
if (platform.isNeoForge && platform.mcVersion < 12005) {
// NeoForge still uses the old mods.toml name until 1.20.5
name = "mods.toml"
}
}
}
filesMatching("entity_model_features_*.accesswidener") {
if (this.name != accessWidener) this.exclude()
}
}
tasks.register<Copy>("copyArtifacts") {
from(layout.buildDirectory.dir("libs").get())
into("${rootDir}\\jars")
mustRunAfter(tasks.build)
delete(layout.buildDirectory.dir("libs").get())
}
tasks.build {
finalizedBy("copyArtifacts")
}