mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
feat: add Loader module for JuiceAgent jar loading
- Add Loader subproject with JuiceAgent-API integration - Configure shadowJar output to out/tmp/Loader.jar - Add Loader:shadowJar dependency to buildInjection - Add config.toml with JuiceAgent JarLoader module config
This commit is contained in:
1 parent
e854031e83
commit
00f3972d1d
6 files changed
+86
-1
No files matched your search
Generated
+1
@@ -10,6 +10,7 @@
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/Injector" />
|
||||
<option value="$PROJECT_DIR$/Loader" />
|
||||
<option value="$PROJECT_DIR$/Minecraft-1.8.8" />
|
||||
<option value="$PROJECT_DIR$/OrangeX" />
|
||||
</set>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "com.gradleup.shadow" version "8.3.9"
|
||||
}
|
||||
|
||||
group = 'cn.xiaozhou233.orangex.loader'
|
||||
version = 'unspecified'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly files("../libraries/JuiceAgent-API-1.4.1+build.1.jar")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = 'Loader.jar'
|
||||
destinationDirectory = rootProject.layout.projectDirectory.dir('out/tmp')
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.xiaozhou233.orangex.loader;
|
||||
|
||||
|
||||
import cn.xiaozhou233.juiceagent.api.JuiceAgent;
|
||||
|
||||
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());
|
||||
JuiceAgent.addToClassLoader(injectionFile.getAbsolutePath(), minecraftClassLoader);
|
||||
|
||||
// Start OrangeX
|
||||
try {
|
||||
Class<?> orangeXClass = Class.forName("cn.xiaozhou233.orangex.OrangeX", true, minecraftClassLoader);
|
||||
Object orangeXInstance = orangeXClass.getMethod("getInstance").invoke(null);
|
||||
orangeXClass.getMethod("start").invoke(orangeXInstance);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
System.out.println("======== Loader END ========");
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -18,7 +18,8 @@ tasks.register("buildInjection", Copy) {
|
||||
dependsOn(
|
||||
tasks.named("cleanTmp"),
|
||||
project(':OrangeX').tasks.named('shadowJar'),
|
||||
project(':Injector').tasks.named('shadowJar')
|
||||
project(':Injector').tasks.named('shadowJar'),
|
||||
project(':Loader').tasks.named('shadowJar')
|
||||
)
|
||||
|
||||
from(rootProject.layout.projectDirectory.dir('natives'))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[JuiceAgent]
|
||||
Version = 1
|
||||
|
||||
[JuiceAgent.Loader]
|
||||
JuiceAgentNativeLibraryPath = ""
|
||||
|
||||
[JuiceAgent.Modules]
|
||||
|
||||
[JuiceAgent.Modules.JarLoader]
|
||||
Enabled = true
|
||||
InjectionDir = "./injection"
|
||||
JarPath = "./Loader.jar"
|
||||
EntryClass = "cn.xiaozhou233.orangex.loader.Loader"
|
||||
EntryMethod = "start"
|
||||
@@ -2,4 +2,5 @@ rootProject.name = 'OrangeX-Client'
|
||||
include 'Minecraft-1.8.8'
|
||||
include 'OrangeX'
|
||||
include 'Injector'
|
||||
include 'Loader'
|
||||
|
||||
Reference in new issue
Block a user