Skip to content

Commit

Permalink
Update transformers to 5.2.80
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Nov 16, 2023
1 parent 2c00900 commit d56e09b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.79
transformer_version=5.2.80
base_version=3.4
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import java.util.jar.JarOutputStream
import java.util.jar.Manifest

open class ArchitectPluginExtension(val project: Project) {
var transformerVersion = "5.2.79"
var transformerVersion = "5.2.80"
var injectablesVersion = "1.0.10"
var minecraft = ""
private var compileOnly = false
Expand Down Expand Up @@ -126,6 +126,15 @@ open class ArchitectPluginExtension(val project: Project) {
writer.write(file.toPath(), pair.clazz, pair.properties)
}
}

if (transform.name == "neoforge") {
project.configurations.getByName("developmentForgeLike").forEach { file ->
(transform.transformers.map { it.apply(file.toPath()) } + ModLoader.applyNeoForgeForgeLikeDev(loom, transform))
.forEach { pair ->
writer.write(file.toPath(), pair.clazz, pair.properties)
}
}
}
}
}

Expand All @@ -150,9 +159,13 @@ open class ArchitectPluginExtension(val project: Project) {

fun transform(name: String, action: Action<Transform>) {
transforms.getOrPut(name) {
Transform(project, "development" + (if (name == "neoforge") "NeoForge" else name.capitalize())).also { transform ->
Transform(project, name, "development" + (if (name == "neoforge") "NeoForge" else name.capitalize())).also { transform ->
if (!compileOnly) {
project.configurations.maybeCreate(transform.devConfigName)

if (name == "neoforge") {
project.configurations.maybeCreate("developmentForgeLike")
}
}
action.execute(transform)

Expand Down Expand Up @@ -437,6 +450,21 @@ open class ArchitectPluginExtension(val project: Project) {
})
} as Jar
}

fun forgeLike(action: Action<CommonSettings>) {
common {
clear()
action.execute(this)
}
}

@JvmOverloads
fun forgeLike(platforms: Iterable<String>, action: CommonSettings.() -> Unit = {}) {
forgeLike {
it.add(platforms)
action(it)
}
}
}

private fun File.createEmptyJar() {
Expand All @@ -446,11 +474,17 @@ private fun File.createEmptyJar() {

data class Transform(
val project: Project,
val name: String,
val devConfigName: String,
val transformers: MutableList<Function<Path, TransformerPair>> = mutableListOf(),
var envAnnotationProvider: String = "net.fabricmc:fabric-loader:+",
var platformPackage: String? = null,
val extraForgeLikeToNeoForgeRemaps: MutableMap<String, String> = mutableMapOf(),
) {
fun remapForgeLike(remap: String, to: String) {
extraForgeLikeToNeoForgeRemaps[remap] = to
}

operator fun plusAssign(transformer: TransformerPair) {
transformers.add(Function { transformer })
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/dev/architectury/plugin/ModLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package dev.architectury.plugin

import dev.architectury.plugin.loom.LoomInterface
import dev.architectury.plugin.transformers.AddRefmapName
import dev.architectury.transformer.shadowed.impl.com.google.gson.Gson
import dev.architectury.transformer.transformers.*
import dev.architectury.transformer.util.TransformerPair

open class ModLoader(
val id: String,
Expand Down Expand Up @@ -134,6 +136,12 @@ open class ModLoader(
get() = "NeoForge"
}

fun applyNeoForgeForgeLikeDev(loom: LoomInterface, transform: Transform): List<TransformerPair> {
val properties = mutableMapOf<String, Any>()
properties[BuiltinProperties.NEOFORGE_LIKE_REMAPS] = transform.extraForgeLikeToNeoForgeRemaps
return listOf(TransformerPair(TransformForgeLikeToNeoForge::class.java, Gson().toJsonTree(properties).asJsonObject))
}

val QUILT = ModLoader(
id = "quilt",
transformDevelopment = {
Expand Down

0 comments on commit d56e09b

Please sign in to comment.