@@ -9,10 +9,10 @@ import java.util.*
99
1010plugins {
1111 java
12- id(" xyz.wagyourtail .unimined" ) version " 1.3.14+neofix.1 " apply false
13- id(" xyz.wagyourtail.jvmdowngrader" ) version " 1.2.2 "
14- id(" com.diffplug.gradle.spotless" ) version " 8.0 .0" apply false
15- id(" com.gradleup.shadow" ) version " 9.2.2 " apply false
12+ id(" dev.firstdark .unimined" ) version " 1.0.3+1.4.2-SNAPSHOT " apply false
13+ id(" xyz.wagyourtail.jvmdowngrader" ) version " 1.3.5 "
14+ id(" com.diffplug.gradle.spotless" ) version " 8.1 .0" apply false
15+ id(" com.gradleup.shadow" ) version " 9.3.0 " apply false
1616 id(" com.hypherionmc.modutils.modpublisher" ) version " 2.1.8+snapshot.3" apply false
1717}
1818
@@ -41,6 +41,7 @@ val extProtocol = "mc_protocol"()!!.toInt()
4141val extIsLegacy = " isLegacy" ()!! .toBoolean()
4242val extIsJarMod = " isJarMod" ()!! .toBoolean()
4343val extIsModern = ! extIsLegacy && extProtocol >= 498
44+ val extIsOfficial = " mc_mappings_type" () == " official"
4445val extIsMCPJar = extIsJarMod && " mc_mappings_type" () == " mcp"
4546
4647// Only apply ATs to forge on non-legacy builds, or on Legacy Protocols above 1.5
@@ -60,7 +61,7 @@ subprojects {
6061 val isLoaderSource = path != " :common"
6162
6263 apply (plugin = " java" )
63- apply (plugin = " xyz.wagyourtail .unimined" )
64+ apply (plugin = " dev.firstdark .unimined" )
6465 apply (plugin = " xyz.wagyourtail.jvmdowngrader" )
6566 apply (plugin = " com.diffplug.spotless" )
6667 apply (plugin = " com.gradleup.shadow" )
@@ -80,6 +81,7 @@ subprojects {
8081 val isLegacy by extra(extIsLegacy)
8182 val isJarMod by extra(extIsJarMod)
8283 val isModern by extra(extIsModern)
84+ val isOfficial by extra(extIsOfficial)
8385 val isMCPJar by extra(extIsMCPJar)
8486 val accessWidenerFile by extra(extAWFile)
8587 val canUseATs by extra(extCanUseATs)
@@ -170,8 +172,82 @@ subprojects {
170172 version(mcVersion)
171173
172174 mappings {
173- devNamespace(" official" )
174- devFallbackNamespace(" official" )
175+ if (isOfficial) {
176+ devNamespace(" official" )
177+ devFallbackNamespace(" official" )
178+ } else {
179+ val mcMappings = " mc_mappings" ()!!
180+ when (mcMappingsType) {
181+ " mcp" -> {
182+ if (! isJarMod) {
183+ searge()
184+ }
185+ mcp((if (isJarMod) " legacy" else " stable" ), mcMappings)
186+ }
187+
188+ " forgeMCP" -> {
189+ forgeBuiltinMCP(" forge_version" ()!! )
190+ }
191+
192+ " retroMCP" -> {
193+ retroMCP(mcMappings)
194+ }
195+
196+ " mojmap" -> {
197+ mojmap()
198+ }
199+
200+ else -> throw GradleException (" Unknown or Unsupported Mappings version" )
201+ }
202+
203+ // Only use Intermediaries on Versions that support it
204+ val usingIntermediary = (isLegacy && protocol >= 39 ) || ! isLegacy
205+ if (usingIntermediary) {
206+ if (isModern) {
207+ intermediary()
208+ } else {
209+ legacyIntermediary()
210+ }
211+ }
212+
213+ // ability to add custom mappings
214+ stubs(" official" , mcMappingsType!! ) {
215+ c(" ModLoader" , " net/minecraft/src/ModLoader" )
216+ c(" BaseMod" , " net/minecraft/src/BaseMod" )
217+ // Fix: Fixed an inconsistent mapping in 1.16 and 1.16.1 between MCP and Mojmap
218+ if (! isLegacy && (protocol == 735 || protocol == 736 )) {
219+ c(
220+ " dng" ,
221+ " net/minecraft/client/gui/components/AbstractWidget"
222+ ) {
223+ m(" e;()I" , " func_238483_d_" , " getHeightRealms" )
224+ }
225+ }
226+ }
227+
228+ if (isMCPJar) {
229+ if (protocol <= 2 ) { // MC a1.1.2_01 and below
230+ devNamespace(" searge" )
231+ } else {
232+ devFallbackNamespace(" searge" )
233+ }
234+ } else if (usingIntermediary) {
235+ devFallbackNamespace(" intermediary" )
236+ }
237+ }
238+
239+ if (shouldDowngrade) {
240+ val apiVersion = if (buildVersion.isJava7) JavaVersion .VERSION_1_8 else buildVersion
241+ val downgradeClient = tasks.register(" downgradeClient" , DowngradeFiles ::class .java) {
242+ inputCollection = sourceSet.output.classesDirs + sourceSet.runtimeClasspath
243+ classpath = project.files()
244+ outputCollection.files
245+ }
246+
247+ runs.config(" client" ) {
248+ classpath = downgradeClient.get().outputCollection + files(jvmdg.getDowngradedApi(apiVersion))
249+ }
250+ }
175251 }
176252
177253 minecraftRemapper.config {
@@ -187,14 +263,15 @@ subprojects {
187263 val libName = if (! isLoaderSource) " fabric" else name
188264 val libVersion = " unilib_build_version" ()!!
189265 val libFile = " $libName${if (canDowngrade) " -native" else " " } "
266+ val libGrab = if (isOfficial) " implementation" else " modImplementation"
190267
191268 dependencies {
192269 // Annotations
193270 " compileOnly" (" com.google.code.findbugs:jsr305:3.0.2" )
194- " compileOnly" (" com.github.spotbugs:spotbugs-annotations:4.9.6 " )
271+ " compileOnly" (" com.github.spotbugs:spotbugs-annotations:4.9.8 " )
195272
196273 // Attach UniLib dependency
197- " implementation " (
274+ libGrab (
198275 " com.gitlab.cdagaming.unilib:$libPrefix -${
199276 libName.replaceFirstChar {
200277 if (it.isLowerCase()) it.titlecase(
@@ -231,6 +308,7 @@ subprojects {
231308 }
232309
233310 val relocatePath = " $modId .external"
311+ val uniLibPath = " unilib.external"
234312
235313 tasks.named<ShadowJar >(" shadowJar" ).configure {
236314 // Meta Exclusions
@@ -269,14 +347,15 @@ subprojects {
269347 exclude(" META-INF/native-image/com.kohlschutter.junixsocket/junixsocket-native-arm*/**" )
270348
271349 // Package Relocations
272- relocate(" net.lenni0451" , " $relocatePath .net.lenni0451" )
273350 relocate(" com.jagrosh" , " $relocatePath .com.jagrosh" )
274351 relocate(" org.meteordev" , " $relocatePath .org.meteordev" )
275- relocate(" io.github.classgraph" , " $relocatePath .io.github.classgraph" )
276- relocate(" nonapi.io.github.classgraph" , " $relocatePath .nonapi.io.github.classgraph" )
352+ // UniLib Relocations
353+ relocate(" net.lenni0451" , " $uniLibPath .net.lenni0451" )
354+ relocate(" io.github.classgraph" , " $uniLibPath .io.github.classgraph" )
355+ relocate(" nonapi.io.github.classgraph" , " $uniLibPath .nonapi.io.github.classgraph" )
277356 if (protocol < 755 ) {
278- relocate(" org.slf4j" , " $relocatePath .org.slf4j" )
279- relocate(" org.apache.logging.slf4j" , " $relocatePath .org.apache.logging.slf4j" )
357+ relocate(" org.slf4j" , " $uniLibPath .org.slf4j" )
358+ relocate(" org.apache.logging.slf4j" , " $uniLibPath .org.apache.logging.slf4j" )
280359 }
281360 // Integration Relocations
282361 if (! isLegacy) {
0 commit comments