From d66b0a9354da383f2b305e279f7b5455c19aefd0 Mon Sep 17 00:00:00 2001 From: tanishisherewithhh <120117618+tanishisherewithhh@users.noreply.github.com> Date: Thu, 5 Sep 2024 21:27:17 +0530 Subject: [PATCH] And I was wondering why velocity wasnt working. Also we now save and load friends. --- examples/AutoRepair.lua | 2 +- .../module/modules/movement/Velocity.java | 6 ++- .../heliosclient/system/config/Config.java | 43 ++++++++++++++++--- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/examples/AutoRepair.lua b/examples/AutoRepair.lua index 254224c2..92278141 100644 --- a/examples/AutoRepair.lua +++ b/examples/AutoRepair.lua @@ -54,7 +54,7 @@ function autoRepair() local expThrower = luajava.cast(luajava.bindClass(" dev.heliosclient.module.modules.player.ExpThrower"), module_) -- Uncomment this line to auto change the swapback setting to true. - expThrower.swapBack.value = true + --expThrower.swapBack.value = true if needsRepair and not repairing then -- Turn on ExpThrower module diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Velocity.java b/src/main/java/dev/heliosclient/module/modules/movement/Velocity.java index e84dc9b3..d79ae317 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Velocity.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Velocity.java @@ -89,7 +89,6 @@ public Velocity() { super("Velocity", "Cancels knockback and pushes by environment", Categories.MOVEMENT); addSettingGroup(sgGeneral); addQuickSettings(sgGeneral.getSettings()); - } @SubscribeEvent @@ -103,8 +102,9 @@ public void onPacketReceive(PacketEvent.RECEIVE event) { if ((mc.player.isTouchingWater() || mc.player.isSubmergedInWater() || mc.player.isInLava()) && pauseInWater.value) return; + if (event.packet instanceof EntityVelocityUpdateS2CPacket pac) { - if (pac.getId() != mc.player.getId()) { + if (pac.getId() == mc.player.getId()) { switch ((Mode) mode.getOption()) { case Matrix -> { if (!flag) { @@ -138,11 +138,13 @@ public void onPacketReceive(PacketEvent.RECEIVE event) { ((AccessorExplosionS2CPacket) explosionPac).setVelocityX(0); ((AccessorExplosionS2CPacket) explosionPac).setVelocityY(0); ((AccessorExplosionS2CPacket) explosionPac).setVelocityZ(0); + ccTickCoolDown = -1; } case Custom -> { ((AccessorExplosionS2CPacket) explosionPac).setVelocityX((float) (((AccessorExplosionS2CPacket) explosionPac).getVelocityX() * horizontal.value / 100f)); ((AccessorExplosionS2CPacket) explosionPac).setVelocityZ((float) (((AccessorExplosionS2CPacket) explosionPac).getVelocityZ() * horizontal.value / 100f)); ((AccessorExplosionS2CPacket) explosionPac).setVelocityY((float) (((AccessorExplosionS2CPacket) explosionPac).getVelocityY() * vertical.value / 100f)); + ccTickCoolDown = -1; } case Grim -> { ((AccessorExplosionS2CPacket) explosionPac).setVelocityX(0); diff --git a/src/main/java/dev/heliosclient/system/config/Config.java b/src/main/java/dev/heliosclient/system/config/Config.java index 4b37ac47..799507b5 100644 --- a/src/main/java/dev/heliosclient/system/config/Config.java +++ b/src/main/java/dev/heliosclient/system/config/Config.java @@ -5,14 +5,12 @@ import dev.heliosclient.hud.HudElement; import dev.heliosclient.hud.HudElementData; import dev.heliosclient.hud.HudElementList; -import dev.heliosclient.managers.CategoryManager; -import dev.heliosclient.managers.CommandManager; -import dev.heliosclient.managers.HudManager; -import dev.heliosclient.managers.ModuleManager; +import dev.heliosclient.managers.*; import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.Setting; import dev.heliosclient.module.settings.SettingGroup; +import dev.heliosclient.system.Friend; import dev.heliosclient.ui.clickgui.CategoryPane; import dev.heliosclient.ui.clickgui.ClickGUIScreen; import dev.heliosclient.ui.clickgui.hudeditor.HudCategoryPane; @@ -20,6 +18,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; @@ -48,6 +47,7 @@ public void init() { otherConfigManager = new ConfigManager(HeliosClient.SAVE_FOLDER.getAbsolutePath(), "config"); otherConfigManager.createAndAdd("hud"); + otherConfigManager.createAndAdd("friends"); // loadConfigManagers(); @@ -64,6 +64,7 @@ public void saveEverything() { otherConfigManager.save(true); otherConfigManager.getSubConfig("hud").save(true); + otherConfigManager.getSubConfig("friends").save(true); moduleConfigManager.save(true); } @@ -71,12 +72,14 @@ public void writeConfigData() { writeClientConfig(); writeHudConfig(); writeModuleConfig(); + writeFriendConfig(); } public void load() { loadClientConfigModules(); loadHudElements(); loadModules(); + loadFriendConfig(); if (ClickGUIScreen.INSTANCE == null) { ClickGUIScreen.INSTANCE = new ClickGUIScreen(); @@ -117,6 +120,13 @@ public void loadConfigManagers() { } else { otherConfigManager.getSubConfig("hud").load(); } + + if (otherConfigManager.checkIfEmpty("friends")) { + writeFriendConfig(); + otherConfigManager.getSubConfig("friends").save(true); + } else { + otherConfigManager.getSubConfig("friends").load(); + } } public void loadModules() { @@ -195,7 +205,7 @@ public void writeClientConfig() { } /** - * Gets the configuration for the client. + * Gets the hud configuration for the client. */ public void writeHudConfig() { try { @@ -217,6 +227,29 @@ public void writeHudConfig() { LOGGER.error("Error occurred while getting Hud config.", e); } } + public void writeFriendConfig() { + try { + List friends = new ArrayList<>(); + + for(Friend friend: FriendManager.getFriends()){ + friends.add(friend.playerName()); + } + otherConfigManager.getSubConfig("friends").getWriteData().put("friends", friends); + } catch (Exception e) { + LOGGER.error("Error occurred while getting Hud config.", e); + } + } + public void loadFriendConfig() { + try { + List friends = (List) otherConfigManager.getSubConfig("friends").getReadData().get("friends"); + + for(String friend: friends){ + FriendManager.addFriend(new Friend(friend)); + } + } catch (Exception e) { + LOGGER.error("Error occurred while getting Hud config.", e); + } + } // Generates the default configuration for the modules.