mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Init Commit
This commit is contained in:
commit
d492ba7224
39 files changed
+27426
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
Generated
+21
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/Injector" />
|
||||
<option value="$PROJECT_DIR$/Loader" />
|
||||
<option value="$PROJECT_DIR$/Minecraft" />
|
||||
<option value="$PROJECT_DIR$/OrangeX" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+12
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<writeAnnotations>
|
||||
<writeAnnotation name="lombok.Getter" />
|
||||
</writeAnnotations>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Start Minecraft Client" type="Application" factoryName="Application">
|
||||
<option name="ALTERNATIVE_JRE_PATH" value="zulu-17" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||
<option name="MAIN_CLASS_NAME" value="Start" />
|
||||
<module name="OrangeX-Client.Minecraft.main" />
|
||||
<option name="VM_PARAMETERS" value="-Djava.library.path=versions\1.8.8\1.8.8-natives" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Minecraft/runtime" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
@@ -0,0 +1,15 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "com.gradleup.shadow" version "8.3.9"
|
||||
}
|
||||
|
||||
group = 'cn.xiaozhou233.orangex.injector'
|
||||
version = 'unspecified'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.xiaozhou233.juiceagent.injector;
|
||||
|
||||
public class InjectorNative {
|
||||
/*
|
||||
* @param pid target process id
|
||||
*/
|
||||
public native boolean inject(int pid, String path);
|
||||
|
||||
/*
|
||||
* @param pid target process id
|
||||
* @param path injection dll path
|
||||
* @param configPath config file path
|
||||
*/
|
||||
public native boolean inject(int pid, String path, String configPath);
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
public static native WindowInfo[] findWindowsByTitle(String keyword);
|
||||
|
||||
|
||||
public static class WindowInfo {
|
||||
public String title;
|
||||
public int pid;
|
||||
|
||||
public WindowInfo(String title, int pid) {
|
||||
this.title = title;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("标题: %-30s | PID: %d", title, pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.xiaozhou233.orangex.injector;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
public static void unzip(InputStream zipInputStream, File destDir) throws IOException {
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdirs(); // 创建目标目录
|
||||
}
|
||||
|
||||
try (ZipInputStream zipIn = new ZipInputStream(zipInputStream)) {
|
||||
ZipEntry entry;
|
||||
while ((entry = zipIn.getNextEntry()) != null) {
|
||||
File outFile = new File(destDir, entry.getName());
|
||||
if (entry.isDirectory()) {
|
||||
outFile.mkdirs(); // 创建目录
|
||||
} else {
|
||||
File parent = outFile.getParentFile();
|
||||
if (!parent.exists()) {
|
||||
parent.mkdirs(); // 创建父目录
|
||||
}
|
||||
|
||||
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile))) {
|
||||
byte[] buffer = new byte[4096];
|
||||
int read;
|
||||
while ((read = zipIn.read(buffer)) != -1) {
|
||||
bos.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
}
|
||||
zipIn.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package cn.xiaozhou233.orangex.injector;
|
||||
|
||||
import cn.xiaozhou233.juiceagent.injector.InjectorNative;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Injector {
|
||||
public static String orangexPath = System.getProperty("user.home") + "/.orangex";
|
||||
public static void main(String[] args) {
|
||||
System.out.println("OrangeX Injector");
|
||||
|
||||
int pid = -1;
|
||||
|
||||
// Unzip injection.zip to ~/.orangex
|
||||
System.out.println("Unzip injection.zip to " + orangexPath);
|
||||
try (InputStream zipStream = ClassLoader.getSystemResourceAsStream("injection.zip")) {
|
||||
if (zipStream == null) {
|
||||
System.err.println("ZIP resource not found!");
|
||||
return;
|
||||
}
|
||||
FileUtils.unzip(zipStream, new File(orangexPath));
|
||||
System.out.println("Done!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Load Native Library
|
||||
System.load(orangexPath + "/libinject.dll");
|
||||
InjectorNative injectorNative = new InjectorNative();
|
||||
|
||||
// Find Minecraft
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
try {
|
||||
String[] titles = {"Minecraft", "minecraft", "1.8.9", "Badlion", "Lunar"};
|
||||
String[] ignoreTitles = {"Badlion Client", "Badlion Chat", "Home - Lunar Client"};
|
||||
ArrayList<Integer> pids = new ArrayList<>();
|
||||
for (String title : titles) {
|
||||
InjectorNative.WindowInfo[] list = InjectorNative.findWindowsByTitle(title);
|
||||
if (list == null || list.length == 0) {
|
||||
} else {
|
||||
for (InjectorNative.WindowInfo w : list) {
|
||||
if (pids.contains(w.pid))
|
||||
continue;
|
||||
if (Arrays.stream(ignoreTitles).anyMatch(w.title::contains))
|
||||
continue;
|
||||
pids.add(w.pid);
|
||||
stringBuilder.append(String.format("[ %s ] %s%n", w.pid, w.title));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (UnsatisfiedLinkError ule) {
|
||||
throw new RuntimeException("Native method findWindowsByTitle not available", ule);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("[ERROR] Error while calling native findWindowsByTitle: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// Print the result
|
||||
System.out.println("=======================");
|
||||
System.out.println(stringBuilder);
|
||||
System.out.println("=======================");
|
||||
|
||||
// Input the process ID
|
||||
try (Scanner scanner = new Scanner(System.in)) {
|
||||
System.out.print("[INPUT] PID: ");
|
||||
pid = scanner.nextInt();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid PID input", e);
|
||||
}
|
||||
|
||||
// Inject!
|
||||
String agentPath = orangexPath + "/libagent.dll";
|
||||
String configDir = orangexPath;
|
||||
injectorNative.inject(pid, agentPath, configDir);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 xiaozhou233
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the “Software”), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -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 ========");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "com.gradleup.shadow" version "8.3.9"
|
||||
}
|
||||
|
||||
group = 'cn.xiaozhou.orangex'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly(files("../libraries/minecraft-1.8.9.jar"))
|
||||
compileOnly(files("../libraries/1.8.9-OptiFine.jar"))
|
||||
compileOnly(files("../libraries/lwjgl-2.9.4-nightly-20150209.jar"))
|
||||
// https://mvnrepository.com/artifact/org.projectlombok/lombok
|
||||
compileOnly("org.projectlombok:lombok:1.18.42")
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.42"
|
||||
|
||||
implementation(files("../libraries/ymixin.jar"))
|
||||
// https://mvnrepository.com/artifact/org.ow2.asm/asm-tree
|
||||
implementation("org.ow2.asm:asm-tree:9.8")
|
||||
// https://mvnrepository.com/artifact/org.ow2.asm/asm-tree
|
||||
implementation("org.ow2.asm:asm:9.8")
|
||||
// Source: https://mvnrepository.com/artifact/org.greenrobot/eventbus
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
}
|
||||
|
||||
|
||||
shadowJar {
|
||||
relocate 'org.objectweb.asm', 'cn.xiaozhou233.asm9'
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.xiaozhou233.orangex;
|
||||
|
||||
import cn.xiaozhou233.orangex.mixin.MixinManager;
|
||||
import cn.xiaozhou233.orangex.module.ModuleManager;
|
||||
import lombok.Getter;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
public class OrangeX {
|
||||
@Getter
|
||||
public static final EventBus eventBus = EventBus.builder()
|
||||
.logNoSubscriberMessages(false)
|
||||
.logSubscriberExceptions(false)
|
||||
.sendNoSubscriberEvent(false)
|
||||
.sendSubscriberExceptionEvent(false)
|
||||
.installDefaultEventBus();
|
||||
|
||||
public static void start() {
|
||||
System.out.println("OrangeX loading...");
|
||||
|
||||
MixinManager.start();
|
||||
|
||||
ModuleManager.registerAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.xiaozhou233.orangex.event;
|
||||
|
||||
public class Event {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.Event;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class EventRender2D extends Event {
|
||||
private float partialTicks;
|
||||
|
||||
public EventRender2D(float partialTicks) {
|
||||
this.partialTicks = partialTicks;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package cn.xiaozhou233.orangex.mixin;
|
||||
|
||||
import cn.xiaozhou233.orangex.mixin.impl.MixinGuiIngame;
|
||||
import cn.xiaozhou233.orangex.utils.JuiceLoaderFacade;
|
||||
import cn.yapeteam.ymixin.Transformer;
|
||||
import cn.yapeteam.ymixin.YMixin;
|
||||
|
||||
public final class MixinManager {
|
||||
|
||||
private MixinManager() {}
|
||||
|
||||
public static void start() {
|
||||
|
||||
ClassLoader cl = MixinManager.class.getClassLoader();
|
||||
|
||||
YMixin.init(
|
||||
className -> {
|
||||
try {
|
||||
return Class.forName(
|
||||
className.replace("/", "."),
|
||||
false,
|
||||
cl
|
||||
);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
},
|
||||
clazz -> {
|
||||
byte[] classBytes = JuiceLoaderFacade.getClassBytes(clazz);
|
||||
if (classBytes == null) {
|
||||
throw new RuntimeException(
|
||||
"ClassBytes null: " + clazz.getName()
|
||||
);
|
||||
}
|
||||
return classBytes;
|
||||
},
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
Transformer transformer = new Transformer();
|
||||
try {
|
||||
transformer.addMixin(MixinGuiIngame.class);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException("Failed to add mixin", e);
|
||||
}
|
||||
|
||||
transformer.transform().forEach((name, bytes) -> {
|
||||
try {
|
||||
Class<?> targetClass = Class.forName(name, false, cl);
|
||||
boolean ok = JuiceLoaderFacade.redefineClass(targetClass, bytes);
|
||||
if (!ok) {
|
||||
throw new RuntimeException("Redefine failed: " + name);
|
||||
}
|
||||
System.out.println("[OrangeX] Redefined class: " + name);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(
|
||||
"Failed to redefine class: " + name,
|
||||
e
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.xiaozhou233.orangex.mixin.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventRender2D;
|
||||
import cn.yapeteam.ymixin.annotations.Inject;
|
||||
import cn.yapeteam.ymixin.annotations.Local;
|
||||
import cn.yapeteam.ymixin.annotations.Mixin;
|
||||
import cn.yapeteam.ymixin.annotations.Target;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@Mixin(GuiIngame.class)
|
||||
public class MixinGuiIngame {
|
||||
|
||||
@Inject(method = "renderGameOverlay", desc = "(F)V", target = @Target("HEAD"))
|
||||
public void onRenderGameOverlay(@Local(source = "partialTicks", index = 1) float partialTicks) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(
|
||||
GL11.GL_SRC_ALPHA,
|
||||
GL11.GL_ONE_MINUS_SRC_ALPHA,
|
||||
GL11.GL_ONE,
|
||||
GL11.GL_ZERO
|
||||
);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.entityRenderer.setupOverlayRendering();
|
||||
|
||||
OrangeX.getEventBus().post(new EventRender2D(partialTicks));
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.xiaozhou233.orangex.module;
|
||||
|
||||
public class Module {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.xiaozhou233.orangex.module;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.module.impl.render.HUD;
|
||||
|
||||
public class ModuleManager {
|
||||
public static void registerAll() {
|
||||
OrangeX.getEventBus().register(new HUD());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.render;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventRender2D;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class HUD extends Module {
|
||||
|
||||
private Minecraft mc;
|
||||
private FontRenderer fr;
|
||||
|
||||
private final ArrayList<String> modules = new ArrayList<>();
|
||||
|
||||
private float rainbowTick = 0f;
|
||||
|
||||
public HUD() {
|
||||
modules.add("Juice uwu");
|
||||
modules.add("ExampleA");
|
||||
modules.add("ExampleB");
|
||||
modules.add("ExampleC");
|
||||
modules.add("114514");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onRender2D(EventRender2D event) {
|
||||
|
||||
// Lazy init, safe in MC thread
|
||||
if (mc == null) {
|
||||
mc = Minecraft.getMinecraft();
|
||||
if (mc == null || mc.fontRendererObj == null) return;
|
||||
fr = mc.fontRendererObj;
|
||||
}
|
||||
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
float partialTicks = event.getPartialTicks();
|
||||
|
||||
rainbowTick += partialTicks;
|
||||
|
||||
renderLogo();
|
||||
renderModuleList(sr, rainbowTick);
|
||||
}
|
||||
|
||||
private void renderLogo() {
|
||||
fr.drawStringWithShadow(
|
||||
"OrangeX Client",
|
||||
10,
|
||||
10,
|
||||
0xFFA500
|
||||
);
|
||||
}
|
||||
|
||||
private void renderModuleList(ScaledResolution sr, float baseTick) {
|
||||
int margin = 6;
|
||||
int y = margin;
|
||||
int index = 0;
|
||||
|
||||
modules.sort(
|
||||
Comparator.comparingInt(fr::getStringWidth).reversed()
|
||||
);
|
||||
|
||||
for (String module : modules) {
|
||||
int textWidth = fr.getStringWidth(module);
|
||||
int x = sr.getScaledWidth() - textWidth - margin;
|
||||
|
||||
int color = getRainbowColor(baseTick + index * 6f);
|
||||
|
||||
drawHudString(module, x, y, color);
|
||||
|
||||
y += fr.FONT_HEIGHT + 4;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
private void drawHudString(String text, int x, int y, int color) {
|
||||
int padding = 2;
|
||||
|
||||
Gui.drawRect(
|
||||
x - padding,
|
||||
y - padding,
|
||||
x + fr.getStringWidth(text) + padding,
|
||||
y + fr.FONT_HEIGHT + padding,
|
||||
0x70000000
|
||||
);
|
||||
|
||||
fr.drawStringWithShadow(text, x, y, color);
|
||||
}
|
||||
|
||||
private int getRainbowColor(float tick) {
|
||||
float cycle = 60f;
|
||||
float hue = (tick % cycle) / cycle;
|
||||
return Color.HSBtoRGB(hue, 0.9f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class JuiceLoaderFacade {
|
||||
|
||||
private static final Class<?> JL;
|
||||
private static final Method INIT;
|
||||
private static final Method GET_CLASS_BYTES;
|
||||
private static final Method REDEFINE_CLASS;
|
||||
private static final Method GET_LOADED_CLASSES;
|
||||
|
||||
static {
|
||||
try {
|
||||
JL = Class.forName(
|
||||
"cn.xiaozhou233.juiceloader.JuiceLoader",
|
||||
true,
|
||||
ClassLoader.getSystemClassLoader()
|
||||
);
|
||||
|
||||
INIT = JL.getMethod("init");
|
||||
GET_CLASS_BYTES = JL.getMethod("getClassBytes", Class.class);
|
||||
REDEFINE_CLASS = JL.getMethod(
|
||||
"redefineClass",
|
||||
Class.class,
|
||||
byte[].class,
|
||||
int.class
|
||||
);
|
||||
GET_LOADED_CLASSES = JL.getMethod("getLoadedClasses");
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to init JuiceFacade", e);
|
||||
}
|
||||
}
|
||||
|
||||
private JuiceLoaderFacade() {}
|
||||
|
||||
public static byte[] getClassBytes(Class<?> clazz) {
|
||||
try {
|
||||
return (byte[]) GET_CLASS_BYTES.invoke(null, clazz);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean redefineClass(Class<?> clazz, byte[] bytes) {
|
||||
try {
|
||||
return (boolean) REDEFINE_CLASS.invoke(null, clazz, bytes, bytes.length);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?>[] getLoadedClasses() {
|
||||
try {
|
||||
return (Class<?>[]) GET_LOADED_CLASSES.invoke(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,64 @@
|
||||
tasks.register("buildInjection", Copy) {
|
||||
group = 'build'
|
||||
description = 'Build and collect all jars + resources into out/tmp'
|
||||
|
||||
dependsOn(
|
||||
project(':OrangeX').tasks.named('build'),
|
||||
project(':Loader').tasks.named('build')
|
||||
)
|
||||
|
||||
into(layout.projectDirectory.dir('out/tmp'))
|
||||
|
||||
from(project(':OrangeX').tasks.named('shadowJar').map { it.archiveFile }) {
|
||||
rename { 'OrangeX.jar' }
|
||||
}
|
||||
from(project(':Loader').tasks.named('shadowJar').map { it.archiveFile }) {
|
||||
rename { 'Entry.jar' }
|
||||
}
|
||||
|
||||
from(layout.projectDirectory.dir('natives'))
|
||||
from(layout.projectDirectory.dir('resources'))
|
||||
from(layout.projectDirectory.file('libraries/JuiceLoader.jar'))
|
||||
}
|
||||
|
||||
tasks.register("packInjection", Zip) {
|
||||
group = 'build'
|
||||
description = 'Package all collected files into injection.zip'
|
||||
|
||||
dependsOn(tasks.named("buildInjection"))
|
||||
|
||||
destinationDirectory.set(layout.projectDirectory.dir("out"))
|
||||
archiveFileName.set("injection.zip")
|
||||
|
||||
from(layout.projectDirectory.dir("out/tmp"))
|
||||
}
|
||||
|
||||
tasks.register("buildInjector", Jar) {
|
||||
group = 'build'
|
||||
description = 'Build Injector.jar including injection.zip'
|
||||
|
||||
dependsOn(tasks.named("packInjection"))
|
||||
dependsOn(project(':Injector').tasks.named('shadowJar'))
|
||||
|
||||
destinationDirectory.set(layout.projectDirectory.dir("out"))
|
||||
archiveFileName.set("Injector.jar")
|
||||
|
||||
from(zipTree(project(':Injector').tasks.named('shadowJar').map { it.archiveFile })) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
from(layout.projectDirectory.file("out/injection.zip")) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'cn.xiaozhou233.orangex.injector.Injector'
|
||||
)
|
||||
}
|
||||
|
||||
doLast {
|
||||
delete('out/injection.zip')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
#Sun Jan 11 15:33:57 CST 2026
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,234 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
JuiceLoaderJarPath = ""
|
||||
JuiceLoaderLibraryPath = ""
|
||||
InjectionDir = ""
|
||||
|
||||
EntryJarPath = ""
|
||||
EntryClass = "cn.xiaozhou233.orangex.loader.Loader"
|
||||
EntryMethod = "start"
|
||||
@@ -0,0 +1,6 @@
|
||||
rootProject.name = 'OrangeX-Client'
|
||||
include 'Minecraft'
|
||||
include 'OrangeX'
|
||||
include 'Loader'
|
||||
include 'Injector'
|
||||
|
||||
Reference in new issue
Block a user