Feat: Add OrangeX module with MCPLoader injection

This commit is contained in:
xiaozhou233 committed 2026-08-17 23:17:38 +08:00
1 parent 818ce5910a
commit 80307f6edc
15 files changed
+149 -2

No files matched your search

+1
View File
@@ -10,6 +10,7 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/Minecraft-1.8.8" />
<option value="$PROJECT_DIR$/OrangeX" />
</set>
</option>
<option name="resolveExternalAnnotations" value="true" />
+24
View File
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OrangeX-Client [buildAll]" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="buildAll" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
+1
View File
@@ -8,6 +8,7 @@
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Minecraft-1.8.8-runtime" />
<method v="2">
<option name="Make" enabled="true" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="OrangeX-Client [buildAll]" run_configuration_type="GradleRunConfiguration" />
</method>
</configuration>
</component>
Generated
-2
View File
@@ -2,7 +2,5 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/JuiceAgent" vcs="Git" />
<mapping directory="$PROJECT_DIR$/JuiceLoader" vcs="Git" />
</component>
</project>
+4
View File
@@ -15,6 +15,10 @@ dependencies {
implementation fileTree(dir: "../Minecraft-1.8.8-runtime/libraries", include: ["**/*.jar"])
implementation files("../Minecraft-1.8.8-runtime/versions/1.8.8/1.8.8.jar")
implementation files("../libraries/JuiceAgent-API-1.4.1+build.1.jar")
implementation project(":OrangeX")
}
test {
@@ -0,0 +1,51 @@
package cn.xiaozhou233.orangex.loader;
import cn.xiaozhou233.juiceagent.api.JuiceAgent;
import java.io.File;
public enum MCPLoader {
INSTANCE;
public static String userDir = System.getProperty("user.home");
public static Thread clientThread;
public static ClassLoader minecraftClassLoader;
public void start() {
System.out.println("======== OrangeX MCP Loader ========");
System.load(new File("../natives/libagent.dll").getAbsolutePath());
JuiceAgent.init("");
// 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("../../out/tmp/OrangeX.jar");
System.out.println("OrangeX Injection: " + injectionFile.getAbsolutePath());
JuiceAgent.addToClassLoader(injectionFile.getAbsolutePath(), minecraftClassLoader);
try {
Class<?> orangeXClass = Class.forName("cn.xiaozhou233.orangex.OrangeX", true, minecraftClassLoader);
Object instance = orangeXClass.getMethod("getInstance").invoke(null);
orangeXClass.getMethod("start").invoke(instance);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void stop() {
System.out.println("OrangeX MCP Loader Stopping...");
}
}
@@ -1,5 +1,6 @@
package net.minecraft.client;
import cn.xiaozhou233.orangex.loader.MCPLoader;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -589,6 +590,10 @@ public class Minecraft implements IThreadListener, IPlayerUsage
}
this.renderGlobal.makeEntityOutlineShader();
// OrangeX MCP Loader Inject Point //
MCPLoader.INSTANCE.start();
// OrangeX MCP Loader Inject Point //
}
private void registerMetadataSerializers()
@@ -1031,6 +1036,10 @@ public class Minecraft implements IThreadListener, IPlayerUsage
this.stream.shutdownStream();
logger.info("Stopping!");
// OrangeX MCP Loader Inject Point //
MCPLoader.INSTANCE.stop();
// OrangeX MCP Loader Inject Point //
try
{
this.loadWorld((WorldClient)null);
+21
View File
@@ -0,0 +1,21 @@
plugins {
id 'java'
id "com.gradleup.shadow" version "8.3.9"
}
group = 'cn.xiaozhou233.orangex'
version = 'unspecified'
repositories {
mavenCentral()
}
dependencies {
compileOnly("org.projectlombok:lombok:1.18.46")
annotationProcessor("org.projectlombok:lombok:1.18.46")
}
shadowJar {
archiveFileName = 'OrangeX.jar'
destinationDirectory = rootProject.layout.projectDirectory.dir('out/temp')
}
@@ -0,0 +1,17 @@
package cn.xiaozhou233.orangex;
public class OrangeX {
public static final OrangeX INSTANCE = new OrangeX();
public void start() {
System.out.println("OrangeX started.");
}
public void stop() {
System.out.println("OrangeX stopped.");
}
public static OrangeX getInstance() {
return INSTANCE;
}
}
+20
View File
@@ -1,3 +1,23 @@
plugins {
id 'lifecycle-base'
}
tasks.register("buildInjection", Copy) {
outputs.upToDateWhen { false }
dependsOn(
project(':OrangeX').tasks.named('shadowJar')
)
}
tasks.register("buildAll") {
dependsOn(tasks.named("buildInjection"))
doFirst {
println("Building OrangeX-Client...")
}
doLast {
println("Build finished!")
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -1,3 +1,4 @@
rootProject.name = 'OrangeX-Client'
include 'Minecraft-1.8.8'
include 'OrangeX'