From dc3ee158402ec983297e167e7b6e29a8d8c51cbe Mon Sep 17 00:00:00 2001 From: tanishisherewithhh <120117618+tanishisherewithhh@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:34:49 +0530 Subject: [PATCH] Bug hunting and readme changes. Force-multiplier for polygon mesh renderer. --- README.md | 4 +- .../java/dev/heliosclient/HeliosClient.java | 2 - .../hud/hudelements/SpeedHud.java | 5 +- .../module/modules/render/GUI.java | 21 +++++ .../module/sysmodules/ClickGUI.java | 5 +- .../dev/heliosclient/system/DiscordRPC.java | 86 +++++++++---------- .../ui/clickgui/ModuleButton.java | 9 +- .../gui/PolygonMeshPatternRenderer.java | 2 + .../ui/clickgui/settings/SettingsScreen.java | 2 + 9 files changed, 80 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 05a79b3..bc76f0f 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,12 @@ To submit a bug open an issue in this repository. Before doing so please assure ## Known issues - Buggy modules like Tick-Shift, PacketMine. -- Incomplete modules like Phase. +- Incomplete modules like Phase, Fucker, InventoryTweaks. - ~~HudElements don't resize to their proper locations sometimes.~~ - Scripting System (WIP). - Lack of combat and some important utility modules. - No Baritone Integration -- No AltManager +- ~~No AltManager~~ No AltManager GUI - Lack of commands - Lack of shaders (Neither of the current contributors know much good about GLSL) diff --git a/src/main/java/dev/heliosclient/HeliosClient.java b/src/main/java/dev/heliosclient/HeliosClient.java index 89c2570..8924ea3 100644 --- a/src/main/java/dev/heliosclient/HeliosClient.java +++ b/src/main/java/dev/heliosclient/HeliosClient.java @@ -150,9 +150,7 @@ public void onInitialize() { registerListeners(); - LOGGER.info("Downloading and extracting Discord Native Library-2.5.6..."); DiscordRPC.INSTANCE.init(); - LOGGER.info("Downloading Completed..."); LuaScriptManager.getScripts(); diff --git a/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java b/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java index e1d812b..f270647 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java @@ -16,7 +16,8 @@ public SpeedHud() { super(DATA); this.width = 40; this.height = Math.round(Renderer2D.getStringHeight()); - } public static HudElementData DATA = new HudElementData<>("Player Speed", "Shows player speed in blocks per second", SpeedHud::new); + } + public static HudElementData DATA = new HudElementData<>("Player Speed", "Shows player speed in blocks per second", SpeedHud::new); @Override public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { @@ -24,7 +25,7 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { String text = "Speed: "; String value = ColorUtils.gray + MathUtils.round(moveSpeed(), 2); this.width = Math.round(Renderer2D.getStringWidth(text + value)); - Renderer2D.drawString(drawContext.getMatrices(), text + value, this.x + 1, this.y, ColorManager.INSTANCE.hudColor); + Renderer2D.drawString(drawContext.getMatrices(), text + value, this.x, this.y, ColorManager.INSTANCE.hudColor); } private double moveSpeed() { diff --git a/src/main/java/dev/heliosclient/module/modules/render/GUI.java b/src/main/java/dev/heliosclient/module/modules/render/GUI.java index c5ad214..1f89cc6 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/GUI.java +++ b/src/main/java/dev/heliosclient/module/modules/render/GUI.java @@ -79,6 +79,13 @@ public class GUI extends Module_ { .defaultValue(new Color(17, 18, 19, 100)) .build() ); + public BooleanSetting textHighlight = sgColors.add(new BooleanSetting.Builder() + .name("Module text highlight when active") + .description("If this is on, then instead of the whole button, only the text will be highlighted with a glow if the module is on.") + .value(false) + .onSettingChange(this) + .build() + ); public BooleanSetting categoryBorder = sgColors.add(new BooleanSetting.Builder() .name("Category Border") .description("Render the border around category") @@ -133,6 +140,7 @@ public class GUI extends Module_ { .description("Number of points") .min(10) .max(400) + .value(75d) .defaultValue(75) .roundingPlace(0) .shouldRender(()->coolVisuals.value) @@ -161,6 +169,17 @@ public class GUI extends Module_ { .onSettingChange(this) .build() ); + public DoubleSetting mouseForce = sgVisuals.add(new DoubleSetting.Builder() + .name("Force Multiplier of the mouse") + .description("The force multiplier applied by the mouse on the mesh so they move faster") + .min(0) + .max(5) + .defaultValue(1.3) + .roundingPlace(1) + .shouldRender(()->coolVisuals.value) + .onSettingChange(this) + .build() + ); public GUI() { super("GUI", "The HeliosClient GUI settings.", Categories.RENDER); @@ -183,6 +202,7 @@ public void onSettingChange(Setting setting) { PolygonMeshPatternRenderer.INSTANCE.maskGradient = gradientType.get(); PolygonMeshPatternRenderer.INSTANCE.radius = (float) dotRadius.value; PolygonMeshPatternRenderer.INSTANCE.MAX_DISTANCE = (float) lineMaxLength.value; + PolygonMeshPatternRenderer.INSTANCE.MOUSE_FORCE_MULTIPLIER = mouseForce.getFloat(); if(setting == polygonPoints){ PolygonMeshPatternRenderer.INSTANCE.setNumOfPoints(polygonPoints.getInt()); @@ -198,6 +218,7 @@ public void onLoad() { PolygonMeshPatternRenderer.INSTANCE.maskGradient = gradientType.get(); PolygonMeshPatternRenderer.INSTANCE.radius = (float) dotRadius.value; PolygonMeshPatternRenderer.INSTANCE.MAX_DISTANCE = (float) lineMaxLength.value; + PolygonMeshPatternRenderer.INSTANCE.MOUSE_FORCE_MULTIPLIER = mouseForce.getFloat(); PolygonMeshPatternRenderer.INSTANCE.setNumOfPoints(polygonPoints.getInt()); } diff --git a/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java b/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java index 72a4707..9cdb1d4 100644 --- a/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java +++ b/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java @@ -87,9 +87,10 @@ public class ClickGUI extends Module_ { .name("ModuleButton Height") .description("ModuleButton Height for the ClickGUI") .onSettingChange(this) - .defaultValue(16) .max(50) .min(1) + .defaultValue(16) + .value(16d) .roundingPlace(0) .build() ); @@ -413,7 +414,7 @@ public void onSettingChange(Setting setting) { } //Config changes - if (setting == switchConfigs) { + if (setting == switchConfigs && switchConfigs.getOption() != null) { // Change the file name we want to load HeliosClient.CONFIG.writeModuleConfig(); HeliosClient.CONFIG.moduleConfigManager.switchConfig(switchConfigs.getOption().toString(), true); diff --git a/src/main/java/dev/heliosclient/system/DiscordRPC.java b/src/main/java/dev/heliosclient/system/DiscordRPC.java index bcca89a..33d1b0c 100644 --- a/src/main/java/dev/heliosclient/system/DiscordRPC.java +++ b/src/main/java/dev/heliosclient/system/DiscordRPC.java @@ -33,62 +33,33 @@ public class DiscordRPC { private Core discordCore; private Activity activity; - public void init() { - try { - File sdkFile = this.getSDKLibrary(); - - // Initialize the Core with the existing or downloaded file - - File tempJNIDir = new File(System.getProperty("java.io.tmpdir") + "/java", "jni"); - - if (!tempJNIDir.isDirectory() && !tempJNIDir.mkdir()) - throw new RuntimeException(new IOException("Cannot create temporary JNI directory")); - - tempJNIDir.deleteOnExit(); - - initInternal(sdkFile, tempJNIDir); - - } catch (IOException | RuntimeException e) { - AnimationUtils.addErrorToast("Discord Core init failed. Check logs for details.", false, 1500); - HeliosClient.LOGGER.error("Discord Core init failed.", e); - } - } - /** * The {@link Core#init(File, File)} is not memory efficient and creates stores new "discord_game_sdk_jni" for every run. * It builds up space really fast and I got to `80mb` in 40 runs. - *

+ *

* So in here, we are returning if the file in the temp directory already exists. */ - private static void initInternal(File discordLibrary, File tempDir) - { + private static void initInternal(File discordLibrary, File tempDir) { String name = "discord_game_sdk_jni"; String osName = System.getProperty("os.name").toLowerCase(Locale.ROOT); String arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT); String objectName; - if(osName.contains("windows")) - { + if (osName.contains("windows")) { osName = "windows"; objectName = name + ".dll"; // the Discord native library needs to be loaded before our JNI library on Windows System.load(discordLibrary.getAbsolutePath()); - } - else if(osName.contains("linux")) - { + } else if (osName.contains("linux")) { osName = "linux"; objectName = "lib" + name + ".so"; - } - else if(osName.contains("mac os")) - { + } else if (osName.contains("mac os")) { osName = "macos"; objectName = "lib" + name + ".dylib"; - } - else - { - throw new RuntimeException("cannot determine OS type: "+osName); + } else { + throw new RuntimeException("cannot determine OS type: " + osName); } /* @@ -96,11 +67,11 @@ Some systems (e.g. Mac OS X) might report the architecture as "x86_64" instead o While it would be possible to store the MacOS dylib as "x86_x64" instead of "amd64", I personally prefer to keep the system architecture consistent. */ - if(arch.equals("x86_64")) + if (arch.equals("x86_64")) arch = "amd64"; File temp = new File(tempDir, objectName); - if(temp.exists()){ + if (temp.exists()) { System.load(temp.getAbsolutePath()); Core.initDiscordNative(discordLibrary.getAbsolutePath()); LOGGER.info("(DiscordRPC) JNI directory exists"); @@ -108,23 +79,46 @@ Some systems (e.g. Mac OS X) might report the architecture as "x86_64" instead o return; } - String path = "/native/"+osName+"/"+arch+"/"+objectName; + String path = "/native/" + osName + "/" + arch + "/" + objectName; InputStream in = Core.class.getResourceAsStream(path); - if(in == null) - throw new RuntimeException(new FileNotFoundException("cannot find native library at "+path)); + if (in == null) + throw new RuntimeException(new FileNotFoundException("cannot find native library at " + path)); - try - { + try { Files.copy(in, temp.toPath()); - } - catch(IOException e) - { + } catch (IOException e) { throw new RuntimeException(e); } System.load(temp.getAbsolutePath()); Core.initDiscordNative(discordLibrary.getAbsolutePath()); } + + public void init() { + HeliosExecutor.execute(() -> { + LOGGER.info("Downloading and extracting Discord Native Library-2.5.6... on a separate thread"); + try { + File sdkFile = this.getSDKLibrary(); + + // Initialize the Core with the existing or downloaded file + + File tempJNIDir = new File(System.getProperty("java.io.tmpdir") + "/java", "jni"); + + if (!tempJNIDir.isDirectory() && !tempJNIDir.mkdir()) + throw new RuntimeException(new IOException("Cannot create temporary JNI directory")); + + tempJNIDir.deleteOnExit(); + + initInternal(sdkFile, tempJNIDir); + + LOGGER.info("Downloading Completed..."); + } catch (IOException | RuntimeException e) { + AnimationUtils.addErrorToast("Discord Core init failed. Check logs for details.", false, 1500); + HeliosClient.LOGGER.error("Discord Core init failed.", e); + } + }); + } + /** * This is the modified version of {@link Core#downloadDiscordLibrary()} * In this version, it checks if the required file already exists in the Temp folder, diff --git a/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java b/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java index b73f55f..091f5d2 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java @@ -77,6 +77,7 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float x, int if (!shouldRender) return; + GUI gui = ModuleManager.get(GUI.class); if (hitBox.contains(mouseX, mouseY)) { hoverAnimationTimer = Math.min(hoverAnimationTimer + 1, 20); } else { @@ -85,8 +86,8 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float x, int // Get the width and height of the module name int moduleNameHeight = (int) Renderer2D.getFxStringHeight(module.name) - 1; - Color fillColorStart = module.isActive() ? ColorManager.INSTANCE.primaryGradientStart : ColorUtils.changeAlpha(ModuleManager.get(GUI.class).buttonColor.getColor(), 100); - Color fillColorEnd = module.isActive() ? ColorManager.INSTANCE.primaryGradientEnd : ColorUtils.changeAlpha(ModuleManager.get(GUI.class).buttonColor.getColor(), 100); + Color fillColorStart = module.isActive() && !gui.textHighlight.value? ColorManager.INSTANCE.primaryGradientStart : ColorUtils.changeAlpha(gui.buttonColor.getColor(), 100); + Color fillColorEnd = module.isActive() && !gui.textHighlight.value ? ColorManager.INSTANCE.primaryGradientEnd : ColorUtils.changeAlpha(gui.buttonColor.getColor(), 100); Color blendedColor = ColorUtils.blend(fillColorStart, fillColorEnd, 1 / 2f); int textY = y + (height - moduleNameHeight) / 2; @@ -102,6 +103,10 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float x, int drawGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), fillColorStart, fillColorEnd, fillColorEnd, fillColorStart, x + 1, y + height, width, boxHeight + 2, HeliosClient.CLICKGUI.guiRoundness.getInt()); Renderer2D.stopScaling(drawContext.getMatrices()); } + + if(module.isActive() && gui.textHighlight.value) { + Renderer2D.drawBlurredShadow(drawContext.getMatrices(), x + 2, textY, Renderer2D.getFxStringWidth(module.name) + 1, moduleNameHeight, 9, ColorManager.INSTANCE.primaryGradientStart); + } Renderer2D.drawFixedString(drawContext.getMatrices(), module.name, x + 3, textY, ColorManager.INSTANCE.defaultTextColor()); if (hitBox.contains(mouseX, mouseY)) { diff --git a/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java b/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java index f7685da..1cb42d6 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/gui/PolygonMeshPatternRenderer.java @@ -13,6 +13,7 @@ public class PolygonMeshPatternRenderer { private int NUM_POINTS = 75; private Point[] points = new Point[NUM_POINTS]; public float MAX_DISTANCE = 75.0f; + public float MOUSE_FORCE_MULTIPLIER = 1f; public float radius = 2f; public GradientManager.Gradient maskGradient = GradientManager.getGradient("Linear2D"); @@ -80,6 +81,7 @@ void move(int mouseX, int mouseY) { float dy = y - mouseY; float distance = (float) Math.sqrt(dx * dx + dy * dy); float force = Math.max(0, 100 - distance) / 5000; + force *= MOUSE_FORCE_MULTIPLIER; xSpeed += force * dx / distance; ySpeed += force * dy / distance; diff --git a/src/main/java/dev/heliosclient/ui/clickgui/settings/SettingsScreen.java b/src/main/java/dev/heliosclient/ui/clickgui/settings/SettingsScreen.java index 444ce8f..9ab4b88 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/settings/SettingsScreen.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/settings/SettingsScreen.java @@ -81,6 +81,8 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) super.renderBackgroundTexture(drawContext); } + adjustWindowHeight(); + if(GUI.coolVisuals()){ PolygonMeshPatternRenderer.INSTANCE.render(drawContext.getMatrices(),mouseX,mouseY); }