mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 21:15:53 +08:00
clean
This commit is contained in:
1 parent
4e0d7cb3ab
commit
c1d355b1a2
96 files changed
+1
-30636
No files matched your search
@@ -1,6 +0,0 @@
|
||||
[submodule "JuiceAgent"]
|
||||
path = JuiceAgent
|
||||
url = https://github.com/xiaozhou233/JuiceAgent.git
|
||||
[submodule "JuiceLoader"]
|
||||
path = JuiceLoader
|
||||
url = https://github.com/xiaozhou233/JuiceLoader.git
|
||||
Generated
+1
-1
@@ -10,7 +10,7 @@
|
||||
</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">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,15 +0,0 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "com.gradleup.shadow" version "8.3.9"
|
||||
}
|
||||
|
||||
group = 'cn.xiaozhou233.orangex.injector'
|
||||
version = 'unspecified'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.injector;
|
||||
|
||||
import cn.xiaozhou233.juiceagent.injector.InjectorNative;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
System.out.println("Unzip injection.zip to " + orangexPath);
|
||||
|
||||
File zipFile = new File("injection.zip");
|
||||
|
||||
if (!zipFile.exists()) {
|
||||
System.err.println("injection.zip not found in runtime directory!");
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream zipStream = new FileInputStream(zipFile)) {
|
||||
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
|
||||
ArrayList<Integer> pids = new ArrayList<>();
|
||||
ArrayList<String> windowTitles = new ArrayList<>();
|
||||
try {
|
||||
String[] titles = {"Minecraft", "minecraft", "1.8.9", "Badlion", "Lunar"};
|
||||
String[] ignoreTitles = {"Badlion Client", "Badlion Chat", "Home - Lunar Client"};
|
||||
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);
|
||||
windowTitles.add(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("=======================");
|
||||
for (int i = 0; i < pids.size(); i++) {
|
||||
System.out.printf("[ %d ] %s (PID: %d)%n", i + 1, windowTitles.get(i), pids.get(i));
|
||||
}
|
||||
System.out.println("=======================");
|
||||
|
||||
if (pids.isEmpty()) {
|
||||
System.out.println("[ERROR] No Minecraft process found!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Input the sequence number
|
||||
try (Scanner scanner = new Scanner(System.in)) {
|
||||
System.out.printf("[INPUT] Select (1-%d): ", pids.size());
|
||||
int index = scanner.nextInt();
|
||||
if (index < 1 || index > pids.size()) {
|
||||
throw new RuntimeException("Invalid selection: " + index);
|
||||
}
|
||||
pid = pids.get(index - 1);
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Invalid input", e);
|
||||
}
|
||||
|
||||
// Inject
|
||||
String agentPath = orangexPath + "/libloader.dll";
|
||||
String configDir = orangexPath;
|
||||
injectorNative.inject(pid, agentPath, configDir);
|
||||
}
|
||||
|
||||
}
|
||||
-1
Submodule JuiceAgent deleted from 94d881fe63.
-1
Submodule JuiceLoader deleted from fc564b1fb7.
@@ -1,15 +0,0 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "com.gradleup.shadow" version "8.3.9"
|
||||
}
|
||||
|
||||
group = 'cn.xiaozhou.orangex.loader'
|
||||
version = 'unspecified'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(files("../libraries/JuiceAgent-API-1.4.0+build.1.jar"))
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
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 ========");
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
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'
|
||||
// Source: https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||
implementation 'com.google.code.gson:gson:2.13.2'
|
||||
|
||||
// for Alt
|
||||
// Source: https://mvnrepository.com/artifact/net.raphimc/MinecraftAuth
|
||||
implementation 'net.raphimc:MinecraftAuth:5.0.0'
|
||||
// Source: https://mvnrepository.com/artifact/net.lenni0451.commons/gson
|
||||
implementation 'net.lenni0451.commons:gson:1.9.2'
|
||||
// Source: https://mvnrepository.com/artifact/net.lenni0451.commons/httpclient
|
||||
implementation 'net.lenni0451.commons:httpclient:1.9.2'
|
||||
|
||||
}
|
||||
|
||||
|
||||
shadowJar {
|
||||
relocate 'org.objectweb.asm', 'cn.xiaozhou233.asm9'
|
||||
relocate 'com.google.gson', "cn.xiaozhou233.gson"
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package cn.xiaozhou233.orangex;
|
||||
|
||||
import cn.xiaozhou233.orangex.alts.AltManager;
|
||||
import cn.xiaozhou233.orangex.config.ConfigManager;
|
||||
import cn.xiaozhou233.orangex.font.FontManager;
|
||||
import cn.xiaozhou233.orangex.manager.ResourceManager;
|
||||
import cn.xiaozhou233.orangex.manager.ThreadManager;
|
||||
import cn.xiaozhou233.orangex.mixin.MixinManager;
|
||||
import cn.xiaozhou233.orangex.module.ModuleManager;
|
||||
import lombok.Getter;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Getter
|
||||
public class OrangeX {
|
||||
@Getter
|
||||
private static OrangeX instance = new OrangeX();
|
||||
|
||||
private final EventBus eventBus = EventBus.builder()
|
||||
.logNoSubscriberMessages(false)
|
||||
.logSubscriberExceptions(false)
|
||||
.sendNoSubscriberEvent(false)
|
||||
.sendSubscriberExceptionEvent(false)
|
||||
.build();
|
||||
private final ResourceManager resourceManager = new ResourceManager();
|
||||
private final ConfigManager configManager = new ConfigManager();
|
||||
private final MixinManager mixinManager = new MixinManager();
|
||||
private final ModuleManager moduleManager = new ModuleManager();
|
||||
private FontManager fontManager;
|
||||
private final AltManager altManager = new AltManager();
|
||||
private final ThreadManager threadManager = new ThreadManager();
|
||||
|
||||
public OrangeX() {
|
||||
}
|
||||
|
||||
// Invoke by Loader/MCPEntry
|
||||
// See Loader -> cn.xiaozhou233.orangex.loader.Loader
|
||||
// See Minecraft -> cn.xiaozhou233.MCPEntry
|
||||
public void start() {
|
||||
moduleManager.init();
|
||||
configManager.loadConfig();
|
||||
altManager.init();
|
||||
threadManager.init();
|
||||
mixinManager.start();
|
||||
}
|
||||
|
||||
// Invoke by Minecraft
|
||||
// See Mixin cn.xiaozhou233.orangex.mixin.impl.MixinMinecraft.onShutdown()
|
||||
public void stop() {
|
||||
System.out.println("OrangeX stopping...");
|
||||
}
|
||||
|
||||
public FontManager getFontManager() {
|
||||
if (fontManager == null) {
|
||||
fontManager = new FontManager();
|
||||
}
|
||||
return fontManager;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.alts;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter @Setter
|
||||
public class Alt {
|
||||
private String name;
|
||||
private UUID uuid;
|
||||
private String accessToken;
|
||||
private long expireTimeMs;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.alts;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.utils.BrowserUtil;
|
||||
import cn.xiaozhou233.orangex.utils.ClipboardUtil;
|
||||
import net.lenni0451.commons.httpclient.HttpClient;
|
||||
import net.raphimc.minecraftauth.MinecraftAuth;
|
||||
import net.raphimc.minecraftauth.java.JavaAuthManager;
|
||||
import net.raphimc.minecraftauth.msa.model.MsaDeviceCode;
|
||||
import net.raphimc.minecraftauth.msa.service.impl.DeviceCodeMsaAuthService;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class AltLoginThread extends Thread {
|
||||
|
||||
private String status = "NONE";
|
||||
private final Consumer<String> statusConsumer;
|
||||
|
||||
public AltLoginThread(Consumer<String> statusConsumer) {
|
||||
super("Alt Login Thread");
|
||||
this.statusConsumer = statusConsumer;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
private void setStatus(String status) {
|
||||
this.status = status;
|
||||
if (statusConsumer != null) {
|
||||
statusConsumer.accept(status);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
HttpClient httpClient = MinecraftAuth.createHttpClient();
|
||||
setStatus("Created HttpClient");
|
||||
|
||||
JavaAuthManager.Builder authManagerBuilder = JavaAuthManager.create(httpClient);
|
||||
setStatus("Created AuthManagerBuilder");
|
||||
|
||||
JavaAuthManager authManager = authManagerBuilder.login(DeviceCodeMsaAuthService::new, new Consumer<MsaDeviceCode>() {
|
||||
@Override
|
||||
public void accept(MsaDeviceCode deviceCode) {
|
||||
System.out.println("Go to " + deviceCode.getVerificationUri());
|
||||
BrowserUtil.openUrl(deviceCode.getDirectVerificationUri());
|
||||
System.out.println("Enter code " + deviceCode.getUserCode());
|
||||
ClipboardUtil.copyToClipboard(deviceCode.getUserCode());
|
||||
|
||||
setStatus("Waiting Login... code: " + deviceCode.getUserCode());
|
||||
}
|
||||
});
|
||||
|
||||
String username = authManager.getMinecraftProfile().getUpToDate().getName();
|
||||
UUID uuid = authManager.getMinecraftProfile().getUpToDate().getId();
|
||||
String accessToken = authManager.getMinecraftToken().getUpToDate().getToken();
|
||||
long expireTimeMs = authManager.getMinecraftToken().getUpToDate().getExpireTimeMs();
|
||||
|
||||
Alt alt = new Alt(username, uuid, accessToken, expireTimeMs);
|
||||
OrangeX.getInstance().getAltManager().addAlt(alt);
|
||||
setStatus("Login Success!");
|
||||
|
||||
} catch (Exception e) {
|
||||
setStatus("Login Failed: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.alts;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventTick;
|
||||
import cn.xiaozhou233.orangex.ui.altmanager.GUIAltManager;
|
||||
import cn.xiaozhou233.orangex.utils.SessionUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.util.Session;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AltManager {
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
@Getter
|
||||
private List<Alt> alts = new ArrayList<>();
|
||||
private File file;
|
||||
public AltManager() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
// register event
|
||||
OrangeX.getInstance().getEventBus().register(this);
|
||||
file = OrangeX.getInstance().getResourceManager().getAltConfig();
|
||||
load();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTick(EventTick event) {
|
||||
// Return when key is not pressed
|
||||
if (!Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
|
||||
return;
|
||||
|
||||
// Return when not in multiplayer menu
|
||||
if (!(mc.currentScreen instanceof GuiMultiplayer))
|
||||
return;
|
||||
|
||||
// Right SHIFT + Multiplayer Menu -> Display Alt List
|
||||
mc.displayGuiScreen(new GUIAltManager());
|
||||
}
|
||||
|
||||
public void addAlt(Alt alt) {
|
||||
alts.add(alt);
|
||||
save();
|
||||
}
|
||||
|
||||
public void removeAlt(String name) {
|
||||
alts.removeIf(alt -> alt.getName().equals(name));
|
||||
save();
|
||||
}
|
||||
|
||||
public void removeAlt(Alt alt) {
|
||||
alts.remove(alt);
|
||||
save();
|
||||
}
|
||||
|
||||
public Alt get(int index) {
|
||||
return alts.get(index);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return alts.size();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(alts);
|
||||
|
||||
try (FileWriter writer = new FileWriter(file)) {
|
||||
writer.write(json);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<Alt>>() {}.getType();
|
||||
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
List<Alt> loaded = gson.fromJson(reader, listType);
|
||||
if (loaded != null) {
|
||||
alts = loaded;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void login(Alt alt) {
|
||||
Session session = new Session(
|
||||
alt.getName(),
|
||||
alt.getUuid().toString(),
|
||||
alt.getAccessToken(),
|
||||
"mojang"
|
||||
);
|
||||
SessionUtil.setSession(session);
|
||||
System.out.println("Logging in as " + alt.getName());
|
||||
System.out.println("UUID: " + alt.getUuid());
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.config;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.value.BooleanValue;
|
||||
import cn.xiaozhou233.orangex.module.value.KeybindValue;
|
||||
import cn.xiaozhou233.orangex.module.value.ModeValue;
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import cn.xiaozhou233.orangex.module.value.Value;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ConfigManager {
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
private HashMap<String, PanelPosition> panelConfigMap = new HashMap<>();
|
||||
|
||||
private HashMap<String, ModuleConfig> moduleConfigMap = new HashMap<>();
|
||||
|
||||
public void loadConfig() {
|
||||
try {
|
||||
// Load Panel Position
|
||||
File panelConfig = OrangeX.getInstance().getResourceManager().getPanelConfig();
|
||||
if (!panelConfig.exists()) panelConfig.createNewFile();
|
||||
if (panelConfig.length() != 0) {
|
||||
Type type = new TypeToken<HashMap<String, PanelPosition>>() {
|
||||
}.getType();
|
||||
try (FileReader reader = new FileReader(panelConfig)) {
|
||||
HashMap<String, PanelPosition> map = gson.fromJson(reader, type);
|
||||
if (map != null) this.panelConfigMap = map;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to load panel config!");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
// Load Module Config
|
||||
File moduleConfig = OrangeX.getInstance().getResourceManager().getModulesConfig();
|
||||
if (!moduleConfig.exists()) moduleConfig.createNewFile();
|
||||
if (moduleConfig.length() != 0) {
|
||||
Type type = new TypeToken<HashMap<String, ModuleConfig>>() {}.getType();
|
||||
try (FileReader reader = new FileReader(moduleConfig)) {
|
||||
HashMap<String, ModuleConfig> map = gson.fromJson(reader, type);
|
||||
if (map != null) this.moduleConfigMap = map;
|
||||
}
|
||||
}
|
||||
|
||||
applyModuleConfig();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to load module config!");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public PanelPosition getPanelPosition(String panelName) {
|
||||
return this.panelConfigMap.getOrDefault(panelName, null);
|
||||
}
|
||||
|
||||
public void setPanelPosition(String panelName, PanelPosition position) {
|
||||
this.panelConfigMap.put(panelName, position);
|
||||
}
|
||||
|
||||
public void saveConfig() {
|
||||
// Save panel config
|
||||
try(FileWriter writer = new FileWriter(
|
||||
OrangeX.getInstance().getResourceManager().getPanelConfig())) {
|
||||
writer.write(gson.toJson(this.panelConfigMap));
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to save panel config");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// Save module config
|
||||
generateModuleConfig();
|
||||
try (FileWriter writer = new FileWriter(
|
||||
OrangeX.getInstance().getResourceManager().getModulesConfig())) {
|
||||
writer.write(gson.toJson(this.moduleConfigMap));
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to save module config");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateModuleConfig() {
|
||||
moduleConfigMap.clear();
|
||||
|
||||
for (Module module : OrangeX.getInstance().getModuleManager().getAllModules()) {
|
||||
ModuleConfig moduleConfig = new ModuleConfig();
|
||||
moduleConfig.setEnabled(module.isEnabled());
|
||||
moduleConfig.setKeybind(module.getKeyBind().getValue());
|
||||
|
||||
for (Value<?> v : module.getValues()) {
|
||||
moduleConfig.getValues().put(
|
||||
v.getName(),
|
||||
gson.toJsonTree(v.getValue())
|
||||
);
|
||||
}
|
||||
|
||||
moduleConfigMap.put(module.getName(), moduleConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyModuleConfig() {
|
||||
for (Module module : OrangeX.getInstance().getModuleManager().getAllModules()) {
|
||||
ModuleConfig mc = moduleConfigMap.get(module.getName());
|
||||
if (mc == null) continue;
|
||||
|
||||
module.setEnabled(mc.isEnabled());
|
||||
module.getKeyBind().setValue(mc.getKeybind());
|
||||
|
||||
for (Value<?> value : module.getValues()) {
|
||||
JsonElement element = mc.getValues().get(value.getName());
|
||||
if (element == null) continue;
|
||||
|
||||
value.fromJson(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Object convertValue(Object raw, Value<?> targetValue) {
|
||||
if (raw == null) return null;
|
||||
|
||||
if (targetValue instanceof KeybindValue) {
|
||||
if (raw instanceof Number) return ((Number) raw).intValue();
|
||||
if (raw instanceof String) return Integer.parseInt((String) raw);
|
||||
}
|
||||
|
||||
if (targetValue instanceof BooleanValue) {
|
||||
if (raw instanceof Boolean) return raw;
|
||||
if (raw instanceof String) return Boolean.parseBoolean((String) raw);
|
||||
}
|
||||
|
||||
if (targetValue instanceof NumberValue) {
|
||||
if (raw instanceof Number) return ((Number) raw).doubleValue();
|
||||
if (raw instanceof String) return Double.parseDouble((String) raw);
|
||||
}
|
||||
|
||||
if (targetValue instanceof ModeValue) {
|
||||
if (raw instanceof String) {
|
||||
String mode = (String) raw;
|
||||
ModeValue mv = (ModeValue) targetValue;
|
||||
if (mv.isValidMode(mode)) return mode;
|
||||
return mv.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (targetValue.getValue().getClass().isInstance(raw)) {
|
||||
return raw;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.config;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter @Setter
|
||||
public class ModuleConfig {
|
||||
private boolean enabled;
|
||||
private int keybind;
|
||||
private Map<String, JsonElement> values = new HashMap<>();
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter @Setter
|
||||
public class PanelPosition {
|
||||
public double x;
|
||||
public double y;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event;
|
||||
|
||||
public class Cancellable extends Event{
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
this.cancelled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event;
|
||||
|
||||
public class Event {
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class EventKey {
|
||||
private final int key;
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
public class EventLoop {
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.Cancellable;
|
||||
import cn.xiaozhou233.orangex.event.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class EventPacketSend extends Cancellable {
|
||||
private Packet packet;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.Event;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class EventRender3D extends Event {
|
||||
|
||||
private float partialTicks;
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
public class EventTick {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
public class EventTimerThread {
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.event.impl;
|
||||
|
||||
public class EventWorldLoad {
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.font;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
|
||||
|
||||
public class CFont
|
||||
{
|
||||
private float imgSize = 512;
|
||||
protected CharData[] charData = new CharData[256];
|
||||
protected Font font;
|
||||
protected boolean antiAlias;
|
||||
protected boolean fractionalMetrics;
|
||||
protected int fontHeight = -1;
|
||||
protected int charOffset = 0;
|
||||
protected DynamicTexture tex;
|
||||
|
||||
public CFont(Font font, boolean antiAlias, boolean fractionalMetrics)
|
||||
{
|
||||
this.font = font;
|
||||
this.antiAlias = antiAlias;
|
||||
this.fractionalMetrics = fractionalMetrics;
|
||||
tex = setupTexture(font, antiAlias, fractionalMetrics, this.charData);
|
||||
}
|
||||
|
||||
public DynamicTexture setupTexture(Font font, boolean antiAlias, boolean fractionalMetrics, CharData[] chars)
|
||||
{
|
||||
BufferedImage img = generateFontImage(font, antiAlias, fractionalMetrics, chars);
|
||||
|
||||
try
|
||||
{
|
||||
return new DynamicTexture(img);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected BufferedImage generateFontImage(Font font, boolean antiAlias, boolean fractionalMetrics, CharData[] chars)
|
||||
{
|
||||
int imgSize = (int) this.imgSize;
|
||||
BufferedImage bufferedImage = new BufferedImage(imgSize, imgSize, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
|
||||
g.setFont(font);
|
||||
g.setColor(new Color(255, 255, 255, 0));
|
||||
g.fillRect(0, 0, imgSize, imgSize);
|
||||
g.setColor(Color.WHITE);
|
||||
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, fractionalMetrics ? RenderingHints.VALUE_FRACTIONALMETRICS_ON : RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antiAlias ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
FontMetrics fontMetrics = g.getFontMetrics();
|
||||
int charHeight = 0;
|
||||
int positionX = 0;
|
||||
int positionY = 1;
|
||||
|
||||
for (int i = 0; i < chars.length; i++)
|
||||
{
|
||||
char ch = (char) i;
|
||||
CharData charData = new CharData();
|
||||
Rectangle2D dimensions = fontMetrics.getStringBounds(String.valueOf(ch), g);
|
||||
charData.width = (dimensions.getBounds().width + 8);
|
||||
charData.height = dimensions.getBounds().height;
|
||||
|
||||
if (positionX + charData.width >= imgSize)
|
||||
{
|
||||
positionX = 0;
|
||||
positionY += charHeight;
|
||||
charHeight = 0;
|
||||
}
|
||||
|
||||
if (charData.height > charHeight)
|
||||
{
|
||||
charHeight = charData.height;
|
||||
}
|
||||
|
||||
charData.storedX = positionX;
|
||||
charData.storedY = positionY;
|
||||
|
||||
if (charData.height > this.fontHeight)
|
||||
{
|
||||
this.fontHeight = charData.height;
|
||||
}
|
||||
|
||||
chars[i] = charData;
|
||||
g.drawString(String.valueOf(ch), positionX + 2, positionY + fontMetrics.getAscent());
|
||||
positionX += charData.width;
|
||||
}
|
||||
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
public void drawChar(CharData[] chars, char c, float x, float y) throws ArrayIndexOutOfBoundsException
|
||||
{
|
||||
try
|
||||
{
|
||||
drawQuad(x, y, chars[c].width, chars[c].height, chars[c].storedX, chars[c].storedY, chars[c].width, chars[c].height);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawQuad(float x, float y, float width, float height, float srcX, float srcY, float srcWidth, float srcHeight)
|
||||
{
|
||||
float renderSRCX = srcX / imgSize;
|
||||
float renderSRCY = srcY / imgSize;
|
||||
float renderSRCWidth = srcWidth / imgSize;
|
||||
float renderSRCHeight = srcHeight / imgSize;
|
||||
GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY);
|
||||
GL11.glVertex2d(x + width, y);
|
||||
GL11.glTexCoord2f(renderSRCX, renderSRCY);
|
||||
GL11.glVertex2d(x, y);
|
||||
GL11.glTexCoord2f(renderSRCX, renderSRCY + renderSRCHeight);
|
||||
GL11.glVertex2d(x, y + height);
|
||||
GL11.glTexCoord2f(renderSRCX, renderSRCY + renderSRCHeight);
|
||||
GL11.glVertex2d(x, y + height);
|
||||
GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY + renderSRCHeight);
|
||||
GL11.glVertex2d(x + width, y + height);
|
||||
GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY);
|
||||
GL11.glVertex2d(x + width, y);
|
||||
}
|
||||
|
||||
public int getStringHeight(String text)
|
||||
{
|
||||
return getHeight();
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return (this.fontHeight - 8) / 2;
|
||||
}
|
||||
|
||||
public int getStringWidth(String text)
|
||||
{
|
||||
int width = 0;
|
||||
|
||||
for (char c : text.toCharArray())
|
||||
{
|
||||
if ((c < this.charData.length) && (c >= 0))
|
||||
{
|
||||
width += this.charData[c].width - 8 + this.charOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return width / 2;
|
||||
}
|
||||
|
||||
public boolean isAntiAlias()
|
||||
{
|
||||
return this.antiAlias;
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean antiAlias)
|
||||
{
|
||||
if (this.antiAlias != antiAlias)
|
||||
{
|
||||
this.antiAlias = antiAlias;
|
||||
tex = setupTexture(this.font, antiAlias, this.fractionalMetrics, this.charData);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFractionalMetrics()
|
||||
{
|
||||
return this.fractionalMetrics;
|
||||
}
|
||||
|
||||
public void setFractionalMetrics(boolean fractionalMetrics)
|
||||
{
|
||||
if (this.fractionalMetrics != fractionalMetrics)
|
||||
{
|
||||
this.fractionalMetrics = fractionalMetrics;
|
||||
tex = setupTexture(this.font, this.antiAlias, fractionalMetrics, this.charData);
|
||||
}
|
||||
}
|
||||
|
||||
public Font getFont()
|
||||
{
|
||||
return this.font;
|
||||
}
|
||||
|
||||
public void setFont(Font font)
|
||||
{
|
||||
this.font = font;
|
||||
tex = setupTexture(font, this.antiAlias, this.fractionalMetrics, this.charData);
|
||||
}
|
||||
|
||||
protected class CharData
|
||||
{
|
||||
public int width;
|
||||
public int height;
|
||||
public int storedX;
|
||||
public int storedY;
|
||||
|
||||
protected CharData()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.font;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class FontManager {
|
||||
public FontRenderer MontserratLight18 = new FontRenderer("Montserrat-Light.ttf", 18, Font.PLAIN, true, true);
|
||||
|
||||
public FontRenderer MontserratRegular18 = new FontRenderer("Montserrat-Bold.ttf", 18, Font.PLAIN, true, true);
|
||||
public FontRenderer MontserratRegular32 = new FontRenderer("Montserrat-Bold.ttf", 32, Font.PLAIN, true, true);
|
||||
|
||||
public FontRenderer MontserratMedium18 = new FontRenderer("Montserrat-Medium.ttf", 18, Font.PLAIN, true, true);
|
||||
public FontRenderer MontserratMedium32 = new FontRenderer("Montserrat-Medium.ttf", 32, Font.PLAIN, true, true);
|
||||
|
||||
public FontRenderer MontserratBold18 = new FontRenderer("Montserrat-Bold.ttf", 18, Font.PLAIN, true, true);
|
||||
public FontRenderer MontserratBold32 = new FontRenderer("Montserrat-Bold.ttf", 32, Font.PLAIN, true, true);
|
||||
|
||||
public FontRenderer JelloMedium32 = new FontRenderer("JelloMedium.ttf", 32, Font.PLAIN, true, true);
|
||||
public FontRenderer JelloRegular16 = new FontRenderer("JelloRegular.ttf", 16, Font.PLAIN, true, true);
|
||||
}
|
||||
@@ -1,474 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.font;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class FontRenderer extends CFont {
|
||||
protected CFont.CharData[] boldChars = new CFont.CharData[256];
|
||||
protected CFont.CharData[] italicChars = new CFont.CharData[256];
|
||||
protected CFont.CharData[] boldItalicChars = new CFont.CharData[256];
|
||||
|
||||
private final int[] colorCode = new int[32];
|
||||
|
||||
/*
|
||||
CREDIT G0dwhitelight.
|
||||
*/
|
||||
public FontRenderer(Font font, boolean antiAlias, boolean fractionalMetrics) {
|
||||
super(font, antiAlias, fractionalMetrics);
|
||||
setupMinecraftColorcodes();
|
||||
setupBoldItalicIDs();
|
||||
}
|
||||
|
||||
public FontRenderer(String filePath, int size, int fontType, boolean antiAlias, boolean fractionalMetrics) {
|
||||
super(FontUtil.getFontFromTTF(
|
||||
FontRenderer.class.getClassLoader().getResourceAsStream("fonts/" + filePath), size, fontType),
|
||||
antiAlias, fractionalMetrics);
|
||||
setupMinecraftColorcodes();
|
||||
setupBoldItalicIDs();
|
||||
}
|
||||
|
||||
public float drawString(String text, float x, float y, int color) {
|
||||
return drawString(text, x, y, color, false);
|
||||
}
|
||||
|
||||
public float drawString(String text, double x, double y, int color) {
|
||||
return drawString(text, x, y, color, false);
|
||||
}
|
||||
|
||||
public float drawStringWithShadow(String text, float x, float y, int color) {
|
||||
float shadowWidth = drawString(text, x + 1D, y + .5D, color, true);
|
||||
return Math.max(shadowWidth, drawString(text, x, y, color, false));
|
||||
}
|
||||
|
||||
public float drawStringWithShadow(String text, double x, double y, int color) {
|
||||
float shadowWidth = drawString(text, x + 1, y + .5, color, true);
|
||||
return Math.max(shadowWidth, drawString(text, x, y, color, false));
|
||||
}
|
||||
|
||||
public float drawCenteredString(String text, float x, float y, int color) {
|
||||
return drawString(text, x - getStringWidth(text) / 2, y, color);
|
||||
}
|
||||
|
||||
public float drawCenteredString(String text, double x, double y, int color) {
|
||||
return drawString(text, x - getStringWidth(text) / 2, y, color);
|
||||
}
|
||||
|
||||
public float drawCenteredStringWithShadow(String text, float x, float y, int color) {
|
||||
float shadowWidth = drawString(text, x - getStringWidth(text) / 2 + 0.45D, y + 0.5D, color, true);
|
||||
return drawString(text, x - getStringWidth(text) / 2, y, color);
|
||||
}
|
||||
|
||||
public void drawStringWithOutline(String text, double x, double y, int color) {
|
||||
drawString(text, x - .5, y, 0x000000);
|
||||
|
||||
drawString(text, x + .5, y, 0x000000);
|
||||
|
||||
drawString(text, x, y - .5, 0x000000);
|
||||
|
||||
drawString(text, x, y + .5, 0x000000);
|
||||
|
||||
drawString(text, x, y, color);
|
||||
}
|
||||
|
||||
public void drawCenteredStringWithOutline(String text, double x, double y, int color) {
|
||||
drawCenteredString(text, x - .5, y, 0x000000);
|
||||
|
||||
drawCenteredString(text, x + .5, y, 0x000000);
|
||||
|
||||
drawCenteredString(text, x, y - .5, 0x000000);
|
||||
|
||||
drawCenteredString(text, x, y + .5, 0x000000);
|
||||
|
||||
drawCenteredString(text, x, y, color);
|
||||
}
|
||||
|
||||
public float drawCenteredStringWithShadow(String text, double x, double y, int color) {
|
||||
float shadowWidth = drawString(text, x - getStringWidth(text) / 2 + 0.45D, y + 0.5D, color, true);
|
||||
return drawString(text, x - getStringWidth(text) / 2, y, color);
|
||||
}
|
||||
|
||||
public float drawString(String text, double x, double y, int color, boolean shadow) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
x -= 1;
|
||||
|
||||
if (text == null) {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
if (color == 553648127) {
|
||||
color = 16777215;
|
||||
}
|
||||
|
||||
if ((color & 0xFC000000) == 0) {
|
||||
color |= -16777216;
|
||||
}
|
||||
|
||||
if (shadow) {
|
||||
color = (color & 0xFCFCFC) >> 2 | color & new Color(20, 20, 20, 200).getRGB();
|
||||
}
|
||||
|
||||
CFont.CharData[] currentData = this.charData;
|
||||
float alpha = (color >> 24 & 0xFF) / 255.0F;
|
||||
boolean randomCase = false;
|
||||
boolean bold = false;
|
||||
boolean italic = false;
|
||||
boolean strikethrough = false;
|
||||
boolean underline = false;
|
||||
boolean render = true;
|
||||
x *= 2.0D;
|
||||
y = (y - 3.0D) * 2.0D;
|
||||
|
||||
if (render) {
|
||||
GL11.glPushMatrix();
|
||||
GlStateManager.scale(0.5D, 0.5D, 0.5D);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
GlStateManager.color((color >> 16 & 0xFF) / 255.0F, (color >> 8 & 0xFF) / 255.0F, (color & 0xFF) / 255.0F, alpha);
|
||||
int size = text.length();
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.bindTexture(tex.getGlTextureId());
|
||||
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getGlTextureId());
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
char character = text.charAt(i);
|
||||
if ((String.valueOf(character).equals("\247")) && (i < size)) {
|
||||
int colorIndex = 21;
|
||||
|
||||
try {
|
||||
colorIndex = "0123456789abcdefklmnor".indexOf(text.charAt(i + 1));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (colorIndex < 16) {
|
||||
bold = false;
|
||||
italic = false;
|
||||
randomCase = false;
|
||||
underline = false;
|
||||
strikethrough = false;
|
||||
GlStateManager.bindTexture(tex.getGlTextureId());
|
||||
// GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D,
|
||||
// tex.getGlTextureId());
|
||||
currentData = this.charData;
|
||||
|
||||
if ((colorIndex < 0) || (colorIndex > 15)) {
|
||||
colorIndex = 15;
|
||||
}
|
||||
|
||||
if (shadow) {
|
||||
colorIndex += 16;
|
||||
}
|
||||
|
||||
int colorcode = this.colorCode[colorIndex];
|
||||
GlStateManager.color((colorcode >> 16 & 0xFF) / 255.0F, (colorcode >> 8 & 0xFF) / 255.0F, (colorcode & 0xFF) / 255.0F, alpha);
|
||||
} else if (colorIndex == 16) {
|
||||
randomCase = true;
|
||||
} else if (colorIndex == 17) {
|
||||
bold = true;
|
||||
|
||||
if (italic) {
|
||||
GlStateManager.bindTexture(texItalicBold.getGlTextureId());
|
||||
// GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D,
|
||||
// texItalicBold.getGlTextureId());
|
||||
currentData = this.boldItalicChars;
|
||||
} else {
|
||||
GlStateManager.bindTexture(texBold.getGlTextureId());
|
||||
// GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D,
|
||||
// texBold.getGlTextureId());
|
||||
currentData = this.boldChars;
|
||||
}
|
||||
} else if (colorIndex == 18) {
|
||||
strikethrough = true;
|
||||
} else if (colorIndex == 19) {
|
||||
underline = true;
|
||||
} else if (colorIndex == 20) {
|
||||
italic = true;
|
||||
|
||||
if (bold) {
|
||||
GlStateManager.bindTexture(texItalicBold.getGlTextureId());
|
||||
// GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D,
|
||||
// texItalicBold.getGlTextureId());
|
||||
currentData = this.boldItalicChars;
|
||||
} else {
|
||||
GlStateManager.bindTexture(texItalic.getGlTextureId());
|
||||
// GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D,
|
||||
// texItalic.getGlTextureId());
|
||||
currentData = this.italicChars;
|
||||
}
|
||||
} else if (colorIndex == 21) {
|
||||
bold = false;
|
||||
italic = false;
|
||||
randomCase = false;
|
||||
underline = false;
|
||||
strikethrough = false;
|
||||
GlStateManager.color((color >> 16 & 0xFF) / 255.0F, (color >> 8 & 0xFF) / 255.0F, (color & 0xFF) / 255.0F, alpha);
|
||||
GlStateManager.bindTexture(tex.getGlTextureId());
|
||||
// GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D,
|
||||
// tex.getGlTextureId());
|
||||
currentData = this.charData;
|
||||
}
|
||||
|
||||
i++;
|
||||
} else if ((character < currentData.length) && (character >= 0)) {
|
||||
GL11.glBegin(GL11.GL_TRIANGLES);
|
||||
drawChar(currentData, character, (float) x, (float) y);
|
||||
GL11.glEnd();
|
||||
|
||||
if (strikethrough) {
|
||||
drawLine(x, y + currentData[character].height / 2, x + currentData[character].width - 8.0D, y + currentData[character].height / 2, 1.0F);
|
||||
}
|
||||
|
||||
if (underline) {
|
||||
drawLine(x, y + currentData[character].height - 2.0D, x + currentData[character].width - 8.0D, y + currentData[character].height - 2.0D, 1.0F);
|
||||
}
|
||||
|
||||
x += currentData[character].width - 8 + this.charOffset;
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_DONT_CARE);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
return (float) x / 2.0F;
|
||||
}
|
||||
|
||||
public int getStringWidth(String text) {
|
||||
if (text == null) {
|
||||
return 0;
|
||||
}
|
||||
int width = 0;
|
||||
CFont.CharData[] currentData = this.charData;
|
||||
boolean bold = false;
|
||||
boolean italic = false;
|
||||
int size = text.length();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
char character = text.charAt(i);
|
||||
|
||||
if ((String.valueOf(character).equals("\247")) && (i < size)) {
|
||||
int colorIndex = "0123456789abcdefklmnor".indexOf(character);
|
||||
|
||||
if (colorIndex < 16) {
|
||||
bold = false;
|
||||
italic = false;
|
||||
} else if (colorIndex == 17) {
|
||||
bold = true;
|
||||
|
||||
if (italic) {
|
||||
currentData = this.boldItalicChars;
|
||||
} else {
|
||||
currentData = this.boldChars;
|
||||
}
|
||||
} else if (colorIndex == 20) {
|
||||
italic = true;
|
||||
|
||||
if (bold) {
|
||||
currentData = this.boldItalicChars;
|
||||
} else {
|
||||
currentData = this.italicChars;
|
||||
}
|
||||
} else if (colorIndex == 21) {
|
||||
bold = false;
|
||||
italic = false;
|
||||
currentData = this.charData;
|
||||
}
|
||||
|
||||
i++;
|
||||
} else if ((character < currentData.length) && (character >= 0)) {
|
||||
width += currentData[character].width - 8 + this.charOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return width / 2;
|
||||
}
|
||||
|
||||
public int getStringWidthCust(String text) {
|
||||
if (text == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
CFont.CharData[] currentData = this.charData;
|
||||
boolean bold = false;
|
||||
boolean italic = false;
|
||||
int size = text.length();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
char character = text.charAt(i);
|
||||
|
||||
if ((String.valueOf(character).equals("§")) && (i < size)) {
|
||||
int colorIndex = "0123456789abcdefklmnor".indexOf(character);
|
||||
|
||||
if (colorIndex < 16) {
|
||||
bold = false;
|
||||
italic = false;
|
||||
} else if (colorIndex == 17) {
|
||||
bold = true;
|
||||
|
||||
if (italic) {
|
||||
currentData = this.boldItalicChars;
|
||||
} else {
|
||||
currentData = this.boldChars;
|
||||
}
|
||||
} else if (colorIndex == 20) {
|
||||
italic = true;
|
||||
|
||||
if (bold) {
|
||||
currentData = this.boldItalicChars;
|
||||
} else {
|
||||
currentData = this.italicChars;
|
||||
}
|
||||
} else if (colorIndex == 21) {
|
||||
bold = false;
|
||||
italic = false;
|
||||
currentData = this.charData;
|
||||
}
|
||||
|
||||
i++;
|
||||
} else if ((character < currentData.length) && (character >= 0)) {
|
||||
width += currentData[character].width - 8 + this.charOffset;
|
||||
}
|
||||
}
|
||||
|
||||
return (width - this.charOffset) / 2;
|
||||
}
|
||||
|
||||
public void setFont(Font font) {
|
||||
super.setFont(font);
|
||||
setupBoldItalicIDs();
|
||||
}
|
||||
|
||||
public void setAntiAlias(boolean antiAlias) {
|
||||
super.setAntiAlias(antiAlias);
|
||||
setupBoldItalicIDs();
|
||||
}
|
||||
|
||||
public void setFractionalMetrics(boolean fractionalMetrics) {
|
||||
super.setFractionalMetrics(fractionalMetrics);
|
||||
setupBoldItalicIDs();
|
||||
}
|
||||
|
||||
protected DynamicTexture texBold;
|
||||
protected DynamicTexture texItalic;
|
||||
protected DynamicTexture texItalicBold;
|
||||
|
||||
private void setupBoldItalicIDs() {
|
||||
texBold = setupTexture(this.font.deriveFont(1), this.antiAlias, this.fractionalMetrics, this.boldChars);
|
||||
texItalic = setupTexture(this.font.deriveFont(2), this.antiAlias, this.fractionalMetrics, this.italicChars);
|
||||
texItalicBold = setupTexture(this.font.deriveFont(3), this.antiAlias, this.fractionalMetrics, this.boldItalicChars);
|
||||
}
|
||||
|
||||
private void drawLine(double x, double y, double x1, double y1, float width) {
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glLineWidth(width);
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
GL11.glVertex2d(x, y);
|
||||
GL11.glVertex2d(x1, y1);
|
||||
GL11.glEnd();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public List<String> wrapWords(String text, double width) {
|
||||
List finalWords = new ArrayList();
|
||||
|
||||
if (getStringWidth(text) > width) {
|
||||
String[] words = text.split(" ");
|
||||
String currentWord = "";
|
||||
char lastColorCode = 65535;
|
||||
|
||||
for (String word : words) {
|
||||
for (int i = 0; i < word.toCharArray().length; i++) {
|
||||
char c = word.toCharArray()[i];
|
||||
|
||||
if ((String.valueOf(c).equals("§")) && (i < word.toCharArray().length - 1)) {
|
||||
lastColorCode = word.toCharArray()[(i + 1)];
|
||||
}
|
||||
}
|
||||
|
||||
if (getStringWidth(currentWord + word + " ") < width) {
|
||||
currentWord = currentWord + word + " ";
|
||||
} else {
|
||||
finalWords.add(currentWord);
|
||||
currentWord = "" + lastColorCode + word + " ";
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWord.length() > 0) if (getStringWidth(currentWord) < width) {
|
||||
finalWords.add("" + lastColorCode + currentWord + " ");
|
||||
currentWord = "";
|
||||
} else {
|
||||
for (String s : formatString(currentWord, width)) {
|
||||
finalWords.add(s);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
finalWords.add(text);
|
||||
}
|
||||
|
||||
return finalWords;
|
||||
}
|
||||
|
||||
public List<String> formatString(String string, double width) {
|
||||
List finalWords = new ArrayList();
|
||||
String currentWord = "";
|
||||
char lastColorCode = 65535;
|
||||
char[] chars = string.toCharArray();
|
||||
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
|
||||
if ((String.valueOf(c).equals("§")) && (i < chars.length - 1))//Why does intelij replace "§" with §
|
||||
{
|
||||
lastColorCode = chars[(i + 1)];
|
||||
}
|
||||
|
||||
if (getStringWidth(currentWord + c) < width) {
|
||||
currentWord = currentWord + c;
|
||||
} else {
|
||||
finalWords.add(currentWord);
|
||||
currentWord = "" + lastColorCode + String.valueOf(c);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWord.length() > 0) {
|
||||
finalWords.add(currentWord);
|
||||
}
|
||||
|
||||
return finalWords;
|
||||
}
|
||||
|
||||
private void setupMinecraftColorcodes() {
|
||||
for (int index = 0; index < 32; index++) {
|
||||
int noClue = (index >> 3 & 0x1) * 85;
|
||||
int red = (index >> 2 & 0x1) * 170 + noClue;
|
||||
int green = (index >> 1 & 0x1) * 170 + noClue;
|
||||
int blue = (index >> 0 & 0x1) * 170 + noClue;
|
||||
|
||||
if (index == 6) {
|
||||
red += 85;
|
||||
}
|
||||
|
||||
if (index >= 16) {
|
||||
red /= 4;
|
||||
green /= 4;
|
||||
blue /= 4;
|
||||
}
|
||||
|
||||
this.colorCode[index] = ((red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.font;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
public class FontUtil {
|
||||
|
||||
public static Font getFontFromTTF(InputStream inputStream, float fontSize, int fontType) {
|
||||
Font output = null;
|
||||
try {
|
||||
output = Font.createFont(fontType, inputStream);
|
||||
output = output.deriveFont(fontSize);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.manager;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Getter
|
||||
public class ResourceManager {
|
||||
private final File orangeXDir = new File(System.getProperty("user.home") + "/.orangex");
|
||||
|
||||
// Alt
|
||||
private File altConfig = new File(orangeXDir, "alts.json");
|
||||
|
||||
// Panel Config
|
||||
private File panelConfig = new File(orangeXDir, "panel.json");
|
||||
// Modules Config
|
||||
private File modulesConfig = new File(orangeXDir, "modules.json");
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.manager;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventTimerThread;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class ThreadManager {
|
||||
|
||||
private Thread timerThread;
|
||||
private volatile boolean running = false;
|
||||
|
||||
private static final long TIMER_INTERVAL_MS = 10L;
|
||||
|
||||
public void init() {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
|
||||
running = true;
|
||||
|
||||
timerThread = new Thread(() -> {
|
||||
while (running && !Thread.currentThread().isInterrupted()) {
|
||||
OrangeX.getInstance()
|
||||
.getEventBus()
|
||||
.post(new EventTimerThread());
|
||||
|
||||
try {
|
||||
Thread.sleep(TIMER_INTERVAL_MS);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, "OrangeX-Timer");
|
||||
|
||||
timerThread.start();
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(
|
||||
new Thread(this::shutdown, "OrangeX-Timer-Shutdown")
|
||||
);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
running = false;
|
||||
if (timerThread != null) {
|
||||
timerThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.mixin;
|
||||
|
||||
import cn.xiaozhou233.orangex.mixin.impl.MixinEntityRenderer;
|
||||
import cn.xiaozhou233.orangex.mixin.impl.MixinGuiIngame;
|
||||
import cn.xiaozhou233.orangex.mixin.impl.MixinMinecraft;
|
||||
import cn.xiaozhou233.orangex.mixin.impl.MixinNetHandlerPlayClient;
|
||||
import cn.xiaozhou233.orangex.utils.JuiceAgentFacade;
|
||||
import cn.yapeteam.ymixin.Transformer;
|
||||
import cn.yapeteam.ymixin.YMixin;
|
||||
|
||||
public final class MixinManager {
|
||||
|
||||
public 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 = JuiceAgentFacade.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);
|
||||
transformer.addMixin(MixinMinecraft.class);
|
||||
transformer.addMixin(MixinEntityRenderer.class);
|
||||
transformer.addMixin(MixinNetHandlerPlayClient.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 = JuiceAgentFacade.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
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.mixin.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventRender3D;
|
||||
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.renderer.EntityRenderer;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public class MixinEntityRenderer {
|
||||
|
||||
@Inject(
|
||||
method = "renderWorldPass", desc = "(IFJ)V",
|
||||
target = @Target(
|
||||
value = "INVOKESTATIC",
|
||||
target = "net/minecraft/client/renderer/GlStateManager.disableFog()V",
|
||||
shift = Target.Shift.AFTER
|
||||
)
|
||||
)
|
||||
private void render(@Local(source = "partialTicks", index = 2) float partialTicks) {
|
||||
OrangeX.getInstance().getEventBus().post(new EventRender3D(partialTicks));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
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.getInstance().getEventBus().post(new EventRender2D(partialTicks));
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.mixin.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.*;
|
||||
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 org.lwjgl.input.Keyboard;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft {
|
||||
int i = 0;
|
||||
|
||||
@Inject(method = "runGameLoop", desc = "()V", target = @Target("HEAD"))
|
||||
private void onLoop() {
|
||||
OrangeX.getInstance().getEventBus().post(new EventLoop());
|
||||
}
|
||||
|
||||
@Inject(method = "runTick", desc = "()V", target = @Target("HEAD"))
|
||||
public void onTick() {
|
||||
OrangeX.getInstance().getEventBus().post(new EventTick());
|
||||
}
|
||||
|
||||
@Inject(method = "shutdownMinecraftApplet", desc = "()V", target = @Target("HEAD"))
|
||||
public void onShutdown() {
|
||||
OrangeX.getInstance().stop();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "runTick", desc = "()V",
|
||||
target = @Target(
|
||||
value = "INVOKESTATIC",
|
||||
target = "org/lwjgl/input/Keyboard.getEventKeyState()Z",
|
||||
shift = Target.Shift.AFTER
|
||||
)
|
||||
)
|
||||
public void onKey(@Local(source = "key", index = 1) int key) {
|
||||
if (Minecraft.getMinecraft().currentScreen == null && Keyboard.getEventKeyState())
|
||||
OrangeX.getInstance().getEventBus().post(new EventKey(key));
|
||||
}
|
||||
|
||||
@Inject(method = "loadWorld", desc = "(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", target = @Target("HEAD"))
|
||||
public void onLoadWorld() {
|
||||
OrangeX.getInstance().getEventBus().post(new EventWorldLoad());
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.mixin.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventPacketSend;
|
||||
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.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.Packet;
|
||||
|
||||
@Mixin(NetHandlerPlayClient.class)
|
||||
public class MixinNetHandlerPlayClient {
|
||||
@Inject(
|
||||
method = "addToSendQueue",
|
||||
desc = "(Lnet/minecraft/network/Packet;)V",
|
||||
target = @Target("HEAD")
|
||||
)
|
||||
public void onSendPacket(@Local(source = "packet", index = 1) Packet packet) {
|
||||
EventPacketSend eventPacketSend = new EventPacketSend(packet);
|
||||
OrangeX.getInstance().getEventBus().post(eventPacketSend);
|
||||
|
||||
if (eventPacketSend.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.module.value.KeybindValue;
|
||||
import cn.xiaozhou233.orangex.module.value.Value;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Getter
|
||||
public abstract class Module {
|
||||
protected final Minecraft mc = Minecraft.getMinecraft();
|
||||
protected final FontRenderer fr = mc.fontRendererObj;
|
||||
|
||||
protected final String name;
|
||||
@Getter
|
||||
@Setter
|
||||
protected KeybindValue keyBind = new KeybindValue("Bind", "KeyBinding", 0);
|
||||
protected final ModuleCategory category;
|
||||
protected boolean enabled = false;
|
||||
@Getter
|
||||
protected final List<Value<?>> values = new ArrayList<>();
|
||||
|
||||
public Module(String name, ModuleCategory category) {
|
||||
this.name = name;
|
||||
this.category = category;
|
||||
|
||||
addValue(keyBind);
|
||||
}
|
||||
|
||||
public Module(String name, ModuleCategory category, int defaultKey) {
|
||||
this(name, category);
|
||||
this.keyBind.setKey(defaultKey);
|
||||
}
|
||||
|
||||
protected void onEnable() {
|
||||
System.out.println("[OrangeX] Enable " + name);
|
||||
}
|
||||
|
||||
protected void onDisable() {
|
||||
System.out.println("[OrangeX] Disable " + name);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean setEnabled) {
|
||||
if (this.enabled == setEnabled) return;
|
||||
|
||||
this.enabled = setEnabled;
|
||||
|
||||
if (this.enabled) {
|
||||
if (OrangeX.getInstance().getEventBus().isRegistered(this))
|
||||
return;
|
||||
try { OrangeX.getInstance().getEventBus().register(this); } catch (Exception ignored) {}
|
||||
onEnable();
|
||||
} else {
|
||||
if (!OrangeX.getInstance().getEventBus().isRegistered(this))
|
||||
return;
|
||||
try { OrangeX.getInstance().getEventBus().unregister(this); } catch (Exception ignored) {}
|
||||
onDisable();
|
||||
}
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
setEnabled(!this.enabled);
|
||||
}
|
||||
|
||||
protected void addValue(Value<?> value) {
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Optional<Value<T>> getValue(String name, Class<T> type) {
|
||||
for (Value<?> v : values) {
|
||||
if (v.getName().equalsIgnoreCase(name) && type.isInstance(v.getValue())) {
|
||||
return Optional.of((Value<T>) v);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module;
|
||||
|
||||
public enum ModuleCategory {
|
||||
RENDER,
|
||||
COMBAT,
|
||||
WORLD,
|
||||
MISC,
|
||||
MOVEMENT,
|
||||
PLAYER,
|
||||
FUN
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventKey;
|
||||
import cn.xiaozhou233.orangex.module.impl.combat.AutoClicker;
|
||||
import cn.xiaozhou233.orangex.module.impl.fun.Derp;
|
||||
import cn.xiaozhou233.orangex.module.impl.misc.Test;
|
||||
import cn.xiaozhou233.orangex.module.impl.movement.NoJumpDelay;
|
||||
import cn.xiaozhou233.orangex.module.impl.render.*;
|
||||
import cn.xiaozhou233.orangex.module.impl.world.FastPlace;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ModuleManager {
|
||||
private static final List<Module> modules = new CopyOnWriteArrayList<>();
|
||||
|
||||
public ModuleManager() {
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
OrangeX.getInstance().getEventBus().register(this);
|
||||
registerAll();
|
||||
}
|
||||
|
||||
public void registerAll() {
|
||||
register(new ClickGUI());
|
||||
register(new HUD());
|
||||
|
||||
register(new Test());
|
||||
|
||||
register(new Derp());
|
||||
|
||||
register(new NoJumpDelay());
|
||||
|
||||
register(new AutoClicker());
|
||||
|
||||
register(new FastPlace());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onKey(EventKey event) {
|
||||
for (Module module : modules) {
|
||||
if (module.getKeyBind().getValue() == event.getKey()) {
|
||||
module.toggle();
|
||||
System.out.println("[ModuleManager] Toggled module: " + module.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register(Module module) {
|
||||
modules.add(module);
|
||||
System.out.println("[ModuleManager] Registered module: " + module.getName());
|
||||
}
|
||||
|
||||
public Module getModule(String name) {
|
||||
return modules.stream()
|
||||
.filter(m -> m.getName().equalsIgnoreCase(name))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public List<Module> getModulesByCategory(ModuleCategory category) {
|
||||
return modules.stream()
|
||||
.filter(m -> m.getCategory() == category)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Module> getAllModules() {
|
||||
return modules;
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.combat;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventTimerThread;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AutoClicker extends Module {
|
||||
|
||||
private final ScheduledExecutorService CLICK_EXECUTOR =
|
||||
Executors.newSingleThreadScheduledExecutor(r -> new Thread(r, "OrangeX-ClickThread"));
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
private long lastClickTime = System.currentTimeMillis();
|
||||
private long delayMs = 100;
|
||||
|
||||
private final Deque<Double> intervalTicks = new ArrayDeque<>();
|
||||
private static final int HISTORY = 100;
|
||||
|
||||
private final NumberValue cps =
|
||||
new NumberValue("CPS", "Clicks per second", 8d, 1, 20, 0.1);
|
||||
|
||||
public AutoClicker() {
|
||||
super("AutoClicker", ModuleCategory.COMBAT);
|
||||
addValue(cps);
|
||||
}
|
||||
|
||||
private double getStdDev() {
|
||||
if (intervalTicks.size() < 5) return 1.0;
|
||||
|
||||
double sum = 0;
|
||||
for (double v : intervalTicks) sum += v;
|
||||
double mean = sum / intervalTicks.size();
|
||||
|
||||
double var = 0;
|
||||
for (double v : intervalTicks) var += (v - mean) * (v - mean);
|
||||
var /= intervalTicks.size();
|
||||
|
||||
return Math.sqrt(var);
|
||||
}
|
||||
|
||||
private long generateDelayMs() {
|
||||
double target = cps.getValue();
|
||||
double meanMs = 1000.0 / target;
|
||||
|
||||
// 双峰:更快 / 更慢
|
||||
double shortDelay = meanMs * (0.65 + random.nextDouble() * 0.15); // 0.65~0.8 倍
|
||||
double longDelay = meanMs * (1.25 + random.nextDouble() * 0.35); // 1.25~1.6 倍
|
||||
|
||||
// 计算 stdDev
|
||||
double stdDev = getStdDev();
|
||||
|
||||
// 10% 极端值
|
||||
if (random.nextDouble() < 0.1) {
|
||||
if (random.nextBoolean()) {
|
||||
return Math.max(1, (long) (meanMs * (0.35 + random.nextDouble() * 0.25)));
|
||||
} else {
|
||||
return Math.max(1, (long) (meanMs * (1.7 + random.nextDouble() * 0.8)));
|
||||
}
|
||||
}
|
||||
|
||||
// 如果 stdDev < 1,则强制“极端化”
|
||||
if (stdDev < 1.0) {
|
||||
if (random.nextBoolean()) {
|
||||
return Math.max(1, (long) (meanMs * (0.35 + random.nextDouble() * 0.25)));
|
||||
} else {
|
||||
return Math.max(1, (long) (meanMs * (1.7 + random.nextDouble() * 0.8)));
|
||||
}
|
||||
}
|
||||
|
||||
// 这里是关键:让“短间隔出现概率更高”,保证平均 CPS 不下降
|
||||
// 例如:短间隔 70% / 长间隔 30%
|
||||
boolean pickShort = random.nextDouble() < 0.7;
|
||||
return Math.max(1, (long) (pickShort ? shortDelay : longDelay));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTimer(EventTimerThread event) {
|
||||
if (mc.theWorld == null) return;
|
||||
if (!Mouse.isButtonDown(0)) return;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - lastClickTime < delayMs) return;
|
||||
|
||||
int keyCode = mc.gameSettings.keyBindAttack.getKeyCode();
|
||||
KeyBinding.setKeyBindState(keyCode, true);
|
||||
KeyBinding.onTick(keyCode);
|
||||
|
||||
CLICK_EXECUTOR.schedule(() -> {
|
||||
KeyBinding.setKeyBindState(keyCode, false);
|
||||
}, 1 + random.nextInt(10), TimeUnit.MILLISECONDS);
|
||||
|
||||
double intervalMs = now - lastClickTime;
|
||||
double intervalTick = intervalMs / 50.0;
|
||||
|
||||
intervalTicks.addLast(intervalTick);
|
||||
if (intervalTicks.size() > HISTORY) intervalTicks.removeFirst();
|
||||
|
||||
lastClickTime = now;
|
||||
delayMs = generateDelayMs();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDisable() {
|
||||
CLICK_EXECUTOR.shutdownNow();
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.fun;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventLoop;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventPacketSend;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.module.value.BooleanValue;
|
||||
import cn.xiaozhou233.orangex.module.value.ModeValue;
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.play.client.C03PacketPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Derp extends Module {
|
||||
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private float yaw = 0f;
|
||||
|
||||
private final NumberValue speed =
|
||||
new NumberValue("Speed", "Speed", 10d, 1d, 100d, 0.1d);
|
||||
private final BooleanValue serverOnly =
|
||||
new BooleanValue("ServerOnly", "ServerOnly", false);
|
||||
private final ModeValue mode =
|
||||
new ModeValue("Mode", "Mode", "Derp", Arrays.asList("Derp", "Random", "Jitter"));
|
||||
|
||||
public Derp() {
|
||||
super("Derp", ModuleCategory.FUN);
|
||||
|
||||
addValue(speed);
|
||||
addValue(serverOnly);
|
||||
addValue(mode);
|
||||
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
yaw = mc.thePlayer != null ? mc.thePlayer.rotationYaw : 0f;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onLoop(EventLoop event) {
|
||||
float spd = speed.getValue().floatValue();
|
||||
|
||||
switch (mode.getValue()) {
|
||||
case "Derp":
|
||||
yaw += spd;
|
||||
break;
|
||||
|
||||
case "Random":
|
||||
yaw = (float) (Math.random() * 360f - 180f);
|
||||
break;
|
||||
|
||||
case "Jitter":
|
||||
yaw += MathHelper.clamp_float(
|
||||
(float) ((Math.random() * 2f - 1f) * spd),
|
||||
-15f,
|
||||
15f
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
yaw = MathHelper.wrapAngleTo180_float(yaw);
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onPacketSend(EventPacketSend event) {
|
||||
if (!(event.getPacket() instanceof C03PacketPlayer))
|
||||
return;
|
||||
if (mc.thePlayer == null)
|
||||
return;
|
||||
|
||||
C03PacketPlayer packet = (C03PacketPlayer) event.getPacket();
|
||||
setYawPitch(packet, yaw, mc.thePlayer.rotationPitch);
|
||||
|
||||
if (!serverOnly.getValue()) {
|
||||
mc.thePlayer.renderYawOffset = yaw;
|
||||
mc.thePlayer.rotationYawHead = yaw;
|
||||
}
|
||||
}
|
||||
|
||||
private void setYawPitch(C03PacketPlayer packet, float yaw, float pitch) {
|
||||
try {
|
||||
Field yawField = C03PacketPlayer.class.getDeclaredField("yaw");
|
||||
Field pitchField = C03PacketPlayer.class.getDeclaredField("pitch");
|
||||
|
||||
yawField.setAccessible(true);
|
||||
pitchField.setAccessible(true);
|
||||
|
||||
yawField.setFloat(packet, yaw);
|
||||
pitchField.setFloat(packet, pitch);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.misc;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventKey;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventWorldLoad;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.module.value.BooleanValue;
|
||||
import cn.xiaozhou233.orangex.module.value.KeybindValue;
|
||||
import cn.xiaozhou233.orangex.module.value.ModeValue;
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Test extends Module{
|
||||
|
||||
public Test() {
|
||||
super("Test", ModuleCategory.MISC);
|
||||
|
||||
// Boolean Examples
|
||||
addValue(new BooleanValue("Example Boolean1", "Example", true));
|
||||
addValue(new BooleanValue("Example Boolean2", "Example", false));
|
||||
|
||||
// Keybinding Examples
|
||||
addValue(new KeybindValue("Example1", "Example", 0));
|
||||
addValue(new KeybindValue("Example2", "Example", Keyboard.KEY_RSHIFT));
|
||||
|
||||
// Mode Examples
|
||||
addValue(new ModeValue("Example Mode", "Example", "ModeA", new ArrayList<>(Arrays.asList("ModeA", "ModeB", "ModeC"))));
|
||||
|
||||
// Number Examples
|
||||
addValue(new NumberValue("Example Number", "Example", 0.0, 0, 100, 0.1));
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onKey(EventKey event) {
|
||||
System.out.println("Key: " + event.getKey());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onWorldLoad(EventWorldLoad event) {
|
||||
System.out.println("World loaded");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.movement;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventLoop;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class NoJumpDelay extends Module {
|
||||
private static Field jumpTicksField;
|
||||
|
||||
static {
|
||||
try {
|
||||
jumpTicksField = EntityLivingBase.class.getDeclaredField("jumpTicks");
|
||||
jumpTicksField.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public NoJumpDelay() {
|
||||
super("NoJumpDelay", ModuleCategory.MOVEMENT);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEventLoop(EventLoop event) {
|
||||
if (mc.thePlayer == null) return;
|
||||
|
||||
try {
|
||||
jumpTicksField.setInt(mc.thePlayer, 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.render;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.ClickGuiScreen;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class ClickGUI extends Module {
|
||||
|
||||
public ClickGUI() {
|
||||
super("ClickGUI", ModuleCategory.RENDER);
|
||||
keyBind.setKey(Keyboard.KEY_RSHIFT);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnable() {
|
||||
super.onEnable();
|
||||
|
||||
mc.displayGuiScreen(new ClickGuiScreen());
|
||||
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.render;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.event.impl.EventRender2D;
|
||||
import cn.xiaozhou233.orangex.font.FontRenderer;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class HUD extends Module {
|
||||
|
||||
private float rainbowTick = 0f;
|
||||
|
||||
private static final int MARGIN = 6;
|
||||
private static final int PADDING = 2;
|
||||
private static final int MODULE_SPACING = 4;
|
||||
private static final int LOGO_COLOR = 0xFFA500;
|
||||
private static final int BACKGROUND_ALPHA = 0x70; // 112
|
||||
private static final float RAINBOW_CYCLE = 60f;
|
||||
|
||||
public HUD() {
|
||||
super("HUD", ModuleCategory.RENDER);
|
||||
|
||||
// TODO: Remove this when config is implemented
|
||||
setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onRender2D(EventRender2D event) {
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
rainbowTick += event.getPartialTicks();
|
||||
|
||||
renderLogo();
|
||||
renderModuleList(sr);
|
||||
}
|
||||
|
||||
private void renderLogo() {
|
||||
OrangeX.getInstance().getFontManager().JelloMedium32.drawStringWithShadow("OrangeX", 5, 5, LOGO_COLOR);
|
||||
}
|
||||
|
||||
private void renderModuleList(ScaledResolution sr) {
|
||||
List<Module> enabledModules = OrangeX.getInstance().getModuleManager()
|
||||
.getAllModules()
|
||||
.stream()
|
||||
.filter(Module::isEnabled)
|
||||
.sorted(Comparator.comparingInt((Module m) ->
|
||||
OrangeX.getInstance().getFontManager().MontserratMedium18.getStringWidth(m.getName())).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int y = MARGIN;
|
||||
int screenWidth = sr.getScaledWidth();
|
||||
|
||||
for (int i = 0; i < enabledModules.size(); i++) {
|
||||
Module module = enabledModules.get(i);
|
||||
int textWidth = OrangeX.getInstance().getFontManager().MontserratMedium18.getStringWidth(module.getName());
|
||||
int x = screenWidth - textWidth - MARGIN;
|
||||
|
||||
int color = getRainbowColor(rainbowTick + i * 6f);
|
||||
drawHudString(module.getName(), x, y, color);
|
||||
|
||||
y += OrangeX.getInstance().getFontManager().MontserratMedium18.getStringHeight(module.getName()) + MODULE_SPACING;
|
||||
}
|
||||
}
|
||||
|
||||
private void drawHudString(String text, int x, int y, int color) {
|
||||
FontRenderer font = OrangeX.getInstance().getFontManager().MontserratMedium18;
|
||||
int textWidth = font.getStringWidth(text);
|
||||
|
||||
Gui.drawRect(
|
||||
x - PADDING,
|
||||
y - PADDING,
|
||||
x + textWidth + PADDING,
|
||||
y + font.getStringHeight(text) + PADDING,
|
||||
(BACKGROUND_ALPHA << 24) | 0x000000
|
||||
);
|
||||
|
||||
font.drawStringWithShadow(text, x, y, color);
|
||||
}
|
||||
|
||||
private int getRainbowColor(float tick) {
|
||||
float hue = (tick % RAINBOW_CYCLE) / RAINBOW_CYCLE;
|
||||
return Color.HSBtoRGB(hue, 0.9f, 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.impl.world;
|
||||
|
||||
import cn.xiaozhou233.orangex.event.impl.EventTick;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import cn.xiaozhou233.orangex.utils.ReflectionUtil;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FastPlace extends Module {
|
||||
|
||||
// Level 1~5
|
||||
private final NumberValue level =
|
||||
new NumberValue("Level", "FastPlace level", 1d, 1d, 5d, 1d);
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
public FastPlace() {
|
||||
super("FastPlace", ModuleCategory.WORLD);
|
||||
addValue(level);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onTick(EventTick event) {
|
||||
if (mc.thePlayer == null || mc.theWorld == null) return;
|
||||
|
||||
ItemStack stack = mc.thePlayer.getHeldItem();
|
||||
if (stack == null || !(stack.getItem() instanceof ItemBlock)) return;
|
||||
|
||||
try {
|
||||
int lvl = level.getValue().intValue();
|
||||
|
||||
// Level -> min/max ms
|
||||
int minMs = (lvl - 1) * 50;
|
||||
int maxMs = lvl * 50;
|
||||
|
||||
// Random ms within level range
|
||||
int delayMs = minMs + random.nextInt(maxMs - minMs + 1);
|
||||
|
||||
int targetTick = (int) Math.ceil(delayMs / 50.0);
|
||||
int current = ReflectionUtil.getRightClickDelay();
|
||||
|
||||
if (current > targetTick) {
|
||||
ReflectionUtil.setRightClickDelay(targetTick);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.value;
|
||||
|
||||
public class BooleanValue extends Value<Boolean> {
|
||||
public BooleanValue(String name, String description, Boolean defaultValue) {
|
||||
super(name, description, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Boolean> getValueClass() {
|
||||
return Boolean.class;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.value;
|
||||
|
||||
public class KeybindValue extends Value<Integer> {
|
||||
|
||||
public KeybindValue(String name, String description, Integer defaultValue) {
|
||||
super(name, description, defaultValue);
|
||||
}
|
||||
|
||||
public void setKey(int key) {
|
||||
setValue(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Integer> getValueClass() {
|
||||
return Integer.class;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.value;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class ModeValue extends Value<String> {
|
||||
|
||||
private final List<String> modes;
|
||||
|
||||
public ModeValue(String name, String description, String defaultValue, List<String> modes) {
|
||||
super(name, description, defaultValue);
|
||||
this.modes = modes;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return modes.indexOf(getValue());
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
if (index < 0 || index >= modes.size()) return;
|
||||
setValue(modes.get(index));
|
||||
}
|
||||
|
||||
public void next() {
|
||||
int index = getIndex();
|
||||
if (index < 0) index = 0;
|
||||
index++;
|
||||
if (index >= modes.size()) index = 0;
|
||||
setIndex(index);
|
||||
}
|
||||
|
||||
public void previous() {
|
||||
int index = getIndex();
|
||||
if (index < 0) index = 0;
|
||||
index--;
|
||||
if (index < 0) index = modes.size() - 1;
|
||||
setIndex(index);
|
||||
}
|
||||
|
||||
public String getCurrentMode() {
|
||||
return getValue();
|
||||
}
|
||||
|
||||
public boolean isValidMode(String mode) {
|
||||
return modes.contains(mode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<String> getValueClass() {
|
||||
return String.class;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.value;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class NumberValue extends Value<Double> {
|
||||
|
||||
private final double min;
|
||||
private final double max;
|
||||
private final double increment;
|
||||
|
||||
public NumberValue(String name, String description, Double defaultValue, double min, double max, double increment) {
|
||||
super(name, description, defaultValue);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.increment = increment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<Double> getValueClass() {
|
||||
return Double.class;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.module.value;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public abstract class Value<T> {
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
@Setter
|
||||
private T value;
|
||||
|
||||
public Value(String name, String description, T defaultValue) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.value = defaultValue;
|
||||
}
|
||||
|
||||
public void fromJson(JsonElement element) {
|
||||
try {
|
||||
setValue(gson.fromJson(element, getValueClass()));
|
||||
} catch (JsonSyntaxException e) {
|
||||
System.out.println("Failed to parse json for value " + name);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Class<T> getValueClass();
|
||||
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.altmanager;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.alts.Alt;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GUIAddCracked extends GuiScreen {
|
||||
|
||||
private GuiTextField nameField;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
|
||||
nameField = new GuiTextField(0, fontRendererObj, this.width / 2 - 100, this.height / 2 - 10, 200, 20);
|
||||
nameField.setMaxStringLength(32);
|
||||
|
||||
this.buttonList.add(new GuiButton(1, this.width / 2 - 50, this.height / 2 + 20, 100, 20, "Save"));
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 50, this.height / 2 + 45, 100, 20, "Back"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
save();
|
||||
break;
|
||||
case 0:
|
||||
mc.displayGuiScreen(new GUIAltManager());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
String name = nameField.getText().trim();
|
||||
if (!name.isEmpty()) {
|
||||
Alt alt = new Alt(
|
||||
name,
|
||||
UUID.randomUUID(),
|
||||
"",
|
||||
0L
|
||||
);
|
||||
OrangeX.getInstance().getAltManager().addAlt(alt);
|
||||
mc.displayGuiScreen(new GUIAltManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
nameField.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
nameField.textboxKeyTyped(typedChar, keyCode);
|
||||
|
||||
if (keyCode == 28) {
|
||||
save();
|
||||
}
|
||||
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
nameField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawDefaultBackground();
|
||||
drawCenteredString(fontRendererObj, "Add Cracked", width / 2, height / 2 - 30, 0xFFFFFF);
|
||||
|
||||
nameField.drawTextBox();
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.altmanager;
|
||||
|
||||
import cn.xiaozhou233.orangex.alts.AltLoginThread;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GUIAddMicrosoft extends GuiScreen {
|
||||
|
||||
private AltLoginThread loginThread;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
|
||||
this.buttonList.add(new GuiButton(1, this.width / 2 - 50, this.height / 2 + 20, 100, 20, "Start Login"));
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 50, this.height / 2 + 45, 100, 20, "Back"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
if (loginThread == null || !loginThread.isAlive()) {
|
||||
loginThread = new AltLoginThread(null);
|
||||
loginThread.start();
|
||||
}
|
||||
break;
|
||||
|
||||
case 0:
|
||||
mc.displayGuiScreen(new GUIAltManager());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawDefaultBackground();
|
||||
|
||||
drawCenteredString(fontRendererObj, "Add Microsoft", width / 2, height / 2 - 40, 0xFFFFFF);
|
||||
|
||||
String status = "NONE";
|
||||
if (loginThread != null) {
|
||||
status = loginThread.getStatus();
|
||||
}
|
||||
|
||||
drawCenteredString(fontRendererObj, "Status: " + status, width / 2, height / 2 - 10, 0xFFFFFF);
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.altmanager;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.alts.Alt;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class GUIAltManager extends GuiScreen {
|
||||
|
||||
private int selectedIndex = -1;
|
||||
private int scroll = 0;
|
||||
|
||||
// Double click detect
|
||||
private int lastClickIndex = -1;
|
||||
private long lastClickTime = 0L;
|
||||
|
||||
// Double click interval (ms)
|
||||
private static final long DOUBLE_CLICK_DELAY = 250L;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
|
||||
// Reset click state
|
||||
selectedIndex = -1;
|
||||
lastClickIndex = -1;
|
||||
lastClickTime = 0L;
|
||||
|
||||
// Add
|
||||
this.buttonList.add(new GuiButton(1, this.width - 110, 10, 100, 20, "Add Cracked"));
|
||||
this.buttonList.add(new GuiButton(2, this.width - 110, 35, 100, 20, "Add Microsoft"));
|
||||
|
||||
// Back
|
||||
this.buttonList.add(new GuiButton(3, 10, this.height - 30, 60, 20, "Back"));
|
||||
|
||||
// Delete
|
||||
this.buttonList.add(new GuiButton(5, 80, this.height - 30, 60, 20, "Delete"));
|
||||
|
||||
// Login
|
||||
this.buttonList.add(new GuiButton(4, this.width - 70, this.height - 30, 60, 20, "Login"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
List<Alt> alts = OrangeX.getInstance().getAltManager().getAlts();
|
||||
|
||||
switch (button.id) {
|
||||
case 1:
|
||||
mc.displayGuiScreen(new GUIAddCracked());
|
||||
break;
|
||||
|
||||
case 2:
|
||||
mc.displayGuiScreen(new GUIAddMicrosoft());
|
||||
break;
|
||||
|
||||
case 3:
|
||||
mc.displayGuiScreen(new GuiMultiplayer(null));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (selectedIndex >= 0 && selectedIndex < alts.size()) {
|
||||
Alt alt = alts.get(selectedIndex);
|
||||
OrangeX.getInstance().getAltManager().login(alt);
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (selectedIndex >= 0 && selectedIndex < alts.size()) {
|
||||
Alt alt = alts.get(selectedIndex);
|
||||
OrangeX.getInstance().getAltManager().removeAlt(alt);
|
||||
selectedIndex = -1;
|
||||
lastClickIndex = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
|
||||
drawCenteredString(this.fontRendererObj, "Alt Manager", this.width / 2, 10, Color.WHITE.getRGB());
|
||||
|
||||
mc.fontRendererObj.drawString(
|
||||
"Current Account: §a" + Minecraft.getMinecraft().getSession().getUsername(),
|
||||
10, 30, Color.WHITE.getRGB()
|
||||
);
|
||||
|
||||
List<Alt> alts = OrangeX.getInstance().getAltManager().getAlts();
|
||||
|
||||
int startX = 10;
|
||||
int startY = 60;
|
||||
int listWidth = this.width - 20;
|
||||
int listHeight = this.height - 110;
|
||||
int lineHeight = 20;
|
||||
|
||||
// Draw list background
|
||||
drawRect(
|
||||
startX - 2,
|
||||
startY - 2,
|
||||
startX + listWidth + 2,
|
||||
startY + listHeight + 2,
|
||||
0x55000000
|
||||
);
|
||||
|
||||
// Scroll
|
||||
int wheel = Mouse.getDWheel();
|
||||
if (wheel != 0) {
|
||||
scroll += wheel > 0 ? -20 : 20;
|
||||
}
|
||||
|
||||
int maxScroll = Math.max(0, alts.size() * lineHeight - listHeight);
|
||||
if (scroll < 0) scroll = 0;
|
||||
if (scroll > maxScroll) scroll = maxScroll;
|
||||
|
||||
// Render alts
|
||||
for (int i = 0; i < alts.size(); i++) {
|
||||
int y = startY + i * lineHeight - scroll;
|
||||
|
||||
if (y < startY - lineHeight || y > startY + listHeight) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == selectedIndex) {
|
||||
drawRect(startX, y, startX + listWidth, y + lineHeight, 0x55FFFFFF);
|
||||
}
|
||||
|
||||
mc.fontRendererObj.drawString(
|
||||
alts.get(i).getName(),
|
||||
startX + 5,
|
||||
y + 6,
|
||||
Color.WHITE.getRGB()
|
||||
);
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if (mouseButton != 0) return;
|
||||
|
||||
List<Alt> alts = OrangeX.getInstance().getAltManager().getAlts();
|
||||
|
||||
int startX = 10;
|
||||
int startY = 60;
|
||||
int listWidth = this.width - 20;
|
||||
int listHeight = this.height - 110;
|
||||
int lineHeight = 20;
|
||||
|
||||
for (int i = 0; i < alts.size(); i++) {
|
||||
int y = startY + i * lineHeight - scroll;
|
||||
|
||||
// Only allow clicking visible items
|
||||
if (y < startY - lineHeight || y > startY + listHeight) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mouseX >= startX && mouseX <= startX + listWidth &&
|
||||
mouseY >= y && mouseY <= y + lineHeight) {
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (lastClickIndex == i && now - lastClickTime <= DOUBLE_CLICK_DELAY) {
|
||||
// Double click -> login
|
||||
OrangeX.getInstance().getAltManager().login(alts.get(i));
|
||||
return;
|
||||
}
|
||||
|
||||
// Single click -> select
|
||||
selectedIndex = i;
|
||||
lastClickIndex = i;
|
||||
lastClickTime = now;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
mc.displayGuiScreen(new GuiMultiplayer(null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import cn.xiaozhou233.orangex.config.ConfigManager;
|
||||
import cn.xiaozhou233.orangex.config.PanelPosition;
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.module.ModuleCategory;
|
||||
import cn.xiaozhou233.orangex.module.value.*;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.panel.Panel;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.ModuleButton;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.BooleanComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.NumberComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.ModeComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.KeybindComponent;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClickGuiScreen extends GuiScreen {
|
||||
|
||||
// Category
|
||||
private final List<Panel> panels = new ArrayList<>();
|
||||
|
||||
// Dragging
|
||||
private Panel draggingPanel = null;
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
panels.clear();
|
||||
|
||||
ScaledResolution sr = new ScaledResolution(mc);
|
||||
double screenWidth = sr.getScaledWidth_double();
|
||||
double screenHeight = sr.getScaledHeight_double();
|
||||
|
||||
double margin = 20;
|
||||
double startX = margin;
|
||||
double startY = margin;
|
||||
|
||||
double panelWidth = 120;
|
||||
double panelHeaderHeight = 20;
|
||||
double gap = 10;
|
||||
|
||||
for (ModuleCategory category : ModuleCategory.values()) {
|
||||
if (startX + panelWidth > screenWidth - margin) {
|
||||
startX = margin;
|
||||
startY += panelHeaderHeight + gap;
|
||||
}
|
||||
|
||||
PanelPosition position =
|
||||
OrangeX.getInstance().getConfigManager().getPanelPosition(category.name());
|
||||
|
||||
double x = startX;
|
||||
double y = startY;
|
||||
|
||||
if (position != null) {
|
||||
x = Math.max(
|
||||
0,
|
||||
Math.min(position.getX(), screenWidth - panelWidth)
|
||||
);
|
||||
y = Math.max(
|
||||
0,
|
||||
Math.min(position.getY(), screenHeight - panelHeaderHeight)
|
||||
);
|
||||
}
|
||||
|
||||
Panel panel = new Panel(category.name(), x, y, panelWidth);
|
||||
|
||||
for (Module module : OrangeX.getInstance().getModuleManager().getModulesByCategory(category)) {
|
||||
ModuleButton button = new ModuleButton(0, 0, panelWidth, module, panel);
|
||||
|
||||
KeybindValue toggleKeybinding = null;
|
||||
|
||||
for (Value<?> value : module.getValues()) {
|
||||
if (value instanceof BooleanValue) {
|
||||
button.addComponent(new BooleanComponent(0, 0, panelWidth, (BooleanValue) value, button));
|
||||
} else if (value instanceof NumberValue) {
|
||||
button.addComponent(new NumberComponent(0, 0, panelWidth, (NumberValue) value, button));
|
||||
} else if (value instanceof ModeValue) {
|
||||
button.addComponent(new ModeComponent(0, 0, panelWidth, (ModeValue) value, button));
|
||||
} else if (value instanceof KeybindValue) {
|
||||
if (value.getName().equals("Bind")) {
|
||||
toggleKeybinding = (KeybindValue) value;
|
||||
} else {
|
||||
button.addComponent(new KeybindComponent(0, 0, panelWidth, (KeybindValue) value, button));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toggleKeybinding != null)
|
||||
button.addComponent(new KeybindComponent(0, 0, panelWidth, toggleKeybinding, button));
|
||||
|
||||
panel.addComponent(button);
|
||||
}
|
||||
|
||||
panels.add(panel);
|
||||
startX += panelWidth + gap;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
Gui.drawRect(0, 0, width, height, new Color(50, 50, 50, 100).getRGB());
|
||||
|
||||
for (Panel panel : panels) {
|
||||
panel.update(mouseX, mouseY);
|
||||
panel.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
for (int i = panels.size() - 1; i >= 0; i--) {
|
||||
Panel panel = panels.get(i);
|
||||
|
||||
if (panel.isHovered(mouseX, mouseY) || panel.isHeaderHovered(mouseX, mouseY)) {
|
||||
panels.remove(panel);
|
||||
panels.add(panel);
|
||||
|
||||
panel.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
if (mouseButton == 0 && panel.isHeaderHovered(mouseX, mouseY)) {
|
||||
draggingPanel = panel;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
if (draggingPanel != null) {
|
||||
draggingPanel.mouseReleased(mouseX, mouseY, state);
|
||||
|
||||
// Save Position to HashMap
|
||||
ConfigManager configManager = OrangeX.getInstance().getConfigManager();
|
||||
configManager.setPanelPosition(draggingPanel.getTitle(),
|
||||
new PanelPosition(draggingPanel.getAbsoluteX(), draggingPanel.getAbsoluteY()));
|
||||
|
||||
draggingPanel = null;
|
||||
}
|
||||
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
for (Panel panel : panels) {
|
||||
panel.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
if (keyCode == 1) {
|
||||
mc.displayGuiScreen(null);
|
||||
}
|
||||
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
// Save position to panel.json
|
||||
OrangeX.getInstance().getConfigManager().saveConfig();
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component;
|
||||
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.ModuleButton;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.panel.Panel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public abstract class Component {
|
||||
|
||||
@Setter
|
||||
protected double x, y;
|
||||
@Getter @Setter
|
||||
protected double width, height;
|
||||
|
||||
protected Component parent;
|
||||
@Getter
|
||||
@Setter
|
||||
protected boolean visible = true;
|
||||
|
||||
public Component(double x, double y, double width, double height, Component parent) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public abstract void render(int mouseX, int mouseY, float partialTicks);
|
||||
|
||||
public void update(int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||
|
||||
}
|
||||
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isHovered(int mouseX, int mouseY) {
|
||||
double px = getAbsoluteX();
|
||||
double py = getAbsoluteY();
|
||||
return mouseX >= px && mouseX <= px + width
|
||||
&& mouseY >= py && mouseY <= py + height;
|
||||
}
|
||||
|
||||
public double getAbsoluteX() {
|
||||
return parent == null ? x : parent.getAbsoluteX() + x;
|
||||
}
|
||||
|
||||
public double getAbsoluteY() {
|
||||
return parent == null ? y : parent.getAbsoluteY() + y;
|
||||
}
|
||||
|
||||
protected void setParent(Panel panel) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void setParent(Component parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public abstract class DragComponent extends ValueComponent {
|
||||
|
||||
protected boolean dragging = false;
|
||||
|
||||
public DragComponent(double x, double y, double width, double height, Component parent) {
|
||||
super(x, y, width, height, parent);
|
||||
}
|
||||
|
||||
// Called when dragging starts
|
||||
protected void onDragStart(int mouseX, int mouseY) {}
|
||||
|
||||
// Called every tick while dragging
|
||||
protected abstract void onDrag(int mouseX, int mouseY);
|
||||
|
||||
// Called when dragging ends
|
||||
protected void onDragEnd(int mouseX, int mouseY) {}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (button != 0) return;
|
||||
if (!isHovered(mouseX, mouseY)) return;
|
||||
|
||||
dragging = true;
|
||||
onDragStart(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||
if (button == 0 && dragging) {
|
||||
dragging = false;
|
||||
onDragEnd(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int mouseX, int mouseY) {
|
||||
// Safety release if mouseReleased event is lost
|
||||
if (dragging && !Mouse.isButtonDown(0)) {
|
||||
dragging = false;
|
||||
onDragEnd(mouseX, mouseY);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dragging) {
|
||||
onDrag(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component;
|
||||
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
|
||||
public abstract class ValueComponent extends Component {
|
||||
|
||||
public ValueComponent(double x, double y, double width, double height, Component parent) {
|
||||
super(x, y, width, height, parent);
|
||||
}
|
||||
|
||||
public abstract void applyValue();
|
||||
|
||||
protected void drawBackground(int mouseX, int mouseY) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
int bgColor = 0xFF333333;
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
bgColor = GuiRenderUtils.blendColor(bgColor, 0xFFFFFFFF, 0.12f);
|
||||
}
|
||||
GuiRenderUtils.drawRect(ax, ay, width, height, bgColor);
|
||||
}
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.value.BooleanValue;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.ValueComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
|
||||
public class BooleanComponent extends ValueComponent {
|
||||
|
||||
private final BooleanValue value;
|
||||
|
||||
public BooleanComponent(double x, double y, double width, BooleanValue value, Component parent) {
|
||||
super(x, y, width, 16, parent);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
double boxSize = 8;
|
||||
double boxX = ax + 4;
|
||||
double boxY = ay + (height - boxSize) / 2;
|
||||
|
||||
int boxColor = value.getValue() ? 0xFF2E8B57 : 0xFF444444;
|
||||
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
boxColor = GuiRenderUtils.blendColor(boxColor, 0xFFFFFFFF, 0.12f);
|
||||
}
|
||||
|
||||
GuiRenderUtils.enableBlend();
|
||||
|
||||
drawBackground(mouseX, mouseY);
|
||||
GuiRenderUtils.drawRect(boxX, boxY, boxSize, boxSize, boxColor);
|
||||
|
||||
GuiRenderUtils.drawString(value.getName(), ax + 4 + boxSize + 6, ay + 6, 0xFFFFFFFF);
|
||||
|
||||
GuiRenderUtils.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (!isHovered(mouseX, mouseY)) return;
|
||||
if (button == 0) {
|
||||
value.setValue(!value.getValue());
|
||||
applyValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyValue() {
|
||||
}
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.value.KeybindValue;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.ValueComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class KeybindComponent extends ValueComponent {
|
||||
|
||||
private final KeybindValue value;
|
||||
private boolean listening = false;
|
||||
|
||||
public KeybindComponent(double x, double y, double width, KeybindValue value, Component parent) {
|
||||
super(x, y, width, 16, parent);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
int bgColor = 0xFF333333;
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
bgColor = GuiRenderUtils.blendColor(bgColor, 0xFFFFFFFF, 0.12f);
|
||||
}
|
||||
|
||||
GuiRenderUtils.enableBlend();
|
||||
GuiRenderUtils.drawRect(ax, ay, width, height, bgColor);
|
||||
|
||||
String keyName = listening ? "Press a key..." : GameSettings.getKeyDisplayString(value.getValue());
|
||||
if (keyName==GameSettings.getKeyDisplayString(Keyboard.KEY_DELETE))
|
||||
keyName = "None";
|
||||
GuiRenderUtils.drawString(value.getName() + ": " + keyName, ax + 6, ay + 4, 0xFFFFFFFF);
|
||||
GuiRenderUtils.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (!isHovered(mouseX, mouseY)) return;
|
||||
|
||||
if (button == 0) {
|
||||
listening = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
if (!listening) return;
|
||||
|
||||
// ESC
|
||||
if (keyCode == 1) {
|
||||
listening = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// DELETE
|
||||
if (keyCode == Keyboard.KEY_DELETE) {
|
||||
value.setValue(Keyboard.KEY_NONE);
|
||||
listening = false;
|
||||
applyValue();
|
||||
return;
|
||||
}
|
||||
|
||||
value.setKey(keyCode);
|
||||
listening = false;
|
||||
applyValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyValue() {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.value.ModeValue;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.ValueComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
|
||||
public class ModeComponent extends ValueComponent {
|
||||
|
||||
private final ModeValue value;
|
||||
|
||||
public ModeComponent(double x, double y, double width, ModeValue value, Component parent) {
|
||||
super(x, y, width, 16, parent);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
int bgColor = 0xFF333333;
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
bgColor = GuiRenderUtils.blendColor(bgColor, 0xFFFFFFFF, 0.12f);
|
||||
}
|
||||
|
||||
GuiRenderUtils.enableBlend();
|
||||
GuiRenderUtils.drawRect(ax, ay, width, height, bgColor);
|
||||
|
||||
String text = value.getName() + ": " + value.getValue();
|
||||
GuiRenderUtils.drawString(text, ax + 6, ay + 4, 0xFFFFFFFF);
|
||||
GuiRenderUtils.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (!isHovered(mouseX, mouseY)) return;
|
||||
|
||||
if (button == 0) value.next();
|
||||
else if (button == 1) value.previous();
|
||||
|
||||
applyValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyValue() {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
-110
@@ -1,110 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.Module;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModuleButton extends Component {
|
||||
|
||||
private final Module module;
|
||||
private final List<Component> components = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private boolean expanded = false;
|
||||
|
||||
private final double baseHeight = 16;
|
||||
|
||||
public ModuleButton(double x, double y, double width, Module module, Component parent) {
|
||||
super(x, y, width, 16, parent);
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
int bgColor = module.isEnabled() ? 0xFF2E8B57 : 0x80000000;
|
||||
|
||||
if (isHovered(mouseX, mouseY)) {
|
||||
bgColor = GuiRenderUtils.blendColor(bgColor, 0xFFFFFFFF, 0.15f);
|
||||
}
|
||||
|
||||
GuiRenderUtils.enableBlend();
|
||||
GuiRenderUtils.drawRect(ax, ay, width, baseHeight, bgColor);
|
||||
|
||||
int statusColor = module.isEnabled() ? 0xFF00FF00 : 0xFF888888;
|
||||
GuiRenderUtils.drawRect(ax, ay, 2, baseHeight, statusColor);
|
||||
|
||||
GuiRenderUtils.drawString(module.getName(), ax + 6, ay + 6, 0xFFFFFFFF);
|
||||
GuiRenderUtils.disableBlend();
|
||||
|
||||
if (!expanded) {
|
||||
this.height = baseHeight;
|
||||
return;
|
||||
}
|
||||
|
||||
double offsetY = baseHeight;
|
||||
for (Component component : components) {
|
||||
component.setY(offsetY);
|
||||
component.setWidth(width);
|
||||
component.render(mouseX, mouseY, partialTicks);
|
||||
offsetY += component.getHeight();
|
||||
}
|
||||
this.height = offsetY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int mouseX, int mouseY) {
|
||||
if (!expanded) return;
|
||||
|
||||
for (Component component : components) {
|
||||
component.update(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (expanded) {
|
||||
for (Component component : components) {
|
||||
if (component.isHovered(mouseX, mouseY)) {
|
||||
component.mouseClicked(mouseX, mouseY, button);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isHovered(mouseX, mouseY)) return;
|
||||
|
||||
if (button == 0) {
|
||||
module.toggle();
|
||||
} else if (button == 1) {
|
||||
expanded = !expanded;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||
for (Component component : components) {
|
||||
component.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
if (!expanded) return;
|
||||
|
||||
for (Component component : components) {
|
||||
component.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(Component component) {
|
||||
component.setParent(this);
|
||||
components.add(component);
|
||||
}
|
||||
}
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.component.impl;
|
||||
|
||||
import cn.xiaozhou233.orangex.module.value.NumberValue;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.DragComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
|
||||
public class NumberComponent extends DragComponent {
|
||||
|
||||
private final NumberValue value;
|
||||
|
||||
public NumberComponent(double x, double y, double width, NumberValue value, Component parent) {
|
||||
super(x, y, width, 14, parent);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
double min = value.getMin();
|
||||
double max = value.getMax();
|
||||
double cur = value.getValue();
|
||||
|
||||
double ratio = (cur - min) / (max - min);
|
||||
ratio = Math.max(0, Math.min(1, ratio));
|
||||
|
||||
double fillWidth = ratio * (width - 10);
|
||||
|
||||
int bgColor = 0xFF333333;
|
||||
int fillColor = 0xFF2E8B57;
|
||||
|
||||
if (isHovered(mouseX, mouseY) || dragging) {
|
||||
bgColor = GuiRenderUtils.blendColor(bgColor, 0xFFFFFFFF, 0.12f);
|
||||
}
|
||||
|
||||
GuiRenderUtils.enableBlend();
|
||||
GuiRenderUtils.drawRect(ax, ay, width, height, bgColor);
|
||||
GuiRenderUtils.drawRect(ax + 5, ay + 9, fillWidth, 2, fillColor);
|
||||
|
||||
String text = value.getName() + ": " + String.format("%.2f", cur);
|
||||
GuiRenderUtils.drawString(text, ax + 6, ay + 3, 0xFFFFFFFF);
|
||||
GuiRenderUtils.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDrag(int mouseX, int mouseY) {
|
||||
double ax = getAbsoluteX();
|
||||
double rel = mouseX - ax - 5;
|
||||
double ratio = rel / (width - 10);
|
||||
ratio = Math.max(0, Math.min(1, ratio));
|
||||
|
||||
double newVal = value.getMin() + ratio * (value.getMax() - value.getMin());
|
||||
value.setValue(newVal);
|
||||
applyValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyValue() {
|
||||
// hook point
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.panel;
|
||||
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Panel extends Component {
|
||||
|
||||
@Getter
|
||||
private final String title;
|
||||
@Getter
|
||||
private final List<Component> components = new ArrayList<>();
|
||||
|
||||
private boolean dragging;
|
||||
private double dragX, dragY;
|
||||
|
||||
@Getter
|
||||
private boolean open = true;
|
||||
private final double headerHeight = 18;
|
||||
|
||||
public Panel(String title, double x, double y, double width) {
|
||||
super(x, y, width, 0, null);
|
||||
this.title = title;
|
||||
this.height = headerHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
double ax = getAbsoluteX();
|
||||
double ay = getAbsoluteY();
|
||||
|
||||
GuiRenderUtils.enableBlend();
|
||||
|
||||
// header
|
||||
GuiRenderUtils.drawRect(ax, ay, width, headerHeight, new Color(32, 32, 32, 255).getRGB());
|
||||
GuiRenderUtils.drawCenteredString(title, ax + width / 2, ay + 5, new Color(255, 255, 255, 255).getRGB());
|
||||
|
||||
if (!open) {
|
||||
GuiRenderUtils.disableBlend();
|
||||
return;
|
||||
}
|
||||
|
||||
GuiRenderUtils.drawRect(ax, ay + headerHeight, width, height - headerHeight, new Color(22, 22, 22, 230).getRGB());
|
||||
|
||||
double offsetY = headerHeight;
|
||||
|
||||
for (Component component : components) {
|
||||
if (!component.isVisible()) continue;
|
||||
|
||||
component.setY(offsetY);
|
||||
component.render(mouseX, mouseY, partialTicks);
|
||||
offsetY += component.getHeight();
|
||||
}
|
||||
|
||||
this.height = offsetY;
|
||||
|
||||
GuiRenderUtils.disableBlend();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(int mouseX, int mouseY) {
|
||||
if (dragging) {
|
||||
this.x = mouseX - dragX;
|
||||
this.y = mouseY - dragY;
|
||||
}
|
||||
|
||||
if (!open) return;
|
||||
|
||||
for (Component component : components) {
|
||||
component.update(mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button) {
|
||||
if (isHeaderHovered(mouseX, mouseY)) {
|
||||
if (button == 0) {
|
||||
dragging = true;
|
||||
dragX = mouseX - x;
|
||||
dragY = mouseY - y;
|
||||
}
|
||||
|
||||
if (button == 1) {
|
||||
open = !open;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!open) return;
|
||||
|
||||
for (Component component : components) {
|
||||
component.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(int mouseX, int mouseY, int button) {
|
||||
dragging = false;
|
||||
|
||||
if (!open) return;
|
||||
|
||||
for (Component component : components) {
|
||||
component.mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHeaderHovered(int mouseX, int mouseY) {
|
||||
double px = getAbsoluteX();
|
||||
double py = getAbsoluteY();
|
||||
return mouseX >= px && mouseX <= px + width
|
||||
&& mouseY >= py && mouseY <= py + headerHeight;
|
||||
}
|
||||
|
||||
public boolean isHovered(int mouseX, int mouseY) {
|
||||
double px = getAbsoluteX();
|
||||
double py = getAbsoluteY();
|
||||
return mouseX >= px && mouseX <= px + width
|
||||
&& mouseY >= py && mouseY <= py + height;
|
||||
}
|
||||
|
||||
public void addComponent(Component component) {
|
||||
component.setParent(this);
|
||||
components.add(component);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
super.keyTyped(typedChar, keyCode);
|
||||
for (Component c : components) {
|
||||
c.keyTyped(typedChar, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.render;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiRenderUtils {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static void drawRect(double x, double y, double w, double h, int color) {
|
||||
Gui.drawRect((int) x, (int) y, (int) (x + w), (int) (y + h), color);
|
||||
}
|
||||
|
||||
public static void drawString(String text, double x, double y, int color) {
|
||||
OrangeX.getInstance().getFontManager().JelloRegular16
|
||||
.drawString(text, (float) x, (float) y, color);
|
||||
}
|
||||
|
||||
public static void drawCenteredString(String text, double x, double y, int color) {
|
||||
OrangeX.getInstance().getFontManager().MontserratRegular18
|
||||
.drawString(text, (float) x - (float) OrangeX.getInstance().getFontManager().MontserratLight18.getStringWidth(text) / 2, (float) y, color);
|
||||
}
|
||||
|
||||
public static void enableBlend() {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
public static void disableBlend() {
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
public static int blendColor(int color1, int color2, float ratio) {
|
||||
if (ratio <= 0f) return color1;
|
||||
if (ratio >= 1f) return color2;
|
||||
|
||||
int a1 = (color1 >> 24) & 0xFF;
|
||||
int r1 = (color1 >> 16) & 0xFF;
|
||||
int g1 = (color1 >> 8) & 0xFF;
|
||||
int b1 = color1 & 0xFF;
|
||||
|
||||
int a2 = (color2 >> 24) & 0xFF;
|
||||
int r2 = (color2 >> 16) & 0xFF;
|
||||
int g2 = (color2 >> 8) & 0xFF;
|
||||
int b2 = color2 & 0xFF;
|
||||
|
||||
int a = (int) (a1 + (a2 - a1) * ratio);
|
||||
int r = (int) (r1 + (r2 - r1) * ratio);
|
||||
int g = (int) (g1 + (g2 - g1) * ratio);
|
||||
int b = (int) (b1 + (b2 - b1) * ratio);
|
||||
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class BrowserUtil {
|
||||
|
||||
public static void openUrl(String url) {
|
||||
try {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
return;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
try {
|
||||
if (os.contains("win")) {
|
||||
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
|
||||
} else if (os.contains("mac")) {
|
||||
Runtime.getRuntime().exec("open " + url);
|
||||
} else if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
|
||||
Runtime.getRuntime().exec("xdg-open " + url);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
public class ClipboardUtil {
|
||||
|
||||
public static void copyToClipboard(String text) {
|
||||
StringSelection selection = new StringSelection(text);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(selection, null);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class JuiceAgentFacade {
|
||||
|
||||
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.juiceagent.api.JuiceAgent",
|
||||
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 JuiceAgentFacade() {}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class MathUtil {
|
||||
|
||||
private static final int MAX_ATTEMPTS = 8;
|
||||
|
||||
public static double generateNoise(double min, double max) {
|
||||
double mean = (min + max) / 2.0;
|
||||
double range = max - min;
|
||||
double stdDev = Math.max(1.0, range / 3.0);
|
||||
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
|
||||
for (int i = 0; i < MAX_ATTEMPTS; i++) {
|
||||
double value = random.nextGaussian() * stdDev + mean;
|
||||
if (value >= min && value <= max) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// fallback: clamp gaussian
|
||||
return clamp(random.nextGaussian() * stdDev + mean, min, max);
|
||||
}
|
||||
|
||||
public static double clamp(double value, double min, double max) {
|
||||
return Math.max(min, Math.min(max, value));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ReflectionUtil {
|
||||
|
||||
private static Field rightClickDelayField;
|
||||
|
||||
static {
|
||||
try {
|
||||
rightClickDelayField = Minecraft.class.getDeclaredField("rightClickDelayTimer");
|
||||
rightClickDelayField.setAccessible(true);
|
||||
} catch (Exception e) {
|
||||
System.out.println("[ReflectionUtil] Failed to get rightClickDelayTimer field");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getRightClickDelay() throws IllegalAccessException {
|
||||
return rightClickDelayField.getInt(Minecraft.getMinecraft());
|
||||
}
|
||||
|
||||
public static void setRightClickDelay(int value) throws IllegalAccessException {
|
||||
rightClickDelayField.setInt(Minecraft.getMinecraft(), value);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package cn.xiaozhou233.orangex.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Session;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class SessionUtil {
|
||||
public static boolean setSession(Session session) {
|
||||
try {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Field sessionField = Minecraft.class.getDeclaredField("session");
|
||||
sessionField.setAccessible(true);
|
||||
sessionField.set(mc, session);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
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.
File diff suppressed because it is too large.
Load diff
@@ -1,93 +0,0 @@
|
||||
Copyright 2024 The Montserrat.Git Project Authors (https://github.com/JulietaUla/Montserrat.git)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -1 +0,0 @@
|
||||
Version 1.0.0 Demo
|
||||
-153
@@ -1,156 +1,3 @@
|
||||
// ░██████ ░██ ░██
|
||||
// ░██ ░██ ░██ ░██
|
||||
//░██ ░██ ░██░████ ░██████ ░████████ ░████████ ░███████ ░██░██
|
||||
//░██ ░██ ░███ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░███
|
||||
//░██ ░██ ░██ ░███████ ░██ ░██ ░██ ░██ ░█████████ ░██░██
|
||||
// ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░██ ░███ ░██ ░██ ░██
|
||||
// ░██████ ░██ ░█████░██ ░██ ░██ ░█████░██ ░███████ ░██ ░██
|
||||
// ░██
|
||||
// ░███████
|
||||
//
|
||||
|
||||
plugins {
|
||||
id 'lifecycle-base'
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Variables
|
||||
// ============================
|
||||
def JuiceAgentJar = "libraries/JuiceAgent-API-1.4.0+build.1.jar"
|
||||
def outDir = layout.projectDirectory.dir("out")
|
||||
def tmpDir = layout.projectDirectory.dir("out/tmp")
|
||||
def runBatFile = layout.projectDirectory.file("out/run.bat")
|
||||
|
||||
// ============================
|
||||
// Clean output directory
|
||||
// ============================
|
||||
tasks.register('cleanOut', Delete) {
|
||||
delete("$outDir/Injector.jar", "$outDir/injection.zip", runBatFile)
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Build injection
|
||||
// ============================
|
||||
tasks.register("buildInjection", Copy) {
|
||||
group = 'build'
|
||||
description = 'Build injection and copy all required files to tmp directory'
|
||||
|
||||
// Incremental build: only copy changed files
|
||||
outputs.upToDateWhen { false } // optional: force always check, can remove for caching
|
||||
|
||||
dependsOn(
|
||||
project(':OrangeX').tasks.named('shadowJar'),
|
||||
project(':Loader').tasks.named('shadowJar')
|
||||
)
|
||||
|
||||
into(tmpDir)
|
||||
|
||||
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(JuiceAgentJar)) {
|
||||
rename { 'JuiceAgent.jar' }
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Package injection into injection.zip
|
||||
// ============================
|
||||
tasks.register("packInjection", Zip) {
|
||||
group = 'build'
|
||||
description = 'Package all files from tmp into injection.zip'
|
||||
|
||||
dependsOn(tasks.named("buildInjection"))
|
||||
|
||||
destinationDirectory.set(outDir)
|
||||
archiveFileName.set("injection.zip")
|
||||
|
||||
from(tmpDir)
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Build Injector.jar
|
||||
// ============================
|
||||
tasks.register("buildInjector", Jar) {
|
||||
group = 'build'
|
||||
description = 'Build Injector.jar including injection.zip and subproject jar'
|
||||
|
||||
dependsOn(
|
||||
tasks.named("packInjection"),
|
||||
project(':Injector').tasks.named('shadowJar')
|
||||
)
|
||||
|
||||
destinationDirectory.set(outDir)
|
||||
archiveFileName.set("Injector.jar")
|
||||
|
||||
from(zipTree(project(':Injector').tasks.named('shadowJar').map { it.archiveFile })) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes('Main-Class': 'cn.xiaozhou233.orangex.injector.Injector')
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Generate run.bat
|
||||
// ============================
|
||||
tasks.register("generateRunBat") {
|
||||
group = 'build'
|
||||
description = 'Generate run.bat to run Injector.jar'
|
||||
|
||||
dependsOn(tasks.named("buildInjector"))
|
||||
|
||||
outputs.file(runBatFile)
|
||||
|
||||
doLast {
|
||||
runBatFile.asFile.text =
|
||||
"""@echo off
|
||||
java -jar Injector.jar
|
||||
pause
|
||||
"""
|
||||
println("run.bat generated in 'out/' folder")
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Main build task
|
||||
// ============================
|
||||
tasks.register("buildAll") {
|
||||
dependsOn(tasks.named("generateRunBat"))
|
||||
|
||||
doFirst {
|
||||
println("Building OrangeX-Client...")
|
||||
}
|
||||
|
||||
doLast {
|
||||
println("Build finished! Injector.jar, injection.zip, and run.bat are in 'out/' folder.")
|
||||
}
|
||||
}
|
||||
|
||||
// ============================
|
||||
// Task execution order chain
|
||||
// ============================
|
||||
tasks.named("buildInjection") {
|
||||
dependsOn(tasks.named("cleanOut"))
|
||||
}
|
||||
|
||||
tasks.named("packInjection") {
|
||||
dependsOn(tasks.named("buildInjection"))
|
||||
}
|
||||
|
||||
tasks.named("buildInjector") {
|
||||
dependsOn(tasks.named("packInjection"))
|
||||
}
|
||||
|
||||
tasks.named("generateRunBat") {
|
||||
dependsOn(tasks.named("buildInjector"))
|
||||
}
|
||||
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.
@@ -1,11 +0,0 @@
|
||||
[JuiceAgent]
|
||||
JuiceAgentAPIJarPath = ""
|
||||
JuiceAgentNativePath = ""
|
||||
|
||||
[Entry]
|
||||
EntryJarPath = ""
|
||||
EntryClass = "cn.xiaozhou233.orangex.loader.Loader"
|
||||
EntryMethod = "start"
|
||||
|
||||
[Runtime]
|
||||
InjectionDir = ""
|
||||
@@ -1,6 +1,2 @@
|
||||
rootProject.name = 'OrangeX-Client'
|
||||
include 'Minecraft'
|
||||
include 'OrangeX'
|
||||
include 'Loader'
|
||||
include 'Injector'
|
||||
|
||||
Reference in new issue
Block a user