Skip to content

Commit

Permalink
Remove the need for lwjgl package transformer exclusions (#106)
Browse files Browse the repository at this point in the history
* Remove the need for lwjgl package transformer exclusions

* fix derp
  • Loading branch information
eigenraven authored Jan 7, 2024
1 parent 89bbfc8 commit f67c009
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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/" };

Expand Down

0 comments on commit f67c009

Please sign in to comment.