diff --git a/build.gradle b/build.gradle index ae889d2..5808c1f 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,8 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform import java.nio.file.Paths plugins { - id "fabric-loom" version "1.10-SNAPSHOT" + id "net.fabricmc.fabric-loom-remap" version "1.16-SNAPSHOT" apply false + id "net.fabricmc.fabric-loom" version "1.16-SNAPSHOT" apply false id "maven-publish" // Manifold preprocessor @@ -12,6 +13,13 @@ plugins { // Transfer gradle extra properties to root project extra properties gradle.ext.properties.each { prop -> project.ext.set(prop.key, prop.value) } +def loomRemapStr = project.findProperty("fabric_loom_remap")?.toString() +assert loomRemapStr in ["true", "false"] : + "${loomRemapStr == null ? "Missing" : "Invalid"} property in ${Paths.get(version_properties_path, "${project.targetVersion}.properties")} : " + + "fabric_loom_remap${loomRemapStr == null ? "" : "=$loomRemapStr"}" +def loomRemap = loomRemapStr.toBoolean() +apply plugin: loomRemap ? "net.fabricmc.fabric-loom-remap" : "net.fabricmc.fabric-loom" + generateBuildProperties(project.minecraftVersions, project.targetVersion) version = "${project.mod_version}-mc${project.targetVersion}" @@ -64,24 +72,40 @@ loom { // } } +configurations { + remappableImplementation + remappableCompileOnly + remappableLocalRuntime +} + +if (loomRemap) { + configurations.modImplementation.extendsFrom(configurations.remappableImplementation) + configurations.modCompileOnly.extendsFrom(configurations.remappableCompileOnly) + configurations.modLocalRuntime.extendsFrom(configurations.remappableLocalRuntime) +} else { + configurations.implementation.extendsFrom(configurations.remappableImplementation) + configurations.compileOnly.extendsFrom(configurations.remappableCompileOnly) + configurations.localRuntime.extendsFrom(configurations.remappableLocalRuntime) +} + dependencies { // To change the versions see the gradle.properties file or the ./properties/${minecraftVersion}.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}+${project.targetVersion}" + if (loomRemap) mappings loom.officialMojangMappings() + remappableImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" + remappableImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}+${project.targetVersion}" // Override Fabric API version for local testing (runClient/runServer) if (project.hasProperty("test_fabric_api_version")) - modLocalRuntime "net.fabricmc.fabric-api:fabric-api:${project.test_fabric_api_version}" + remappableLocalRuntime "net.fabricmc.fabric-api:fabric-api:${project.test_fabric_api_version}" // Mod Compatibility - if (project.hasProperty("mod_dynmap_version")) - modCompileOnly "maven.modrinth:dynmap:${project.mod_dynmap_version}" - if (project.hasProperty("mod_styled_chat_version")) - modCompileOnly "maven.modrinth:styled-chat:${project.mod_styled_chat_version}" - if (project.hasProperty("mod_styled_chat_placeholder_api_version")) - modCompileOnly "eu.pb4:placeholder-api:${project.mod_styled_chat_placeholder_api_version}" + if (project.hasProperty("mod_dynmap_version") && !project.mod_dynmap_version.allWhitespace) + remappableCompileOnly "maven.modrinth:dynmap:${project.mod_dynmap_version}" + if (project.hasProperty("mod_styled_chat_version") && !project.mod_styled_chat_version.allWhitespace) + remappableCompileOnly "maven.modrinth:styled-chat:${project.mod_styled_chat_version}" + if (project.hasProperty("mod_styled_chat_placeholder_api_version") && !project.mod_styled_chat_placeholder_api_version.allWhitespace) + remappableCompileOnly "eu.pb4:placeholder-api:${project.mod_styled_chat_placeholder_api_version}" // Manifold annotationProcessor "systems.manifold:manifold-preprocessor:${project.manifold_version}" diff --git a/properties/1.19.1.properties b/properties/1.19.1.properties index 1f28091..4a38f82 100644 --- a/properties/1.19.1.properties +++ b/properties/1.19.1.properties @@ -1,5 +1,10 @@ java_version=17 +# Fabric Loom +# - For Minecraft versions <26.1: enable remap +# - For Minecraft versions >=26.1: disable remap +fabric_loom_remap=true + # Fabric Properties # check these on https://fabricmc.net/develop fabric_loader_version=0.16.10 diff --git a/properties/1.19.3.properties b/properties/1.19.3.properties index a017f72..afe02c0 100644 --- a/properties/1.19.3.properties +++ b/properties/1.19.3.properties @@ -1,5 +1,10 @@ java_version=17 +# Fabric Loom +# - For Minecraft versions <26.1: enable remap +# - For Minecraft versions >=26.1: disable remap +fabric_loom_remap=true + # Fabric Properties # check these on https://fabricmc.net/develop fabric_loader_version=0.16.10 diff --git a/properties/1.19.properties b/properties/1.19.properties index a957218..9a6ff87 100644 --- a/properties/1.19.properties +++ b/properties/1.19.properties @@ -1,5 +1,10 @@ java_version=17 +# Fabric Loom +# - For Minecraft versions <26.1: enable remap +# - For Minecraft versions >=26.1: disable remap +fabric_loom_remap=true + # Fabric Properties # check these on https://fabricmc.net/develop fabric_loader_version=0.16.10 diff --git a/properties/1.20.3.properties b/properties/1.20.3.properties index 22444bf..a45722e 100644 --- a/properties/1.20.3.properties +++ b/properties/1.20.3.properties @@ -1,5 +1,10 @@ java_version=17 +# Fabric Loom +# - For Minecraft versions <26.1: enable remap +# - For Minecraft versions >=26.1: disable remap +fabric_loom_remap=true + # Fabric Properties # check these on https://fabricmc.net/develop fabric_loader_version=0.16.10 diff --git a/properties/1.20.properties b/properties/1.20.properties index 28eae28..d270615 100644 --- a/properties/1.20.properties +++ b/properties/1.20.properties @@ -1,5 +1,10 @@ java_version=17 +# Fabric Loom +# - For Minecraft versions <26.1: enable remap +# - For Minecraft versions >=26.1: disable remap +fabric_loom_remap=true + # Fabric Properties # check these on https://fabricmc.net/develop fabric_loader_version=0.16.10 diff --git a/properties/1.21.properties b/properties/1.21.properties index 95bb790..e8b55f4 100644 --- a/properties/1.21.properties +++ b/properties/1.21.properties @@ -1,5 +1,10 @@ java_version=21 +# Fabric Loom +# - For Minecraft versions <26.1: enable remap +# - For Minecraft versions >=26.1: disable remap +fabric_loom_remap=true + # Fabric Properties # check these on https://fabricmc.net/develop fabric_loader_version=0.16.10