From f89c32cbeeea08825813382fd9a618c1eb35c989 Mon Sep 17 00:00:00 2001 From: Caoimhe Byrne Date: Tue, 3 Jun 2025 21:11:48 +0100 Subject: [PATCH] Build: Set `FMLModType` depending on which ModLauncher version is used This attribute was previously set to `LIBRARY` before 0696479 where it was removed for the following reason: > however since we require shading and relocation on ML9 anyway, we may as well just remove it outright. This is fine for production, but relocation does not apply in development environments. The type should be declared as `GAMELIBRARY` on >=ML9, and `LIBRARY` on <=ML8. Anything which uses UniversalCraft should also be on the `GAME` layer, and cannot be on any other layer (e.g. PLUGIN) as it will not be able to access UniversalCraft classes. If we want other libraries to be usable in development environments (Vigilance, Elementa), we'll have to ship separate artifacts of those for >=ML9 and <=ML8 with the `FMLModType` attribute set accordingly. --- build.gradle.kts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 78a7fc9..09a46d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,3 +29,13 @@ preprocess { vars.put("STANDALONE", 0) vars.put("!STANDALONE", 1) } + +tasks.jar { + if (platform.isModLauncher) { + manifest { + // `GAMELIBRARY` is required to access Minecraft classes from ModLauncher 9 and higher. + val modType = if (platform.mcVersion >= 11700) "GAMELIBRARY" else "LIBRARY" + attributes(mapOf("FMLModType" to modType)) + } + } +}