mirror of
https://github.com/GTNewHorizons/lwjgl3ify.git
synced 2026-11-22 13:10:15 +00:00
Fix remaining LCL.getSources issues that caused e.g. broken NEI handlers
This commit is contained in:
1 parent
0469e8f6a5
commit
3febafc9ca
2 files changed
+50
-26
No files matched your search
+1
-1
@@ -8,7 +8,7 @@ def addGtForTesting = Boolean.parseBoolean(project.getProperties().getOrDefault(
|
||||
def addReikaModsForTesting = Boolean.parseBoolean(project.getProperties().getOrDefault("withReikaMods", "false"))
|
||||
|
||||
def asmVersion = '9.6'
|
||||
def rfbVersion = '0.3.6'
|
||||
def rfbVersion = '0.3.7'
|
||||
// 100% binary compatible, 1 minor source compatibility issue (removed a throws IOException clause)
|
||||
def gsonVersion = '2.10.1'
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ package me.eigenraven.lwjgl3ify.relauncher;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
@@ -21,30 +20,52 @@ import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
public class Lwjgl3ifyRelauncherTweaker implements ITweaker {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Lwjgl3ifyRelauncherTweaker() throws ReflectiveOperationException, MalformedURLException, URISyntaxException {
|
||||
URL mySrc = Lwjgl3ifyRelauncherTweaker.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation();
|
||||
while (mySrc.getProtocol()
|
||||
.equals("jar")) {
|
||||
final String all = mySrc.toString();
|
||||
mySrc = new URL(all.substring("jar:".length(), all.lastIndexOf('!')));
|
||||
private static boolean coremodInjected = false;
|
||||
|
||||
public Lwjgl3ifyRelauncherTweaker() {
|
||||
// Load early in prod, late in dev to avoid a crash
|
||||
if (FMLLaunchHandler.side() != null) {
|
||||
injectMyCoremod();
|
||||
}
|
||||
File myFile = new File(".");
|
||||
if (mySrc.getProtocol()
|
||||
.equals("file")) {
|
||||
myFile = Paths.get(myFile.toURI())
|
||||
.toFile();
|
||||
}
|
||||
|
||||
private void injectMyCoremod() {
|
||||
if (coremodInjected) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
URL mySrc = Lwjgl3ifyRelauncherTweaker.class.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation();
|
||||
while (mySrc.getProtocol()
|
||||
.equals("jar")) {
|
||||
final String all = mySrc.toString();
|
||||
mySrc = new URL(all.substring("jar:".length(), all.lastIndexOf('!')));
|
||||
}
|
||||
File myFile = new File(".");
|
||||
if (mySrc.getProtocol()
|
||||
.equals("file")) {
|
||||
myFile = Paths.get(myFile.toURI())
|
||||
.toFile();
|
||||
}
|
||||
// If this tweaker is loaded, FML skips loading the coremod by default.
|
||||
Launch.classLoader.addTransformerExclusion("me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod");
|
||||
final Class<CoreModManager> cmmClass = (Class<CoreModManager>) Class
|
||||
.forName("cpw.mods.fml.relauncher.CoreModManager", true, Launch.classLoader);
|
||||
final Method cmmAddCoremod = cmmClass
|
||||
.getDeclaredMethod("loadCoreMod", LaunchClassLoader.class, String.class, File.class);
|
||||
cmmAddCoremod.setAccessible(true);
|
||||
cmmAddCoremod.invoke(null, Launch.classLoader, "me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod", myFile);
|
||||
coremodInjected = true;
|
||||
} catch (InvocationTargetException e) {
|
||||
if (e.getCause() instanceof RuntimeException re) {
|
||||
throw re;
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// If this tweaker is loaded, FML skips loading the coremod by default.
|
||||
Launch.classLoader.addTransformerExclusion("me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod");
|
||||
final Class<CoreModManager> cmmClass = (Class<CoreModManager>) Class
|
||||
.forName("cpw.mods.fml.relauncher.CoreModManager");
|
||||
final Method cmmAddCoremod = cmmClass
|
||||
.getDeclaredMethod("loadCoreMod", LaunchClassLoader.class, String.class, File.class);
|
||||
cmmAddCoremod.setAccessible(true);
|
||||
cmmAddCoremod.invoke(null, Launch.classLoader, "me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod", myFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,8 +88,11 @@ public class Lwjgl3ifyRelauncherTweaker implements ITweaker {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {}
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
injectMyCoremod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
|
||||
Reference in new issue
Block a user