Init Commit

This commit is contained in:
xiaozhou233 committed 2026-01-16 00:01:38 +08:00
commit d492ba7224
39 files changed
+27426

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
plugins {
id 'java'
id "com.gradleup.shadow" version "8.3.9"
}
group = 'cn.xiaozhou.orangex.loader'
version = 'unspecified'
repositories {
mavenCentral()
}
dependencies {
compileOnly(files("../libraries/JuiceLoader.jar"))
}
@@ -0,0 +1,45 @@
package cn.xiaozhou233.orangex.loader;
import cn.xiaozhou233.juiceloader.JuiceLoader;
import java.io.File;
public class Loader {
public static String userDir = System.getProperty("user.home");
public static Thread clientThread;
public static ClassLoader minecraftClassLoader;
public static void start() {
System.out.println("======== Loader START ========");
// Find client thread
for (Thread t : Thread.getAllStackTraces().keySet()) {
if ("Client thread".equals(t.getName())) {
clientThread = t;
break;
}
}
if (clientThread == null) {
throw new IllegalStateException("Cannot find Minecraft client thread");
}
// Get Minecraft ClassLoader
minecraftClassLoader = clientThread.getContextClassLoader();
System.out.println("Minecraft ClassLoader: " + minecraftClassLoader);
// Load OrangeX
File injectionFile = new File(userDir + "/.orangex/OrangeX.jar");
System.out.println("OrangeX Injection: " + injectionFile.getAbsolutePath());
JuiceLoader.AddToClassLoader(injectionFile.getAbsolutePath(), minecraftClassLoader);
// Start OrangeX
try {
Class<?> orangeXClass = Class.forName("cn.xiaozhou233.orangex.OrangeX", true, minecraftClassLoader);
orangeXClass.getMethod("start").invoke(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
System.out.println("======== Loader END ========");
}
}