Skip to content

Commit

Permalink
And I was wondering why velocity wasnt working. Also we now save and …
Browse files Browse the repository at this point in the history
…load friends.
  • Loading branch information
tanishisherewithhh committed Sep 5, 2024
1 parent b38fb09 commit d66b0a9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/AutoRepair.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public Velocity() {
super("Velocity", "Cancels knockback and pushes by environment", Categories.MOVEMENT);
addSettingGroup(sgGeneral);
addQuickSettings(sgGeneral.getSettings());

}

@SubscribeEvent
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
43 changes: 38 additions & 5 deletions src/main/java/dev/heliosclient/system/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
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;
import dev.heliosclient.util.MathUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -48,6 +47,7 @@ public void init() {

otherConfigManager = new ConfigManager(HeliosClient.SAVE_FOLDER.getAbsolutePath(), "config");
otherConfigManager.createAndAdd("hud");
otherConfigManager.createAndAdd("friends");


// loadConfigManagers();
Expand All @@ -64,19 +64,22 @@ public void saveEverything() {

otherConfigManager.save(true);
otherConfigManager.getSubConfig("hud").save(true);
otherConfigManager.getSubConfig("friends").save(true);
moduleConfigManager.save(true);
}

public void writeConfigData() {
writeClientConfig();
writeHudConfig();
writeModuleConfig();
writeFriendConfig();
}

public void load() {
loadClientConfigModules();
loadHudElements();
loadModules();
loadFriendConfig();

if (ClickGUIScreen.INSTANCE == null) {
ClickGUIScreen.INSTANCE = new ClickGUIScreen();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -195,7 +205,7 @@ public void writeClientConfig() {
}

/**
* Gets the configuration for the client.
* Gets the hud configuration for the client.
*/
public void writeHudConfig() {
try {
Expand All @@ -217,6 +227,29 @@ public void writeHudConfig() {
LOGGER.error("Error occurred while getting Hud config.", e);
}
}
public void writeFriendConfig() {
try {
List<String> 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<String> friends = (List<String>) 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.
Expand Down

0 comments on commit d66b0a9

Please sign in to comment.