From c3b40e0a6c531b12e3449f7472676a40ea8f21b7 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 15 Nov 2023 01:25:19 +0800 Subject: [PATCH] Update transformers to 5.2.77 --- gradle.properties | 2 +- .../plugin/ArchitecturyPluginExtension.kt | 22 ++++++++---- .../dev/architectury/plugin/ModLoader.kt | 36 +++++++++++++++++-- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 29be9ff..95b29c4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,5 +5,5 @@ loom_version_010Legacy=0.10.0.171 loom_version_010=0.10.0.188 loom_version_011=0.11.0.217 loom_version_11=1.1.313 -transformer_version=5.2.75 +transformer_version=5.2.77 base_version=3.4 \ No newline at end of file diff --git a/src/main/kotlin/dev/architectury/plugin/ArchitecturyPluginExtension.kt b/src/main/kotlin/dev/architectury/plugin/ArchitecturyPluginExtension.kt index f730669..e5bc8d0 100644 --- a/src/main/kotlin/dev/architectury/plugin/ArchitecturyPluginExtension.kt +++ b/src/main/kotlin/dev/architectury/plugin/ArchitecturyPluginExtension.kt @@ -30,7 +30,7 @@ import java.util.jar.JarOutputStream import java.util.jar.Manifest open class ArchitectPluginExtension(val project: Project) { - var transformerVersion = "5.2.75" + var transformerVersion = "5.2.77" var injectablesVersion = "1.0.10" var minecraft = "" private var compileOnly = false @@ -87,7 +87,7 @@ open class ArchitectPluginExtension(val project: Project) { } } } - + fun compileOnly() { if (compileOnly) { throw IllegalStateException("compileOnly() can only be called once for project ${project.path}!") @@ -98,16 +98,21 @@ open class ArchitectPluginExtension(val project: Project) { } fun properties(platform: String): Map { - return mutableMapOf( + val map = mutableMapOf( BuiltinProperties.MIXIN_MAPPINGS to loom.allMixinMappings.joinToString(File.pathSeparator), BuiltinProperties.INJECT_INJECTABLES to injectInjectables.toString(), BuiltinProperties.UNIQUE_IDENTIFIER to project.projectUniqueIdentifier(), BuiltinProperties.COMPILE_CLASSPATH to getCompileClasspath().joinToString(File.pathSeparator), - BuiltinProperties.MAPPINGS_WITH_SRG to loom.tinyMappingsWithSrg.toString(), BuiltinProperties.PLATFORM_NAME to platform, - BuiltinProperties.REFMAP_NAME to loom.refmapName, BuiltinProperties.MCMETA_VERSION to "4" ) + + if (platform != "neoforge") { + map[BuiltinProperties.REFMAP_NAME] = loom.refmapName + map[BuiltinProperties.MAPPINGS_WITH_SRG] = loom.tinyMappingsWithSrg.toString() + } + + return map } fun prepareTransformer() { @@ -145,7 +150,7 @@ open class ArchitectPluginExtension(val project: Project) { fun transform(name: String, action: Action) { transforms.getOrPut(name) { - Transform(project, "development" + name.capitalize()).also { transform -> + Transform(project, "development" + (if (name == "neoforge") "NeoForge" else name.capitalize())).also { transform -> if (!compileOnly) { project.configurations.maybeCreate(transform.devConfigName) } @@ -233,6 +238,11 @@ open class ArchitectPluginExtension(val project: Project) { loader(ModLoader.FORGE, action) } + @JvmOverloads + fun neoForge(action: Action = Action {}) { + loader(ModLoader.NEOFORGE, action) + } + @JvmOverloads fun loader(id: String, action: Action = Action {}) { loader(ModLoader.valueOf(id), action) diff --git a/src/main/kotlin/dev/architectury/plugin/ModLoader.kt b/src/main/kotlin/dev/architectury/plugin/ModLoader.kt index 3fe7bec..39b9ce3 100644 --- a/src/main/kotlin/dev/architectury/plugin/ModLoader.kt +++ b/src/main/kotlin/dev/architectury/plugin/ModLoader.kt @@ -4,7 +4,7 @@ import dev.architectury.plugin.loom.LoomInterface import dev.architectury.plugin.transformers.AddRefmapName import dev.architectury.transformer.transformers.* -class ModLoader( +open class ModLoader( val id: String, val transformDevelopment: Transform.() -> Unit, val transformProduction: TransformingTask.(loom: LoomInterface) -> Unit, @@ -13,7 +13,7 @@ class ModLoader( LOADERS[id] = this } - val titledId = id.capitalize() + open val titledId = id.capitalize() companion object { fun valueOf(id: String): ModLoader = @@ -81,6 +81,38 @@ class ModLoader( } ) + val NEOFORGE = object : ModLoader( + id = "neoforge", + transformDevelopment = { + add(TransformExpectPlatform::class.java) { file -> + this[BuiltinProperties.UNIQUE_IDENTIFIER] = projectGeneratedPackage(project, file) + } + add(RemapInjectables::class.java) { file -> + this[BuiltinProperties.UNIQUE_IDENTIFIER] = projectGeneratedPackage(project, file) + } + this += TransformPlatformOnly::class.java + + this += TransformNeoForgeAnnotations::class.java + this += TransformNeoForgeEnvironment::class.java + this += GenerateFakeNeoForgeMod::class.java + }, + transformProduction = { loom -> + add(TransformExpectPlatform()) { file -> + this[BuiltinProperties.UNIQUE_IDENTIFIER] = projectGeneratedPackage(project, file) + } + add(RemapInjectables()) { file -> + this[BuiltinProperties.UNIQUE_IDENTIFIER] = projectGeneratedPackage(project, file) + } + this += TransformPlatformOnly() + + this += TransformNeoForgeAnnotations() + this += TransformNeoForgeEnvironment() + } + ) { + override val titledId: String + get() = "NeoForge" + } + val QUILT = ModLoader( id = "quilt", transformDevelopment = {