From f67c0091c021a36f60ae50874deb22ed034deb40 Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sun, 7 Jan 2024 20:06:19 +0000 Subject: [PATCH] Remove the need for lwjgl package transformer exclusions (#106) * Remove the need for lwjgl package transformer exclusions * fix derp --- build.gradle | 4 ++-- dependencies.gradle | 4 ++-- .../lwjgl3ify/core/Lwjgl3ifyCoremod.java | 1 - .../lwjgl3ify/core/LwjglRedirectTransformer.java | 14 +++++++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index f4f81bd7..952a3c59 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1704135167 +//version: 1704650211 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -53,7 +53,7 @@ plugins { id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version id 'com.modrinth.minotaur' version '2.+' apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false - id 'com.gtnewhorizons.retrofuturagradle' version '1.3.26' + id 'com.gtnewhorizons.retrofuturagradle' version '1.3.27' } print("You might want to check out './gradlew :faq' if your build fails.\n") diff --git a/dependencies.gradle b/dependencies.gradle index 8c83264e..ad689ba3 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -11,8 +11,8 @@ def asmVersion = '9.5' dependencies { // Resolve newer versions of LaunchWrapper to allow java 9+ compat - vanilla_minecraft('net.minecraft:launchwrapper:1.17.3') { transitive = false } - forgePatchesEmbedded('net.minecraft:launchwrapper:1.17.3') { transitive = false } + vanilla_minecraft('net.minecraft:launchwrapper:1.17.4') { transitive = false } + forgePatchesEmbedded('net.minecraft:launchwrapper:1.17.4') { transitive = false } forgePatchesEmbedded("org.ow2.asm:asm:${asmVersion}") forgePatchesEmbedded("org.ow2.asm:asm-commons:${asmVersion}") diff --git a/src/main/java/me/eigenraven/lwjgl3ify/core/Lwjgl3ifyCoremod.java b/src/main/java/me/eigenraven/lwjgl3ify/core/Lwjgl3ifyCoremod.java index da0bcf0c..3bf725b8 100644 --- a/src/main/java/me/eigenraven/lwjgl3ify/core/Lwjgl3ifyCoremod.java +++ b/src/main/java/me/eigenraven/lwjgl3ify/core/Lwjgl3ifyCoremod.java @@ -26,7 +26,6 @@ import me.eigenraven.lwjgl3ify.Tags; @IFMLLoadingPlugin.MCVersion("1.7.10") -@IFMLLoadingPlugin.TransformerExclusions({ "org.lwjglx", "org.lwjgl", "org.lwjgl.input", "org.lwjglx.input" }) @IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE - 2) public class Lwjgl3ifyCoremod implements IFMLLoadingPlugin, IEarlyMixinLoader { diff --git a/src/main/java/me/eigenraven/lwjgl3ify/core/LwjglRedirectTransformer.java b/src/main/java/me/eigenraven/lwjgl3ify/core/LwjglRedirectTransformer.java index ba0f5054..562f47ed 100644 --- a/src/main/java/me/eigenraven/lwjgl3ify/core/LwjglRedirectTransformer.java +++ b/src/main/java/me/eigenraven/lwjgl3ify/core/LwjglRedirectTransformer.java @@ -1,5 +1,8 @@ package me.eigenraven.lwjgl3ify.core; +import java.util.Arrays; +import java.util.stream.Stream; + import net.minecraft.launchwrapper.IClassTransformer; import org.spongepowered.asm.lib.AnnotationVisitor; @@ -21,6 +24,9 @@ public class LwjglRedirectTransformer extends Remapper implements IClassTransfor public LwjglRedirectTransformer() { // Only use the last constructed transformer activeInstance = this; + excludedPackages = Stream.concat(Arrays.stream(fromPrefixes), Arrays.stream(toPrefixes)) + .map(s -> s.replace('/', '.')) + .toArray(String[]::new); } @Override @@ -31,9 +37,14 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) if (basicClass == null) { return null; } - if (name.contains("lwjgl3ify")) { + if (transformedName.contains("lwjgl3ify")) { return basicClass; } + for (String prefix : excludedPackages) { + if (transformedName.startsWith(prefix)) { + return basicClass; + } + } ClassReader reader = new ClassReader(basicClass); ClassWriter writer = new ClassWriter(0); ClassVisitor visitor = new EscapingClassRemapper(writer); @@ -51,6 +62,7 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) } final String[] fromPrefixes = new String[] { "org/lwjgl/", "javax/xml/bind/", "javax/servlet/" }; + final String[] excludedPackages; final String[] toPrefixes = new String[] { "org/lwjglx/", "jakarta/xml/bind/", "jakarta/servlet/" };