From 52cdbbe8780f56bafa14d95d7354a8f3feca05cd Mon Sep 17 00:00:00 2001 From: tanishisherewith <120117618+tanishisherewithhh@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:32:07 +0530 Subject: [PATCH] Lots of changes, as follows: - Refactors and reformats - More gradients - New splash-screen - Deleted some files - Fixed SessionIDAccount login - Added new settings to Anti-Totem - Added PreLaunchMain - Simplified and optimised Capes - Fixed HoleUtils causing main thread to pause when joining few servers - Added Renderer2D methods, changed settings, more customisation - More default Hud-Element settings - Added Chunk-Trails in Radar - Fixed Rotations, and many more unknown changes. --- .../java/dev/heliosclient/HeliosClient.java | 34 +- .../java/dev/heliosclient/PreLaunchMain.java | 11 + .../dev/heliosclient/altmanager/Account.java | 4 +- .../altmanager/accounts/SessionIDAccount.java | 68 +++- .../accounts/TheAlteningAccount.java | 7 +- .../heliosclient/command/commands/Bind.java | 2 +- .../heliosclient/command/commands/Friend.java | 2 +- .../heliosclient/command/commands/Help.java | 2 +- .../command/commands/LoadScript.java | 2 +- .../heliosclient/command/commands/Prefix.java | 2 +- .../command/commands/ReloadScripts.java | 2 +- .../heliosclient/event/SubscribeEvent.java | 4 +- .../heliosclient/event/events/TickEvent.java | 6 + .../events/render/EntityLabelRenderEvent.java | 6 +- .../java/dev/heliosclient/hud/HudElement.java | 138 ++++++--- .../hud/hudelements/ArmorHud.java | 3 +- .../hud/hudelements/ClockHud.java | 2 +- .../hud/hudelements/CompactData.java | 2 +- .../hud/hudelements/CoordinatesHud.java | 14 +- .../hud/hudelements/DirectionHud.java | 2 +- .../dev/heliosclient/hud/hudelements/Fps.java | 2 +- .../hud/hudelements/KeyBindsHud.java | 4 +- .../hud/hudelements/LagTimerHud.java | 2 +- .../hud/hudelements/ModuleList.java | 2 +- .../heliosclient/hud/hudelements/Ping.java | 2 +- .../heliosclient/hud/hudelements/Radar.java | 243 ++++++++++++--- .../hud/hudelements/ScaffoldCount.java | 10 +- .../hud/hudelements/SpeedHud.java | 6 +- .../dev/heliosclient/hud/hudelements/Tps.java | 4 +- .../hud/hudelements/WelcomeHud.java | 2 +- .../heliosclient/managers/CapeManager.java | 40 +-- .../heliosclient/managers/ColorManager.java | 81 +++-- .../heliosclient/managers/EventManager.java | 2 +- .../mixin/CapeFeatureRendererMixin.java | 5 +- .../heliosclient/mixin/GameRendererMixin.java | 7 + .../mixin/MinecraftClientMixin.java | 16 +- .../heliosclient/mixin/MixinPlayerEntity.java | 2 +- .../heliosclient/mixin/MixinSplashScreen.java | 154 +++++----- .../mixin/MixinWorldRenderer.java | 2 +- .../module/modules/chat/ChatHighlight.java | 2 +- .../module/modules/chat/Spammer.java | 2 +- .../module/modules/combat/AimAssist.java | 2 +- .../module/modules/combat/AutoTotem.java | 81 ++++- .../module/modules/combat/BowSpam.java | 2 +- .../module/modules/combat/TriggerBot.java | 6 +- .../module/modules/misc/CapeModule.java | 22 +- .../module/modules/misc/ChestAura.java | 2 +- .../module/modules/misc/Fucker.java | 7 +- .../modules/misc/NotificationModule.java | 4 + .../module/modules/movement/Scaffold.java | 5 +- .../module/modules/movement/Sprint.java | 5 +- .../module/modules/movement/TargetStrafe.java | 51 +-- .../module/modules/player/AutoEat.java | 2 +- .../module/modules/player/FakeLag.java | 6 +- .../module/modules/render/BlockESP.java | 2 +- .../module/modules/render/BlockSelection.java | 2 +- .../module/modules/render/BreakIndicator.java | 2 +- .../module/modules/render/ESP.java | 2 +- .../module/modules/render/Fullbright.java | 2 +- .../module/modules/render/GUI.java | 2 +- .../module/modules/render/HoleESP.java | 10 +- .../module/modules/render/LightLevelESP.java | 2 +- .../module/modules/render/LogOutSpot.java | 2 +- .../module/modules/render/NameTags.java | 13 +- .../module/modules/render/StorageESP.java | 2 +- .../module/modules/render/Test.java | 12 + .../render/hiteffect/HitEffectParticle.java | 2 +- .../module/modules/world/PacketMine.java | 39 ++- .../module/modules/world/PaletteExploit.java | 14 +- .../module/modules/world/TNTIgnite.java | 4 +- .../module/modules/world/painter/Painter.java | 2 +- .../module/settings/CycleSetting.java | 10 +- .../module/settings/DoubleSetting.java | 2 +- .../module/settings/DropDownSetting.java | 9 +- .../module/settings/GradientSetting.java | 14 +- .../heliosclient/module/settings/Option.java | 38 --- .../module/settings/RGBASetting.java | 2 +- .../heliosclient/module/settings/Setting.java | 2 +- .../module/sysmodules/ClickGUI.java | 44 +-- .../scripting/LuaEventManager.java | 2 +- .../heliosclient/scripting/LuaExecutor.java | 10 +- .../dev/heliosclient/scripting/LuaFile.java | 21 +- .../scripting/LuaFriendlyWrapper.java | 72 ----- .../dev/heliosclient/scripting/LuaLoader.java | 6 +- .../scripting/LuaScriptManager.java | 2 +- .../scripting/libraries/ChatLib.java | 22 +- .../scripting/libraries/PacketLib.java | 5 +- .../scripting/libraries/PlayerLib.java | 27 +- .../heliosclient/system/ConsoleAppender.java | 2 +- .../heliosclient/system/config/Config.java | 50 +-- .../system/config/ConfigManager.java | 7 +- .../ui/HeliosClientInfoScreen.java | 2 +- .../ui/clickgui/ClickGUIScreen.java | 4 +- .../ui/clickgui/ConsoleScreen.java | 24 +- .../ui/clickgui/ModuleButton.java | 2 +- .../heliosclient/ui/clickgui/SearchBar.java | 2 +- .../heliosclient/ui/clickgui/gui/Window.java | 3 +- .../clickgui/hudeditor/HudEditorScreen.java | 3 +- .../clickgui/script/ScriptManagerScreen.java | 2 +- .../notifications/InfoNotification.java | 2 +- .../java/dev/heliosclient/util/ChatUtils.java | 1 + .../util/animation/AnimationUtils.java | 2 +- .../heliosclient/util/blocks/BlockUtils.java | 72 +++-- .../heliosclient/util/blocks/HoleUtils.java | 9 +- .../util/cape/CapeTextureManager.java | 119 ++++--- .../util/{ => color}/ColorUtils.java | 5 +- .../heliosclient/util/entity/TargetUtils.java | 30 +- .../util/fontutils/fxFontRenderer.java | 2 +- .../heliosclient/util/inputbox/InputBox.java | 2 +- .../util/inputbox/MultiLineInputBox.java | 2 +- .../util/inputbox/MultiLineInputBoxOld.java | 4 +- .../util/inputbox/lua/LuaSyntaxManager.java | 2 +- .../dev/heliosclient/util/misc/MapReader.java | 4 + .../util/player/InventoryUtils.java | 15 - .../heliosclient/util/player/PlayerUtils.java | 7 +- .../util/player/RotationUtils.java | 32 +- .../util/render/GradientBlockRenderer.java | 2 +- .../heliosclient/util/render/Renderer2D.java | 290 ++++++++++++++++-- .../heliosclient/util/render/Renderer3D.java | 2 +- .../dev/heliosclient/util/render/Texture.java | 27 -- .../util/render/color/QuadColor.java | 4 +- .../util/render/textures/ClearTexture.java | 5 + .../util/render/textures/ClientTexture.java | 24 +- src/main/resources/fabric.mod.json | 3 + 124 files changed, 1406 insertions(+), 862 deletions(-) create mode 100644 src/main/java/dev/heliosclient/PreLaunchMain.java delete mode 100644 src/main/java/dev/heliosclient/module/settings/Option.java delete mode 100644 src/main/java/dev/heliosclient/scripting/LuaFriendlyWrapper.java rename src/main/java/dev/heliosclient/util/{ => color}/ColorUtils.java (99%) delete mode 100644 src/main/java/dev/heliosclient/util/render/Texture.java diff --git a/src/main/java/dev/heliosclient/HeliosClient.java b/src/main/java/dev/heliosclient/HeliosClient.java index 625d9228..98f2b3db 100644 --- a/src/main/java/dev/heliosclient/HeliosClient.java +++ b/src/main/java/dev/heliosclient/HeliosClient.java @@ -19,8 +19,8 @@ import dev.heliosclient.system.config.Config; import dev.heliosclient.ui.clickgui.ConsoleScreen; import dev.heliosclient.ui.notification.notifications.InfoNotification; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.DamageUtils; import dev.heliosclient.util.player.RotationSimulator; import dev.heliosclient.util.render.Renderer2D; @@ -47,12 +47,15 @@ public class HeliosClient implements ModInitializer, Listener { public static final String versionTag = ColorUtils.gray + "v0.dev"; public static final String MODID = "heliosclient"; private static final TimerUtils configTimer = new TimerUtils(); + public static Config CONFIG = new Config(); public static AddonManager ADDONMANAGER = new AddonManager(); public static ClickGUI CLICKGUI; - public volatile static ConsoleScreen CONSOLE = new ConsoleScreen(); + public static ConsoleScreen CONSOLE = new ConsoleScreen(); public static File SAVE_FOLDER = new File(MC.runDirectory.getPath() + "/heliosclient"); + + //Methods for saving and loading public static void loadConfig() { load(config -> { config.loadEverything(); @@ -69,12 +72,11 @@ public static void loadConfig() { private static void load(Consumer consumer) { //Record time it took - configTimer.startTimer(); consumer.accept(CONFIG); - if (shouldSendNotification() && ModuleManager.get(NotificationModule.class).clientNotification.value) { + if (shouldSendNotification() && ModuleManager.get(NotificationModule.class).displayClientNotifications()) { NotificationManager.addNotification(new InfoNotification("Loading Done", "in: " + configTimer.getElapsedTime() + "s", 1000, SoundUtils.TING_SOUNDEVENT)); } @@ -126,16 +128,18 @@ public void onDisconnect(DisconnectEvent client) { @SubscribeEvent public void onStop(ClientStopEvent client) { saveConfigHook(); + if (DiscordRPC.INSTANCE.isRunning) { DiscordRPC.INSTANCE.stopPresence(); } - CapeManager.capeTextureManager.stopCapeAnimation(); + HeliosExecutor.shutdown(); } @Override public void onInitialize() { - ConsoleAppender consoleAppender = new ConsoleAppender(CONSOLE); + //Create the console appender + ConsoleAppender consoleAppender = new ConsoleAppender(HeliosClient.CONSOLE); LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration config = ctx.getConfiguration(); @@ -145,7 +149,6 @@ public void onInitialize() { LOGGER.info("Initialising Helios Client..."); - ColorManager.createInstance(); CONFIG.init(); CLICKGUI = new ClickGUI(); @@ -155,7 +158,6 @@ public void onInitialize() { LuaScriptManager.getScripts(); - FontManager.INSTANCE.refresh(); ADDONMANAGER.loadAddons(); AddonManager.initializeAddons(); @@ -164,28 +166,16 @@ public void onInitialize() { SoundUtils.registerSounds(); HudElementList.INSTANCE = new HudElementList(); - HeliosExecutor.execute(()->{ - CapeManager.CAPE_NAMES = CapeManager.loadCapes(); - }); + HeliosExecutor.execute(()-> CapeManager.CAPE_NAMES = CapeManager.loadCapes()); HeliosExecutor.execute(HeliosClient::loadConfig); //Saving is handled when the client stops, crashes, the world stops or the player disconnects. //Crash save is handled in MixinCrashReport and configs are saved while switching. - MC.execute(() -> { - while (MC.getWindow() == null) { - try { - Thread.sleep(250); - } catch (InterruptedException e) { - // Cope - } - } - HeliosClient.CLICKGUI.onLoad(); - }); - if (fonts != null) EventManager.postEvent(new FontChangeEvent(fonts)); + } public void registerListeners() { diff --git a/src/main/java/dev/heliosclient/PreLaunchMain.java b/src/main/java/dev/heliosclient/PreLaunchMain.java new file mode 100644 index 00000000..de796a03 --- /dev/null +++ b/src/main/java/dev/heliosclient/PreLaunchMain.java @@ -0,0 +1,11 @@ +package dev.heliosclient; + +import dev.heliosclient.managers.ColorManager; +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; + +public class PreLaunchMain implements PreLaunchEntrypoint { + @Override + public void onPreLaunch() { + ColorManager.createInstance(); + } +} diff --git a/src/main/java/dev/heliosclient/altmanager/Account.java b/src/main/java/dev/heliosclient/altmanager/Account.java index 10d2a613..42b9ac30 100644 --- a/src/main/java/dev/heliosclient/altmanager/Account.java +++ b/src/main/java/dev/heliosclient/altmanager/Account.java @@ -5,7 +5,7 @@ public abstract class Account { private String username; private String password; - //Kindof used while saving. + //Kindof to be used while saving. Idk private boolean wasPreviouslyLoggedIn; public Account(String username, String password, boolean wasPreviouslyLoggedIn) { @@ -36,7 +36,7 @@ public void setPassword(String password) { } public boolean isCracked(){ - return this instanceof CrackedAccount || password == null; + return this instanceof CrackedAccount || (password == null && !username.isEmpty()); } public abstract boolean login(); diff --git a/src/main/java/dev/heliosclient/altmanager/accounts/SessionIDAccount.java b/src/main/java/dev/heliosclient/altmanager/accounts/SessionIDAccount.java index 1e593d43..de00d2d5 100644 --- a/src/main/java/dev/heliosclient/altmanager/accounts/SessionIDAccount.java +++ b/src/main/java/dev/heliosclient/altmanager/accounts/SessionIDAccount.java @@ -1,17 +1,23 @@ package dev.heliosclient.altmanager.accounts; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.authlib.GameProfile; import dev.heliosclient.altmanager.Account; import dev.heliosclient.mixin.AccessorMinecraftClient; -import dev.heliosclient.util.cape.ProfileUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.client.session.Session; -import java.io.IOException; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; import java.util.Optional; import java.util.UUID; public class SessionIDAccount extends Account { private String sessionID; + private GameProfile gameProfile; public SessionIDAccount(String sessionID ) { super("",null); @@ -20,26 +26,58 @@ public SessionIDAccount(String sessionID ) { @Override public boolean login() { - if(this.sessionID != null && !this.sessionID.isEmpty() && this.sessionID.lastIndexOf(":") != -1){ - String uuidString = this.sessionID.substring(this.sessionID.lastIndexOf(':')); - UUID uuid = UUID.fromString(ProfileUtils.insertHyphensToUUID(uuidString)); - String accessToken = this.sessionID.substring(this.sessionID.indexOf(":") + 1,this.sessionID.lastIndexOf(':')); - - Session session; - try { - session = new Session(ProfileUtils.getProfileName(uuidString), uuid,accessToken, Optional.empty(),Optional.empty(), Session.AccountType.MOJANG); - } catch (IOException e){ - session = new Session("", uuid,accessToken, Optional.empty(),Optional.empty(), Session.AccountType.MOJANG); - e.printStackTrace(); - } + if(this.sessionID != null && !this.sessionID.isEmpty()){ + gameProfile = fetchProfileFromSession(sessionID); + Session session = new Session(gameProfile.getName(), gameProfile.getId(),sessionID, Optional.empty(),Optional.empty(), Session.AccountType.MOJANG); ((AccessorMinecraftClient) MinecraftClient.getInstance()).setSession(session); } return false; } + public GameProfile fetchProfileFromSession(String token) { + try { + // Setup HTTP connection + URL url = new URL("https://api.minecraftservices.com/minecraft/profile"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + connection.setRequestProperty("Authorization", "Bearer " + token); + + // Get response + int responseCode = connection.getResponseCode(); + if (responseCode != 200) { + throw new IllegalStateException("Failed to get profile by session, received response code is: " + responseCode); + } + + // Read response + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + StringBuilder response = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + // Parse JSON response + JsonObject jsonResponse = JsonParser.parseString(response.toString()).getAsJsonObject(); + String id = jsonResponse.get("id").getAsString(); + String name = jsonResponse.get("name").getAsString(); + + // Format UUID + UUID uuid = UUID.fromString(id.replaceFirst( + "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", + "$1-$2-$3-$4-$5" + )); + + return new GameProfile(uuid, name); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + @Override public String getDisplayName() { - return ""; + return this.gameProfile == null ? fetchProfileFromSession(sessionID).getName() : this.gameProfile.getName(); } } diff --git a/src/main/java/dev/heliosclient/altmanager/accounts/TheAlteningAccount.java b/src/main/java/dev/heliosclient/altmanager/accounts/TheAlteningAccount.java index e2476747..3e62b22d 100644 --- a/src/main/java/dev/heliosclient/altmanager/accounts/TheAlteningAccount.java +++ b/src/main/java/dev/heliosclient/altmanager/accounts/TheAlteningAccount.java @@ -47,7 +47,7 @@ public String getDisplayName() { } //Original Authors are LiquidBounce mc-authLib in kotlin - //Similar Wiki for the authserver: https://wiki.vg/Legacy_Mojang_Authentication + //Similar Wiki for the auth-server: https://wiki.vg/Legacy_Mojang_Authentication public static class YggdrasilUserAuthentication { private static final String clientIdentifier = UUID.randomUUID().toString(); @@ -89,6 +89,7 @@ public AuthenticationRequest(String username, String password) { this.requestUser = true; } } + public static Session doAuthenticate(String username, String password) throws Exception { if (username == null || username.isBlank()) { throw new IllegalArgumentException("Username cannot be blank"); @@ -163,9 +164,7 @@ public static Session doAuthenticate(String username, String password) throws Ex private record AuthenticationResponse(String accessToken, String clientToken, YggdrasilUserAuthentication.AuthenticationResponse.Profile[] availableProfiles, YggdrasilUserAuthentication.AuthenticationResponse.Profile selectedProfile) { - - private record Profile(String id, String name) { - } + private record Profile(String id, String name) { } } } diff --git a/src/main/java/dev/heliosclient/command/commands/Bind.java b/src/main/java/dev/heliosclient/command/commands/Bind.java index 81557c2a..d39e9e05 100644 --- a/src/main/java/dev/heliosclient/command/commands/Bind.java +++ b/src/main/java/dev/heliosclient/command/commands/Bind.java @@ -6,8 +6,8 @@ import dev.heliosclient.command.ModuleArgumentType; import dev.heliosclient.module.Module_; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.KeyboardUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.command.CommandSource; diff --git a/src/main/java/dev/heliosclient/command/commands/Friend.java b/src/main/java/dev/heliosclient/command/commands/Friend.java index 8d4bef76..7b4f438e 100644 --- a/src/main/java/dev/heliosclient/command/commands/Friend.java +++ b/src/main/java/dev/heliosclient/command/commands/Friend.java @@ -5,7 +5,7 @@ import dev.heliosclient.command.Command; import dev.heliosclient.managers.FriendManager; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.command.CommandSource; public class Friend extends Command { diff --git a/src/main/java/dev/heliosclient/command/commands/Help.java b/src/main/java/dev/heliosclient/command/commands/Help.java index d2456fbb..e63ffd8e 100644 --- a/src/main/java/dev/heliosclient/command/commands/Help.java +++ b/src/main/java/dev/heliosclient/command/commands/Help.java @@ -9,7 +9,7 @@ import dev.heliosclient.module.settings.Setting; import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.command.CommandSource; diff --git a/src/main/java/dev/heliosclient/command/commands/LoadScript.java b/src/main/java/dev/heliosclient/command/commands/LoadScript.java index cf2dc482..469423d5 100644 --- a/src/main/java/dev/heliosclient/command/commands/LoadScript.java +++ b/src/main/java/dev/heliosclient/command/commands/LoadScript.java @@ -6,7 +6,7 @@ import dev.heliosclient.scripting.LuaFile; import dev.heliosclient.scripting.LuaScriptManager; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.command.CommandSource; public class LoadScript extends Command { diff --git a/src/main/java/dev/heliosclient/command/commands/Prefix.java b/src/main/java/dev/heliosclient/command/commands/Prefix.java index adeacdb5..03578aa4 100644 --- a/src/main/java/dev/heliosclient/command/commands/Prefix.java +++ b/src/main/java/dev/heliosclient/command/commands/Prefix.java @@ -5,7 +5,7 @@ import dev.heliosclient.command.Command; import dev.heliosclient.managers.CommandManager; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.command.CommandSource; diff --git a/src/main/java/dev/heliosclient/command/commands/ReloadScripts.java b/src/main/java/dev/heliosclient/command/commands/ReloadScripts.java index 740f8ced..988f991f 100644 --- a/src/main/java/dev/heliosclient/command/commands/ReloadScripts.java +++ b/src/main/java/dev/heliosclient/command/commands/ReloadScripts.java @@ -4,7 +4,7 @@ import dev.heliosclient.command.Command; import dev.heliosclient.scripting.LuaScriptManager; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.command.CommandSource; public class ReloadScripts extends Command { diff --git a/src/main/java/dev/heliosclient/event/SubscribeEvent.java b/src/main/java/dev/heliosclient/event/SubscribeEvent.java index 00370534..e1628f26 100644 --- a/src/main/java/dev/heliosclient/event/SubscribeEvent.java +++ b/src/main/java/dev/heliosclient/event/SubscribeEvent.java @@ -8,7 +8,7 @@ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface SubscribeEvent { - Priority priority() default Priority.NORMAL; + Priority priority() default Priority.NORMAL; // Default priority set to NORMAL enum Priority { LOWEST, @@ -19,5 +19,3 @@ enum Priority { } } - - diff --git a/src/main/java/dev/heliosclient/event/events/TickEvent.java b/src/main/java/dev/heliosclient/event/events/TickEvent.java index 9b55f8cc..d69b0532 100644 --- a/src/main/java/dev/heliosclient/event/events/TickEvent.java +++ b/src/main/java/dev/heliosclient/event/events/TickEvent.java @@ -17,6 +17,12 @@ private TickEvent(){} //Called for every Client tick @LuaEvent("ClientTick") public static class CLIENT extends TickEvent { + public static class PRE extends CLIENT{ + + } + public static class POST extends CLIENT{ + + } } @LuaEvent("WorldTick") diff --git a/src/main/java/dev/heliosclient/event/events/render/EntityLabelRenderEvent.java b/src/main/java/dev/heliosclient/event/events/render/EntityLabelRenderEvent.java index 89c67007..467b37e1 100644 --- a/src/main/java/dev/heliosclient/event/events/render/EntityLabelRenderEvent.java +++ b/src/main/java/dev/heliosclient/event/events/render/EntityLabelRenderEvent.java @@ -2,7 +2,6 @@ import dev.heliosclient.event.Cancelable; import dev.heliosclient.event.Event; -import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; @@ -28,10 +27,7 @@ public static EntityLabelRenderEvent get(Entity entity, Text text, MatrixStack m return INSTANCE; } - private EntityLabelRenderEvent(){ - - } - + private EntityLabelRenderEvent(){} public Entity getEntity() { return INSTANCE.entity; diff --git a/src/main/java/dev/heliosclient/hud/HudElement.java b/src/main/java/dev/heliosclient/hud/HudElement.java index 36bd50e3..3bfe14d4 100644 --- a/src/main/java/dev/heliosclient/hud/HudElement.java +++ b/src/main/java/dev/heliosclient/hud/HudElement.java @@ -12,8 +12,8 @@ import dev.heliosclient.system.UniqueID; import dev.heliosclient.ui.clickgui.gui.HudBox; import dev.heliosclient.ui.clickgui.hudeditor.HudEditorScreen; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.interfaces.ISaveAndLoad; import dev.heliosclient.util.interfaces.ISettingChange; import dev.heliosclient.util.misc.MapReader; @@ -77,36 +77,81 @@ public class HudElement implements ISettingChange, ISaveAndLoad, Listener { // This is a lot of complete customisation. // Todo: Add radius setting for rounded background public BooleanSetting renderBg = sgUI.add(new BooleanSetting.Builder() - .name("Render background") + .name("Render Background") .description("Render the background for the element") .value(false) .defaultValue(false) .onSettingChange(this) - .build()); - public BooleanSetting rounded = sgUI.add(new BooleanSetting.Builder() - .name("Rounded background") - .description("Rounds the background of the element for better visuals") + .build() + ); + public BooleanSetting renderOutline = sgUI.add(new BooleanSetting.Builder() + .name("Render Outline") + .description("Render a outline around the element") .value(false) .defaultValue(false) .onSettingChange(this) - .shouldRender(() -> renderBg.value) - .build()); + .build() + ); + public DoubleSetting outlineThickness = sgUI.add(new DoubleSetting.Builder() + .name("Outline Thickness") + .description("Thickness of the outline around the element") + .value(1.2d) + .min(0) + .max(15) + .defaultValue(1.2d) + .roundingPlace(1) + .shouldRender(() -> renderOutline.value) + .onSettingChange(this) + .build() + ); + public RGBASetting outlineColor = sgUI.add(new RGBASetting.Builder() + .name("Outline Color") + .description("Color for the outline") + .value(Color.WHITE) + .defaultValue(Color.WHITE) + .shouldRender(() -> renderOutline.value) + .onSettingChange(this) + .build() + ); + public CycleSetting style = sgUI.add(new CycleSetting.Builder() + .name("Style") + .description("Style for the background and outline") + .defaultValue(List.of(Renderer2D.RectRenderStyle.values())) + .defaultListOption(Renderer2D.RectRenderStyle.PLAIN) + .onSettingChange(this) + .shouldRender(() -> renderBg.value || renderOutline.value) + .build() + ); + public DoubleSetting roundedRadius = sgUI.add(new DoubleSetting.Builder() + .name("Radius of rounded style") + .description("Radius of rounded style") + .value(3) + .min(1) + .max(35) + .defaultValue(3) + .roundingPlace(1) + .shouldRender(() -> style.isOption(Renderer2D.RectRenderStyle.ROUNDED) && (renderBg.value || renderOutline.value)) + .onSettingChange(this) + .build() + ); public BooleanSetting clientColorCycle = sgUI.add(new BooleanSetting.Builder() - .name("Client Color Cycle") + .name("Client Color Cycle Style") .description("Use the client default color cycle for the background of the element") .value(false) .defaultValue(false) .onSettingChange(this) - .shouldRender(() -> renderBg.value) - .build()); - public RGBASetting backgroundColor = sgUI.add(new RGBASetting.Builder() - .name("Background Color") - .description("Render the background for the element") + .shouldRender(() -> renderBg.value || renderOutline.value) + .build() + ); + public RGBASetting styleColor = sgUI.add(new RGBASetting.Builder() + .name("Style Color") + .description("Color to render the style for the element") .value(new Color(4, 3, 3, 157)) .defaultValue(new Color(4, 3, 3, 157)) - .shouldRender(() -> renderBg.value && !clientColorCycle.value) + .shouldRender(() -> (renderBg.value || renderOutline.value) && !clientColorCycle.value) .onSettingChange(this) - .build()); + .build() + ); public DoubleSetting padding = sgUI.add(new DoubleSetting.Builder() .name("Padding") .description("Amount of Padding around the borders") @@ -114,17 +159,19 @@ public class HudElement implements ISettingChange, ISaveAndLoad, Listener { .min(0) .max(15) .defaultValue(0D) - .shouldRender(() -> renderBg.value) + .shouldRender(() -> renderBg.value || renderOutline.value) .onSettingChange(this) - .build()); + .build() + ); public BooleanSetting shadow = sgUI.add(new BooleanSetting.Builder() .name("Shadow") .description("Shadow for the background of the element") .value(false) .defaultValue(false) .onSettingChange(this) - .shouldRender(() -> renderBg.value) - .build()); + .shouldRender(() -> renderBg.value|| renderOutline.value ) + .build() + ); public DoubleSetting shadowRadius = sgUI.add(new DoubleSetting.Builder() .name("Shadow Radius") .description("Radius of the shadow") @@ -132,24 +179,27 @@ public class HudElement implements ISettingChange, ISaveAndLoad, Listener { .max(50) .defaultValue(5D) .value(5D) - .shouldRender(() -> shadow.value && renderBg.value) + .shouldRender(() -> shadow.value && (renderBg.value|| renderOutline.value)) .onSettingChange(this) - .build()); + .build() + ); public BooleanSetting syncShadowColorAsBackground = sgUI.add(new BooleanSetting.Builder() - .name("Sync Background color to shadow") - .description("Syncs shadow color with background color") + .name("Sync Style color to shadow") + .description("Syncs shadow color with style color") .defaultValue(true) .onSettingChange(this) - .shouldRender(() -> shadow.value && renderBg.value) - .build()); + .shouldRender(() -> shadow.value && (renderBg.value|| renderOutline.value)) + .build() + ); public RGBASetting shadowColor = sgUI.add(new RGBASetting.Builder() .name("Shadow Color") .description("Render the shadow for the element") .value(new Color(4, 3, 3, 157)) .defaultValue(new Color(4, 3, 3, 157)) - .shouldRender(() -> shadow.value && !syncShadowColorAsBackground.value && renderBg.value) + .shouldRender(() -> shadow.value && !syncShadowColorAsBackground.value && (renderBg.value|| renderOutline.value)) .onSettingChange(this) - .build()); + .build() + ); public HudElement(HudElementData hudElementInfo) { @@ -291,7 +341,7 @@ public void render(DrawContext drawContext, TextRenderer textRenderer) { public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { setHudBox(); - if (renderBg.value) { + if (renderBg.value || renderOutline.value) { drawContext.getMatrices().push(); drawContext.getMatrices().translate(0D, 0D, 0D); Color bgStart, bgEnd; @@ -299,24 +349,25 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { bgStart = ColorManager.INSTANCE.getPrimaryGradientStart(); bgEnd = ColorManager.INSTANCE.getPrimaryGradientEnd(); } else { - bgStart = backgroundColor.getColor(); + bgStart = styleColor.getColor(); bgEnd = bgStart; } Color blended = ColorUtils.blend(bgStart, bgEnd, 1 / 2f); Color finalShadowColor = syncShadowColorAsBackground.value ? blended : shadowColor.value; - drawBackground(drawContext, bgStart, bgEnd, finalShadowColor); + if(renderBg.value) drawBackground(drawContext, bgStart, bgEnd, finalShadowColor); + if(renderOutline.value) drawOutline(drawContext, clientColorCycle.value ? bgStart : outlineColor.getColor(), clientColorCycle.value ? bgEnd : outlineColor.getColor(), finalShadowColor); drawContext.getMatrices().pop(); } } - private void drawBackground(DrawContext drawContext, Color bgStart, Color bgEnd, Color finalShadowColor) { - if (rounded.value) { + protected void drawBackground(DrawContext drawContext, Color bgStart, Color bgEnd, Color finalShadowColor) { + if (style.isOption(Renderer2D.RectRenderStyle.ROUNDED)) { if (shadow.value) { - Renderer2D.drawRoundedGradientRectangleWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), bgStart, bgEnd, bgEnd, bgStart, 2, (int) shadowRadius.value, finalShadowColor); + Renderer2D.drawRoundedGradientRectangleWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), bgStart, bgEnd, bgEnd, bgStart, roundedRadius.getFloat(), (int) shadowRadius.value, finalShadowColor); } else { - Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), bgStart, bgEnd, bgEnd, bgStart, hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), 2); + Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(), bgStart, bgEnd, bgEnd, bgStart, hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), roundedRadius.getFloat()); } } else { if (shadow.value) { @@ -326,6 +377,21 @@ private void drawBackground(DrawContext drawContext, Color bgStart, Color bgEnd, } } } + protected void drawOutline(DrawContext drawContext, Color bgStart, Color bgEnd, Color finalShadowColor) { + if (style.isOption(Renderer2D.RectRenderStyle.ROUNDED)) { + if (shadow.value && !renderBg.value) { + Renderer2D.drawOutlineGradientRoundedBoxWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(), roundedRadius.getFloat(), outlineThickness.getInt(), bgStart, bgEnd, bgEnd, bgStart, (int) shadowRadius.value, finalShadowColor); + } else { + Renderer2D.drawOutlineGradientRoundedBox(drawContext.getMatrices().peek().getPositionMatrix(), hudBox.getX(), hudBox.getY(),hudBox.getWidth() - 1.9f, hudBox.getHeight(), roundedRadius.getFloat(), outlineThickness.getInt(), bgStart, bgEnd, bgEnd, bgStart); + } + } else { + if (shadow.value && !renderBg.value) { + Renderer2D.drawOutlineGradientBoxWithShadow(drawContext.getMatrices(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(),outlineThickness.getFloat() ,bgStart, bgEnd, bgEnd, bgStart, shadowRadius.getInt(), finalShadowColor); + } else { + Renderer2D.drawOutlineGradientBox(drawContext.getMatrices().peek().getPositionMatrix(), hudBox.getX(), hudBox.getY(), hudBox.getWidth() - 1.9f, hudBox.getHeight(),outlineThickness.getFloat() ,bgStart, bgEnd, bgEnd, bgStart); + } + } + } /** * Called on load. @@ -494,4 +560,6 @@ public static void setSnapSize(int snapSize){ public static int getSnapSize() { return snapSize; } + + } diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java b/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java index 7c3e2e30..c93f04c1 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ArmorHud.java @@ -68,8 +68,7 @@ public ArmorHud() { this.width = 20; this.height = 20 * 4 + 4; this.renderBg.setValue(true); - this.rounded.setValue(true); - + this.style.setOption(Renderer2D.RectRenderStyle.ROUNDED); } @Override diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ClockHud.java b/src/main/java/dev/heliosclient/hud/hudelements/ClockHud.java index 1cfa7f87..2d5621e9 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ClockHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ClockHud.java @@ -48,7 +48,7 @@ public ClockHud() { this.width = 14; this.height = 20; this.renderBg.setValue(true); - this.rounded.setValue(true); + this.style.setOption(Renderer2D.RectRenderStyle.ROUNDED); } @Override public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { diff --git a/src/main/java/dev/heliosclient/hud/hudelements/CompactData.java b/src/main/java/dev/heliosclient/hud/hudelements/CompactData.java index 219bf5f6..70550358 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/CompactData.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/CompactData.java @@ -4,8 +4,8 @@ import dev.heliosclient.hud.HudElementData; import dev.heliosclient.managers.ColorManager; import dev.heliosclient.system.TickRate; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/dev/heliosclient/hud/hudelements/CoordinatesHud.java b/src/main/java/dev/heliosclient/hud/hudelements/CoordinatesHud.java index cee37e23..a97a2375 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/CoordinatesHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/CoordinatesHud.java @@ -5,8 +5,8 @@ import dev.heliosclient.managers.ColorManager; import dev.heliosclient.module.settings.BooleanSetting; import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -19,7 +19,7 @@ public class CoordinatesHud extends HudElement { private final BooleanSetting noXYZ = sgSettings.add(new BooleanSetting.Builder() .name("NoXYZ") - .description("Does not show the XYZ coordinates") + .description("Does not show the XYZ tag") .onSettingChange(this) .defaultValue(false) .build() @@ -33,7 +33,7 @@ public class CoordinatesHud extends HudElement { ); private final BooleanSetting netherCoords = sgSettings.add(new BooleanSetting.Builder() .name("Nether Coords") - .description("Shows the coordinates of nether") + .description("Shows the current coordinates translated to nether coordinates") .onSettingChange(this) .defaultValue(false) .build() @@ -59,9 +59,10 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { coordY = 0; coordZ = 0; } else { - coordX = (int) MathUtils.round(entityForCoords.getX() / (netherCoords.value ? 8 : 1), 0); - coordY = (int) MathUtils.round(entityForCoords.getY() / (netherCoords.value ? 8 : 1), 0); - coordZ = (int) MathUtils.round(entityForCoords.getZ() / (netherCoords.value ? 8 : 1), 0); + int divideBy = netherCoords.value ? 8 : 1; + coordX = (int) MathUtils.round(entityForCoords.getX() / divideBy, 0); + coordY = (int) MathUtils.round(entityForCoords.getY() / divideBy, 0); + coordZ = (int) MathUtils.round(entityForCoords.getZ() / divideBy, 0); } String x = ColorUtils.gray + coordX + ColorUtils.reset; @@ -74,7 +75,6 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { (!noXYZ.value ? " Z: " : ", ") + z; this.width = Math.round(Renderer2D.getStringWidth(text)); - this.height = Math.round(Renderer2D.getStringHeight()); Renderer2D.drawString(drawContext.getMatrices(), text, this.x, this.y, ColorManager.INSTANCE.hudColor); diff --git a/src/main/java/dev/heliosclient/hud/hudelements/DirectionHud.java b/src/main/java/dev/heliosclient/hud/hudelements/DirectionHud.java index 4c40e927..d8e2c34b 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/DirectionHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/DirectionHud.java @@ -4,7 +4,7 @@ import dev.heliosclient.hud.HudElementData; import dev.heliosclient.managers.ColorManager; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import me.x150.renderer.render.Renderer2d; import net.minecraft.client.font.TextRenderer; diff --git a/src/main/java/dev/heliosclient/hud/hudelements/Fps.java b/src/main/java/dev/heliosclient/hud/hudelements/Fps.java index 2634e0a9..26f95044 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/Fps.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/Fps.java @@ -3,7 +3,7 @@ import dev.heliosclient.hud.HudElement; import dev.heliosclient.hud.HudElementData; import dev.heliosclient.managers.ColorManager; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/dev/heliosclient/hud/hudelements/KeyBindsHud.java b/src/main/java/dev/heliosclient/hud/hudelements/KeyBindsHud.java index eaaee798..3e35f5d3 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/KeyBindsHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/KeyBindsHud.java @@ -6,14 +6,14 @@ import dev.heliosclient.managers.ModuleManager; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.KeyBind; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.KeyboardUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; public class KeyBindsHud extends HudElement { - public static HudElementData DATA = new HudElementData<>("Keybinds", "Shows the modules with keybinds", KeyBindsHud::new); + public static HudElementData DATA = new HudElementData<>("KeyBinds", "Shows the modules with set keyBinds", KeyBindsHud::new); public KeyBindsHud() { super(DATA); diff --git a/src/main/java/dev/heliosclient/hud/hudelements/LagTimerHud.java b/src/main/java/dev/heliosclient/hud/hudelements/LagTimerHud.java index cd8176bd..544bfb01 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/LagTimerHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/LagTimerHud.java @@ -3,7 +3,7 @@ import dev.heliosclient.hud.HudElement; import dev.heliosclient.hud.HudElementData; import dev.heliosclient.system.TickRate; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java b/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java index 89c265b8..a6caedf4 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ModuleList.java @@ -9,7 +9,7 @@ import dev.heliosclient.managers.ModuleManager; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/dev/heliosclient/hud/hudelements/Ping.java b/src/main/java/dev/heliosclient/hud/hudelements/Ping.java index 9ba40b7e..7acc0910 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/Ping.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/Ping.java @@ -3,7 +3,7 @@ import dev.heliosclient.hud.HudElement; import dev.heliosclient.hud.HudElementData; import dev.heliosclient.managers.ColorManager; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/dev/heliosclient/hud/hudelements/Radar.java b/src/main/java/dev/heliosclient/hud/hudelements/Radar.java index d27751d3..7831ca0e 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/Radar.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/Radar.java @@ -2,7 +2,10 @@ import dev.heliosclient.hud.HudElement; import dev.heliosclient.hud.HudElementData; +import dev.heliosclient.managers.ModuleManager; +import dev.heliosclient.module.modules.world.PaletteExploit; import dev.heliosclient.module.settings.*; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; @@ -15,18 +18,18 @@ import net.minecraft.entity.passive.TameableEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; +import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.Vec3d; import java.awt.*; import java.util.List; +import java.util.Set; public class Radar extends HudElement { private static int RADAR_SIZE = 100; // Size of the radar in pixels private static int MAX_DISTANCE = 25; // Maximum entity distance - public static HudElementData DATA = new HudElementData<>("Radar", "Shows entities radar", Radar::new); - public SettingGroup sgRadarSettings = new SettingGroup("General"); - public SettingGroup sgRadarColors = new SettingGroup("Colors"); + public SettingGroup sgRadarColors = new SettingGroup("Colors"); public static HudElementData DATA = new HudElementData<>("Radar", "Shows entities radar", Radar::new); public DoubleSetting distance = sgRadarSettings.add(new DoubleSetting.Builder() .name("Distance To Scale") .description("Max Entity distance to be included in the radar") @@ -38,6 +41,31 @@ public class Radar extends HudElement { .onSettingChange(this) .build() ); + public BooleanSetting showGridLines = sgRadarSettings.add(new BooleanSetting.Builder() + .name("Show Grid Lines") + .description("Renders grid lines in the center of the radar") + .defaultValue(false) + .value(false) + .onSettingChange(this) + .build() + ); + public BooleanSetting showChunkTrails = sgRadarSettings.add(new BooleanSetting.Builder() + .name("Show Chunk Trails") + .description("Renders old/new chunks from the Palette exploit module (because it is the most accurate currently) in the radar") + .defaultValue(false) + .value(false) + .onSettingChange(this) + .build() + ); + public BooleanSetting showAllChunkTrails = sgRadarSettings.add(new BooleanSetting.Builder() + .name("Show All Chunk Trails") + .description("This will render all the stored chunks in a small way such that all trails are fit inside the radar. Useful for finding previous trail paths. This will also make the position of entities and chunks not match.") + .defaultValue(false) + .value(false) + .onSettingChange(this) + .shouldRender(() -> showChunkTrails.value) + .build() + ); public DropDownSetting drawingMode = sgRadarSettings.add(new DropDownSetting.Builder() .name("Drawing Mode") .description("Mode of drawing entities on the radar") @@ -184,11 +212,11 @@ public Radar() { @Override public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { - this.width = (int) size.value; - this.height = (int) size.value; - RADAR_SIZE = this.width; + this.width = size.getInt(); + this.height = size.getInt(); super.renderElement(drawContext, textRenderer); + if (mc.player == null || mc.world == null) { return; } @@ -198,6 +226,11 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { Vec3d playerPos = mc.player.getPos(); + Renderer2D.enableScissor(x - this.padding.getInt() - 2, y - this.padding.getInt() - 2, RADAR_SIZE + this.padding.getInt() + 2, RADAR_SIZE + this.padding.getInt() + 2); + if (showChunkTrails.value) { + renderChunks(drawContext, centerX, centerY); + } + for (Entity entity : mc.world.getEntities()) { if (isBlackListed(entity)) { continue; @@ -206,7 +239,7 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { // Ignore the Y-level difference double dx = playerPos.x - entityPos.x; double dz = playerPos.z - entityPos.z; - double distance = Math.sqrt(dx*dx + dz*dz); + double distance = Math.sqrt(dx * dx + dz * dz); if (distance <= MAX_DISTANCE) { // Calculate the entity's position on the radar @@ -221,46 +254,77 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { radius = 1.5f; } if (entity == mc.player) { - FontRenderers.Small_iconRenderer.drawString(drawContext.getMatrices(), "\uF18B", x2 - 1.5f, y2 - 1.2f, yourColor.value.getRGB()); - }else { - switch ((DrawingMode) drawingMode.getOption()) { - case DOT -> Renderer2D.drawFilledCircle(drawContext.getMatrices().peek().getPositionMatrix(), x2, y2, radius, color); - case FIRST_LETTER -> { - float scaledX = x2/drawingScale.getFloat(); - float scaledY = y2/drawingScale.getFloat(); - drawContext.getMatrices().push(); - drawContext.getMatrices().scale(drawingScale.getFloat(),drawingScale.getFloat(),1f); - - String text = entity.getType().getUntranslatedName().substring(0,1); - - drawContext.drawText(mc.textRenderer,text, (int) scaledX, (int) scaledY,color,false); - drawContext.getMatrices().pop(); - } - case FACE -> { - EntityRenderer e = mc.getEntityRenderDispatcher().getRenderer(entity); - if(e != null) { - Identifier texture = e.getTexture(entity); - - if (texture != null) { - drawContext.getMatrices().push(); - drawContext.getMatrices().scale(drawingScale.getFloat(), drawingScale.getFloat(), 1f); - drawContext.drawTexture(texture, (int) (x2 / drawingScale.getFloat() - 8), (int) (y2 / drawingScale.getFloat() - 8), 8, 8, 8, 8, 64, 64); - drawContext.getMatrices().pop(); - } - } - } + FontRenderers.Small_iconRenderer.drawString(drawContext.getMatrices(), "\uF18B", x2 - FontRenderers.Small_iconRenderer.getStringWidth("\uF18B") / 2f, y2 - FontRenderers.Small_iconRenderer.getStringHeight("\uF18B") / 2f, yourColor.value.getRGB()); + } else { + drawEntityOnRadar(drawContext, entity, x2, y2, radius, color); + } + } + } + if (showGridLines.value) { + renderGridLines(drawContext); + } + Renderer2D.disableScissor(); + } + + public void drawEntityOnRadar(DrawContext drawContext, Entity entity, float x, float y, float radius, int color) { + switch ((DrawingMode) drawingMode.getOption()) { + case DOT -> + Renderer2D.drawFilledCircle(drawContext.getMatrices().peek().getPositionMatrix(), x, y, radius, color); + case FIRST_LETTER -> { + float scaledX = x / drawingScale.getFloat(); + float scaledY = y / drawingScale.getFloat(); + drawContext.getMatrices().push(); + drawContext.getMatrices().scale(drawingScale.getFloat(), drawingScale.getFloat(), 1f); + + String text = entity.getType().getUntranslatedName().substring(0, 1); + + drawContext.drawText(mc.textRenderer, text, (int) scaledX, (int) scaledY, color, false); + drawContext.getMatrices().pop(); + } + case FACE -> { + EntityRenderer e = mc.getEntityRenderDispatcher().getRenderer(entity); + if (e != null) { + Identifier texture = e.getTexture(entity); + + if (texture != null) { + drawContext.getMatrices().push(); + drawContext.getMatrices().scale(drawingScale.getFloat(), drawingScale.getFloat(), 1f); + drawContext.drawTexture(texture, (int) (x / drawingScale.getFloat() - 8), (int) (y / drawingScale.getFloat() - 8), 8, 8, 8, 8, 64, 64); + drawContext.getMatrices().pop(); } } } } } + private void renderGridLines(DrawContext drawContext) { + int color = ColorUtils.changeAlphaGetInt(0xFFFFFF, 200); // White color with some transparency + + // Draw horizontal and vertical grid lines at the center + float paddingOff = this.padding.getFloat()/2.0f; + Renderer2D.drawHorizontalLine(drawContext.getMatrices().peek().getPositionMatrix(), x - paddingOff,RADAR_SIZE + (paddingOff*4.0f),y + (float) RADAR_SIZE /2,0.7f,color); + Renderer2D.drawVerticalLine(drawContext.getMatrices().peek().getPositionMatrix(),x + (float) RADAR_SIZE /2,y - paddingOff,RADAR_SIZE + (paddingOff*4.0f),0.7f,color); + // Renderer2D.drawLine(drawContext.getMatrices(), hudBox.getX(), y + (float) RADAR_SIZE / 2, hudBox.getX() + hudBox.getWidth(), y + (float) RADAR_SIZE / 2, 1.2f, color); + //Renderer2D.drawLine(drawContext.getMatrices(), x + (float) RADAR_SIZE / 2, hudBox.getY(), hudBox.getX() + (float) RADAR_SIZE / 2, hudBox.getY() + hudBox.getHeight(), 1.2f, color); + } + + @Override + protected void drawOutline(DrawContext drawContext, Color bgStart, Color bgEnd, Color finalShadowColor) { + drawContext.getMatrices().push(); + drawContext.getMatrices().translate(0, 0, 5); + super.drawOutline(drawContext, bgStart, bgEnd, finalShadowColor); + drawContext.getMatrices().pop(); + } + @Override public void onSettingChange(Setting setting) { super.onSettingChange(setting); if (setting == distance) { MAX_DISTANCE = (int) distance.value; } + if (setting == size) { + RADAR_SIZE = this.size.getInt(); + } } public boolean isBlackListed(Entity entity) { @@ -272,6 +336,109 @@ public boolean isBlackListed(Entity entity) { !includeOthers.value; } + private void renderChunks(DrawContext drawContext, int centerX, int centerY) { + Vec3d playerPos = mc.player.getPos(); + PaletteExploit paletteExploit = ModuleManager.get(PaletteExploit.class); + if (paletteExploit == null) return; + + if (showAllChunkTrails.value) { + renderAllChunks(drawContext, paletteExploit.newChunks, PaletteExploit.ChunkType.NEW, centerX, centerY, playerPos); + renderAllChunks(drawContext, paletteExploit.oldChunks, PaletteExploit.ChunkType.OLD, centerX, centerY, playerPos); + renderAllChunks(drawContext, paletteExploit.beingUpdatedOldChunks, PaletteExploit.ChunkType.BEING_UPDATED, centerX, centerY, playerPos); + renderAllChunks(drawContext, paletteExploit.oldGenerationOldChunks, PaletteExploit.ChunkType.OLD_GEN, centerX, centerY, playerPos); + } else { + for (ChunkPos cp : paletteExploit.newChunks) { + renderChunk(drawContext, cp, PaletteExploit.ChunkType.NEW, centerX, centerY, playerPos); + } + for (ChunkPos cp : paletteExploit.oldChunks) { + renderChunk(drawContext, cp, PaletteExploit.ChunkType.OLD, centerX, centerY, playerPos); + } + for (ChunkPos cp : paletteExploit.beingUpdatedOldChunks) { + renderChunk(drawContext, cp, PaletteExploit.ChunkType.BEING_UPDATED, centerX, centerY, playerPos); + } + for (ChunkPos cp : paletteExploit.oldGenerationOldChunks) { + renderChunk(drawContext, cp, PaletteExploit.ChunkType.OLD_GEN, centerX, centerY, playerPos); + } + } + } + + private void renderChunk(DrawContext drawContext, ChunkPos cp, PaletteExploit.ChunkType type, int centerX, int centerY, Vec3d playerPos) { + double dx = playerPos.x - cp.getStartX(); + double dz = playerPos.z - cp.getStartZ(); + double distance = Math.sqrt(dx * dx + dz * dz); + if (distance <= MAX_DISTANCE) { + double angle = Math.atan2(cp.getStartZ() - playerPos.z, cp.getStartX() - playerPos.x) - Math.toRadians(mc.player.getYaw()) - Math.PI; + float x2 = (float) (centerX + Math.cos(angle) * (distance / this.distance.value) * ((float) size.value / 2)); + float y2 = (float) (centerY + Math.sin(angle) * (distance / this.distance.value) * ((float) size.value / 2)); + int color = ColorUtils.changeAlphaGetInt(ModuleManager.get(PaletteExploit.class).getChunkTypeColor(type), 150); + + // Scale the radar size to fit the distance setting + float radarScale = size.getFloat() / this.distance.getFloat(); + + // Each chunk gets a proportionate size based on the radar scale + float chunkSize = radarScale * 8; + + // Calculate half the chunk size for easier manipulation + float halfChunkSize = chunkSize / 2; + + // Calculate the sine and cosine of the player's yaw (rotation) + float sinYaw = (float) Math.sin(-Math.toRadians(mc.player.getYaw())); + float cosYaw = (float) Math.cos(-Math.toRadians(mc.player.getYaw())); + + // Calculate the top-left corner position of the rectangle + float xTopLeft = x2 + (-halfChunkSize * cosYaw - halfChunkSize * sinYaw); + float yTopLeft = y2 + (-halfChunkSize * sinYaw + halfChunkSize * cosYaw); + + // Calculate the top-right corner position of the rectangle + float xTopRight = x2 + (halfChunkSize * cosYaw - halfChunkSize * sinYaw); + float yTopRight = y2 + (halfChunkSize * sinYaw + halfChunkSize * cosYaw); + + // Calculate the bottom-left corner position of the rectangle + float xBottomLeft = x2 + (-halfChunkSize * cosYaw + halfChunkSize * sinYaw); + float yBottomLeft = y2 + (-halfChunkSize * sinYaw - halfChunkSize * cosYaw); + + // Calculate the bottom-right corner position of the rectangle + float xBottomRight = x2 + (halfChunkSize * cosYaw + halfChunkSize * sinYaw); + float yBottomRight = y2 + (halfChunkSize * sinYaw - halfChunkSize * cosYaw); + + // Draw the rotated rectangle with the calculated corner positions + Renderer2D.drawQuad(drawContext.getMatrices().peek().getPositionMatrix(), + xTopLeft, yTopLeft, xTopRight, yTopRight, xBottomRight, yBottomRight, xBottomLeft, yBottomLeft, color); + + } + } + + private void renderAllChunks(DrawContext drawContext, Set chunks, PaletteExploit.ChunkType type, int centerX, int centerY, Vec3d playerPos) { + for (ChunkPos cp : chunks) { + double dx = playerPos.x - cp.getStartX(); + double dz = playerPos.z - cp.getStartZ(); + double distance = Math.sqrt(dx * dx + dz * dz); + double angle = Math.atan2(cp.getStartZ() - playerPos.z, cp.getStartX() - playerPos.x) - Math.toRadians(mc.player.getYaw()) - Math.PI; + float x2 = (float) (centerX + Math.cos(angle) * (distance / (this.distance.value * 16)) * ((float) size.value / 2)); + float y2 = (float) (centerY + Math.sin(angle) * (distance / (this.distance.value * 16)) * ((float) size.value / 2)); + int color = ColorUtils.changeAlphaGetInt(ModuleManager.get(PaletteExploit.class).getChunkTypeColor(type), 150); + + float radarScale = size.getFloat() / this.distance.getFloat(); + float chunkSize = radarScale * 8; + + float halfChunkSize = chunkSize / 2; + float sinYaw = (float) Math.sin(-Math.toRadians(mc.player.getYaw())); + float cosYaw = (float) Math.cos(-Math.toRadians(mc.player.getYaw())); + + float xTopLeft = x2 + (-halfChunkSize * cosYaw - halfChunkSize * sinYaw); + float yTopLeft = y2 + (-halfChunkSize * sinYaw + halfChunkSize * cosYaw); + float xTopRight = x2 + (halfChunkSize * cosYaw - halfChunkSize * sinYaw); + float yTopRight = y2 + (halfChunkSize * sinYaw + halfChunkSize * cosYaw); + float xBottomLeft = x2 + (-halfChunkSize * cosYaw + halfChunkSize * sinYaw); + float yBottomLeft = y2 + (-halfChunkSize * sinYaw - halfChunkSize * cosYaw); + float xBottomRight = x2 + (halfChunkSize * cosYaw + halfChunkSize * sinYaw); + float yBottomRight = y2 + (halfChunkSize * sinYaw - halfChunkSize * cosYaw); + + Renderer2D.drawQuad(drawContext.getMatrices().peek().getPositionMatrix(), + xTopLeft, yTopLeft, xTopRight, yTopRight, xBottomRight, yBottomRight, xBottomLeft, yBottomLeft, color); + } + } + private int getColor(Entity entity) { int color; if (entity instanceof TameableEntity e && includeTamed.value) { @@ -291,9 +458,13 @@ private int getColor(Entity entity) { } return color; } + + public enum DrawingMode { DOT, FIRST_LETTER, FACE } -} + + +} \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/hud/hudelements/ScaffoldCount.java b/src/main/java/dev/heliosclient/hud/hudelements/ScaffoldCount.java index 1937242a..8185578c 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/ScaffoldCount.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/ScaffoldCount.java @@ -21,6 +21,7 @@ public class ScaffoldCount extends HudElement { private static final float ANIMATION_DURATION = 0.5f; // Duration of the pop-in/out animation in seconds private static final float DISPLAY_DURATION = 2f; // Duration to display the item before popping out. Currently it is 2s private final SettingGroup sgSettings = new SettingGroup("Settings"); + private final DoubleSetting scale = sgSettings.add(new DoubleSetting.Builder() .name("Scale") .description("Change the scale") @@ -32,6 +33,7 @@ public class ScaffoldCount extends HudElement { .roundingPlace(2) .build() ); + public ScaffoldCount() { super(DATA); addSettingGroup(sgSettings); @@ -40,7 +42,7 @@ public ScaffoldCount() { @Override public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { - if (!SCAFFOLD_STACK.isEmpty()) { + if (!SCAFFOLD_STACK.isEmpty() || isInHudEditor) { if (!isVisible) { isVisible = true; timer.startTimer(); @@ -52,7 +54,7 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { } // Render the element with animation - if (isVisible) { + if (isVisible || isInHudEditor) { float scale = Math.min(animationProgress, 1.0f); Renderer2D.scaleAndPosition(drawContext.getMatrices(), x, y, width, height, scale); super.renderElement(drawContext, textRenderer); @@ -73,14 +75,14 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { } } - public void updateProgress(boolean out) { + private void updateProgress(boolean out) { if (out) { animationProgress -= 1.0f / (ANIMATION_DURATION * 20); } else { animationProgress += 1.0f / (ANIMATION_DURATION * 20); } - animationProgress = MathHelper.clamp(animationProgress, 0, scale.getFloat()); + animationProgress = MathHelper.clamp(animationProgress, 0, scale.getFloat() + 0.4f); } public static void setScaffoldStack(ItemStack stack) { diff --git a/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java b/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java index ab4b0fd8..523dcb07 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/SpeedHud.java @@ -3,8 +3,8 @@ import dev.heliosclient.hud.HudElement; import dev.heliosclient.hud.HudElementData; import dev.heliosclient.managers.ColorManager; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; @@ -18,7 +18,7 @@ public SpeedHud() { 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 aka meter per second", SpeedHud::new); @Override public void renderElement(DrawContext drawContext, TextRenderer textRenderer) { @@ -37,4 +37,4 @@ private double moveSpeed() { return Math.abs(MathUtils.length2D(move)); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/hud/hudelements/Tps.java b/src/main/java/dev/heliosclient/hud/hudelements/Tps.java index d6399dd2..18964d35 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/Tps.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/Tps.java @@ -4,14 +4,14 @@ import dev.heliosclient.hud.HudElementData; import dev.heliosclient.managers.ColorManager; import dev.heliosclient.system.TickRate; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; public class Tps extends HudElement { - public static HudElementData DATA = new HudElementData<>("TPS", "Shows current tps", Tps::new); + public static HudElementData DATA = new HudElementData<>("TPS", "Shows current server tps", Tps::new); public Tps() { super(DATA); diff --git a/src/main/java/dev/heliosclient/hud/hudelements/WelcomeHud.java b/src/main/java/dev/heliosclient/hud/hudelements/WelcomeHud.java index 0363f9e3..ab0bd859 100644 --- a/src/main/java/dev/heliosclient/hud/hudelements/WelcomeHud.java +++ b/src/main/java/dev/heliosclient/hud/hudelements/WelcomeHud.java @@ -6,7 +6,7 @@ import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.module.settings.StringSetting; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.inputbox.InputBox; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; diff --git a/src/main/java/dev/heliosclient/managers/CapeManager.java b/src/main/java/dev/heliosclient/managers/CapeManager.java index 90978f10..1e64d5d0 100644 --- a/src/main/java/dev/heliosclient/managers/CapeManager.java +++ b/src/main/java/dev/heliosclient/managers/CapeManager.java @@ -7,10 +7,10 @@ import dev.heliosclient.HeliosClient; import dev.heliosclient.module.modules.misc.CapeModule; import dev.heliosclient.system.HeliosExecutor; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.AnimationUtils; import dev.heliosclient.util.cape.CapeTextureManager; import dev.heliosclient.util.cape.ProfileUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.texture.NativeImage; @@ -33,9 +33,13 @@ import java.util.concurrent.Future; public class CapeManager { + //Default Elytra Skin + private static final Identifier SKIN = new Identifier("textures/entity/elytra.png"); + //Where we store and get our capes. private static final File CAPE_DIRECTORY = new File(HeliosClient.MC.runDirectory, "heliosclient/capes"); private static final String DEFAULT_CAPE = "helioscape.png"; + //The default cape texture of heliosclient. public static final Identifier DEFAULT_CAPE_TEXTURE = new Identifier("heliosclient", "capes/" + DEFAULT_CAPE); @@ -45,9 +49,8 @@ public class CapeManager { public static String[] CAPE_NAMES = new String[]{}; //List of all capes and elytra textures. - public static final CapeTextureManager capeTextureManager = new CapeTextureManager(); - - + private static final CapeTextureManager capeTextureManager = new CapeTextureManager(); + /** * Works similar to {@link FontLoader#loadFonts()} @@ -91,11 +94,10 @@ public static String[] loadCapes() { for (File file : capeFiles) { try (FileInputStream inputStream = new FileInputStream(file)) { String fileName = file.getName(); - String capeName = fileName.substring(0, fileName.lastIndexOf('.')); - capeNames.add(capeName); + capeNames.add(fileName); - capeTextureManager.registerCapeTextures(inputStream, file, capeName.toLowerCase()); - HeliosClient.LOGGER.info("Loaded cape: {}", fileName); + capeTextureManager.registerCapeTextures(inputStream, file, fileName); + HeliosClient.LOGGER.info("Loaded cape: {}", file.getAbsolutePath()); } catch (IOException e) { HeliosClient.LOGGER.error("An error has occurred while reading cape file: {}{}", ColorUtils.darkGreen, file.getName(), e); } @@ -160,7 +162,7 @@ public static NativeImage parseCape(NativeImage image) { return imgNew; } - public static void getCapes(CapeType type, String profileName, String UUID) throws Exception { + public static void getCapes(CapeOrigin type, String profileName, String UUID) throws Exception { Future future = HeliosExecutor.submit((Callable) () -> { switch (type) { case OPTIFINE: @@ -178,7 +180,7 @@ public static void getCapes(CapeType type, String profileName, String UUID) thro if (!ProfileUtils.isValidUUID(UUID)) { throw new IllegalArgumentException("Invalid UUID"); } - if (type == CapeType.CRAFATAR) { + if (type == CapeOrigin.CRAFATAR) { // Get the craftar cape INSTANCE.getCrafatarCape(UUID); } else { @@ -186,7 +188,7 @@ public static void getCapes(CapeType type, String profileName, String UUID) thro INSTANCE.getMinecraftCapesCape(UUID); } break; - case NONE: + case LOCAL: return null; default: throw new IllegalArgumentException("Invalid cape type: " + type); @@ -281,25 +283,25 @@ private void saveCapeFromUrl(String profileName, String UUID, String url) throws } public static Identifier getCurrentCapeTexture() { if(HeliosClient.MC.player == null){ - return capeTextureManager.getCurrentCapeTexture(HeliosClient.MC.getGameProfile().getId()); + return capeTextureManager.getCurrentTexture(HeliosClient.MC.getGameProfile().getId(),false); } - return capeTextureManager.getCurrentCapeTexture(HeliosClient.MC.player.getUuid()); + return capeTextureManager.getCurrentTexture(HeliosClient.MC.player.getUuid(),false); } - private static final Identifier SKIN = new Identifier("textures/entity/elytra.png"); - public static Identifier getCurrentElytraTexture() { if(HeliosClient.MC.player == null){ return SKIN; } - return capeTextureManager.getCurrentElytraTexture(HeliosClient.MC.player.getUuid()); + return capeTextureManager.getCurrentTexture(HeliosClient.MC.player.getUuid(),true); } - public enum CapeType { - NONE, + public enum CapeOrigin { + LOCAL, OPTIFINE, CRAFATAR, MINECRAFTCAPES } - + public static CapeTextureManager getTextureManager(){ + return capeTextureManager; + } } diff --git a/src/main/java/dev/heliosclient/managers/ColorManager.java b/src/main/java/dev/heliosclient/managers/ColorManager.java index 03c40bbd..cba232d7 100644 --- a/src/main/java/dev/heliosclient/managers/ColorManager.java +++ b/src/main/java/dev/heliosclient/managers/ColorManager.java @@ -6,7 +6,7 @@ import dev.heliosclient.event.listener.Listener; import dev.heliosclient.module.modules.render.GUI; import dev.heliosclient.ui.clickgui.Tooltip; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import java.awt.*; @@ -50,38 +50,20 @@ private ColorManager() { new GradientManager.GradientBuilder() .setName("DaySky") - .setStartGradient(() -> { - float hue = (System.currentTimeMillis() % 10000) / 10000f; - return ColorUtils.getDaySkyColors(hue)[0]; - }) - .setEndGradient(() -> { - float hue = (System.currentTimeMillis() % 10000) / 10000f; - return ColorUtils.getDaySkyColors(hue)[1]; - }) + .setStartGradient(() -> ColorUtils.getDaySkyColors(getHue())[0]) + .setEndGradient(() -> ColorUtils.getDaySkyColors(getHue())[1]) .register(); new GradientManager.GradientBuilder() .setName("EveningSky") - .setStartGradient(() -> { - float hue = (System.currentTimeMillis() % 10000) / 10000f; - return ColorUtils.getEveningSkyColors(hue)[0]; - }) - .setEndGradient(() -> { - float hue = (System.currentTimeMillis() % 10000) / 10000f; - return ColorUtils.getEveningSkyColors(hue)[1]; - }) + .setStartGradient(() -> ColorUtils.getEveningSkyColors(getHue())[0]) + .setEndGradient(() -> ColorUtils.getEveningSkyColors(getHue())[1]) .register(); new GradientManager.GradientBuilder() .setName("NightSky") - .setStartGradient(() -> { - float hue = (System.currentTimeMillis() % 10000) / 10000f; - return ColorUtils.getNightSkyColors(hue)[0]; - }) - .setEndGradient(() -> { - float hue = (System.currentTimeMillis() % 10000) / 10000f; - return ColorUtils.getNightSkyColors(hue)[1]; - }) + .setStartGradient(() -> ColorUtils.getNightSkyColors(getHue())[0]) + .setEndGradient(() -> ColorUtils.getNightSkyColors(getHue())[1]) .register(); new GradientManager.GradientBuilder() @@ -96,17 +78,60 @@ private ColorManager() { .setEndGradient(this::getPrimaryGradientEnd) .register(); - } + + registerStaticGradient("Sunrise", new Color(255, 94, 77), new Color(255, 165, 0)); + registerStaticGradient("Ocean", new Color(0, 105, 148), new Color(0, 168, 255)); + registerStaticGradient("Forest", new Color(34, 139, 34), new Color(107, 142, 35)); + registerStaticGradient("Candy", new Color(255, 105, 180), new Color(255, 20, 147)); + registerStaticGradient("Peach", new Color(255, 229, 180), new Color(255, 204, 153)); + registerStaticGradient("Mango", new Color(255, 204, 102), new Color(255, 179, 71)); + registerStaticGradient("Berry", new Color(138, 43, 226), new Color(75, 0, 130)); + registerStaticGradient("Mint", new Color(189, 252, 201), new Color(144, 238, 144)); + registerStaticGradient("Rose", new Color(255, 192, 203), new Color(219, 112, 147)); + registerStaticGradient("Sky", new Color(135, 206, 235), new Color(70, 130, 180)); + registerStaticGradient("Grape", new Color(128, 0, 128), new Color(75, 0, 130)); + registerStaticGradient("Peacock", new Color(0, 128, 128), new Color(0, 206, 209)); + registerStaticGradient("Flame", new Color(255, 69, 0), new Color(255, 140, 0)); + + // Additional universe and space inspired gradients + registerStaticGradient("Cosmos", new Color(70, 130, 180), new Color(75, 0, 130)); + registerStaticGradient("Galaxy", new Color(0, 0, 128), new Color(75, 0, 130)); + registerStaticGradient("Starlight", new Color(255, 255, 204), new Color(173, 216, 230)); + registerStaticGradient("Comet", new Color(0, 255, 255), new Color(255, 255, 0)); + registerStaticGradient("Aurora", new Color(0, 128, 128), new Color(72, 61, 139)); + registerStaticGradient("Quasar", new Color(255, 140, 0), new Color(239, 46, 140, 169)); + + // Additional darker-themed gradients + registerStaticGradient("Maroon", new Color(128, 0, 0), new Color(102, 0, 0)); + registerStaticGradient("Sapphire", new Color(8, 37, 103), new Color(0, 84, 159)); + registerStaticGradient("Emerald", new Color(1, 50, 32), new Color(0, 128, 0)); + registerStaticGradient("Amethyst", new Color(75, 0, 130), new Color(138, 43, 226)); + registerStaticGradient("Ruby", new Color(155, 17, 30), new Color(204, 0, 0)); + registerStaticGradient("Obsidian", new Color(38, 38, 38), new Color(77, 77, 77)); + registerStaticGradient("Copper", new Color(184, 115, 51), new Color(205, 127, 50)); + registerStaticGradient("Charcoal", new Color(54, 69, 79), new Color(70, 79, 85)); + registerStaticGradient("Steel", new Color(112, 128, 144), new Color(119, 136, 153)); + } + public static float getHue(){ + return (System.currentTimeMillis() % (HeliosClient.CLICKGUI.getRainbowSpeed() * 1000)) / (HeliosClient.CLICKGUI.getRainbowSpeed() * 1000.0f); + } public int defaultTextColor() { return defaultTextColor; } + private void registerStaticGradient(String name, Color start, Color end) { + new GradientManager.GradientBuilder() + .setName(name) + .setStartGradient(() -> start) + .setEndGradient(() -> end) + .register(); + } + public static GradientManager.Gradient getPrimaryGradient() { return GradientManager.getGradient("Primary"); } - public Color getPrimaryGradientStart() { return primaryGradientStart; } @@ -159,7 +184,7 @@ public void onTick(TickEvent.CLIENT e) { } - float hue = (System.currentTimeMillis() % 10000) / 10000f; + GUI gui = (ModuleManager.get(GUI.class)); diff --git a/src/main/java/dev/heliosclient/managers/EventManager.java b/src/main/java/dev/heliosclient/managers/EventManager.java index 6175028b..3b1b2443 100644 --- a/src/main/java/dev/heliosclient/managers/EventManager.java +++ b/src/main/java/dev/heliosclient/managers/EventManager.java @@ -19,7 +19,7 @@ public class EventManager { private static final Comparator METHOD_COMPARATOR = Comparator.comparingInt(el -> { SubscribeEvent annotation = el.method.getAnnotation(SubscribeEvent.class); - return (annotation != null) ? annotation.priority().ordinal() : -1; + return (annotation != null) ? annotation.priority().ordinal() : SubscribeEvent.Priority.NORMAL.ordinal(); }); private static final Map, Long> LAST_POSTED = new ConcurrentHashMap<>(); diff --git a/src/main/java/dev/heliosclient/mixin/CapeFeatureRendererMixin.java b/src/main/java/dev/heliosclient/mixin/CapeFeatureRendererMixin.java index 4e573015..c561fbff 100644 --- a/src/main/java/dev/heliosclient/mixin/CapeFeatureRendererMixin.java +++ b/src/main/java/dev/heliosclient/mixin/CapeFeatureRendererMixin.java @@ -21,15 +21,13 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RotationAxis; -import net.minecraft.world.biome.Biome; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(CapeFeatureRenderer.class) +@Mixin(value = CapeFeatureRenderer.class,priority = 1001) public abstract class CapeFeatureRendererMixin extends FeatureRenderer> { public CapeFeatureRendererMixin(FeatureRendererContext> context) { @@ -38,7 +36,6 @@ public CapeFeatureRendererMixin(FeatureRendererContext cir) { AspectRatio ratio = ModuleManager.get(AspectRatio.class); @@ -161,4 +162,10 @@ private void onShowFloatingItem(ItemStack floatingItem, CallbackInfo info) { } } + @Inject(method = "renderNausea", at = @At(value = "HEAD"), cancellable = true) + private void renderNausea$Helios(DrawContext context, float distortionStrength, CallbackInfo ci) { + if (NoRender.get().isActive() && NoRender.get().noNausea.value) { + ci.cancel(); + } + } } diff --git a/src/main/java/dev/heliosclient/mixin/MinecraftClientMixin.java b/src/main/java/dev/heliosclient/mixin/MinecraftClientMixin.java index 71051d56..157469eb 100644 --- a/src/main/java/dev/heliosclient/mixin/MinecraftClientMixin.java +++ b/src/main/java/dev/heliosclient/mixin/MinecraftClientMixin.java @@ -42,11 +42,23 @@ public abstract class MinecraftClientMixin { @Shadow public abstract Window getWindow(); @Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true) - public void onTick(CallbackInfo ci) { + public void onTickPre(CallbackInfo ci) { TickEvent clientTick = new TickEvent.CLIENT(); EventManager.postEvent(clientTick); - if (clientTick.isCanceled()) { + TickEvent.CLIENT.PRE clientTickPre = new TickEvent.CLIENT.PRE(); + EventManager.postEvent(clientTickPre); + + if (clientTick.isCanceled() || clientTickPre.isCanceled()) { + ci.cancel(); + } + } + @Inject(method = "tick", at = @At(value = "TAIL"), cancellable = true) + public void onTickPost(CallbackInfo ci) { + TickEvent.CLIENT.POST clientTickPost = new TickEvent.CLIENT.POST(); + EventManager.postEvent(clientTickPost); + + if (clientTickPost.isCanceled()) { ci.cancel(); } } diff --git a/src/main/java/dev/heliosclient/mixin/MixinPlayerEntity.java b/src/main/java/dev/heliosclient/mixin/MixinPlayerEntity.java index 3ae16e9c..3e481315 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinPlayerEntity.java +++ b/src/main/java/dev/heliosclient/mixin/MixinPlayerEntity.java @@ -69,7 +69,7 @@ public float ongetBlockBreakingSpeed(float ogBreakSpeed, BlockState block) { if (speedMine.modifier.value < 1 || (BlockUtils.canBreakInstantly(block, breakSpeedMod) == BlockUtils.canBreakInstantly(block, ogBreakSpeed))) { return breakSpeedMod; } else { - return (float) (0.9f / BlockUtils.calcBlockBreakingDelta2(HeliosClient.MC.world.getBlockState(pos), 1f)); + return (float) (0.9f / BlockUtils.calcBlockBreakingDelta2(HeliosClient.MC.world.getBlockState(pos))); } } diff --git a/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java b/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java index b7285e56..9202e6fc 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java +++ b/src/main/java/dev/heliosclient/mixin/MixinSplashScreen.java @@ -1,9 +1,8 @@ package dev.heliosclient.mixin; -import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import dev.heliosclient.HeliosClient; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import dev.heliosclient.util.render.textures.ClearTexture; import dev.heliosclient.util.render.textures.ClientTexture; @@ -11,7 +10,6 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.SplashOverlay; import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.RenderLayer; import net.minecraft.resource.ResourceReload; import net.minecraft.text.MutableText; import net.minecraft.text.Style; @@ -29,16 +27,15 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.awt.*; import java.util.Optional; import java.util.function.Consumer; -import static dev.heliosclient.util.render.textures.ClientTexture.CLIENT_LOGO_TEXTURE; +import static dev.heliosclient.util.render.textures.ClientTexture.CLIENT_ICON_TEXTURE; @Mixin(value = SplashOverlay.class, priority = 3001) public abstract class MixinSplashScreen { - @Unique - private static final Identifier CLEAR_TEXTURE = new Identifier(HeliosClient.MODID, "splashscreen/clear.png"); @Shadow @Final static Identifier LOGO; @@ -60,6 +57,8 @@ public abstract class MixinSplashScreen { @Final private ResourceReload reload; + @Shadow @Final private Consumer> exceptionHandler; + @Unique private static int withAlpha(int color, int alpha) { return color & 16777215 | alpha << 24; @@ -67,39 +66,39 @@ private static int withAlpha(int color, int alpha) { @Inject(method = "", at = @At("TAIL")) private void init(MinecraftClient client, ResourceReload monitor, Consumer> exceptionHandler, boolean reloading, CallbackInfo ci) { - client.getTextureManager().registerTexture(LOGO, new ClearTexture(CLEAR_TEXTURE)); - client.getTextureManager().registerTexture(CLIENT_LOGO_TEXTURE, new ClientTexture()); + client.getTextureManager().registerTexture(LOGO, new ClearTexture()); + client.getTextureManager().registerTexture(CLIENT_ICON_TEXTURE, new ClientTexture(true)); } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;getScaledWindowWidth()I", shift = At.Shift.BEFORE, ordinal = 2)) - private void renderSplashBackground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { + @Unique + private void renderSplashBackground(DrawContext context) { int i = context.getScaledWindowWidth(); int j = context.getScaledWindowHeight(); - float s = getS(); - RenderSystem.enableBlend(); - RenderSystem.blendEquation(32774); - RenderSystem.defaultBlendFunc(); - RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); - context.fill(RenderLayer.getGuiOverlay(), 0, 0, i, j, ColorHelper.Argb.getArgb(255, 0, 0, 0)); - RenderSystem.defaultBlendFunc(); - RenderSystem.disableBlend(); - } + int alpha = MathHelper.clamp((int) (getAlpha() * 255),0,255); + int startColor = ColorHelper.Argb.getArgb(alpha,183, 25, 112); + int endColor = ColorHelper.Argb.getArgb(alpha,1, 65, 109); + RenderSystem.disableDepthTest(); + RenderSystem.depthMask(false); + Renderer2D.drawGradient(context.getMatrices().peek().getPositionMatrix(), 0,0,i,j,startColor,endColor, Renderer2D.Direction.LEFT_RIGHT); + RenderSystem.depthMask(true); + RenderSystem.enableDepthTest(); + } + @Unique - private float getS() { - float f = this.reloadCompleteTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F; - float g = this.reloadStartTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadStartTime) / 500.0F : -1.0F; - float s; - if (f >= 1.0F) s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); - else if (reloading) s = MathHelper.clamp(g, 0.0F, 1.0F); - else s = 1.0F; - return s; + private float getAlpha() { + long l = Util.getMeasuringTimeMs(); + float f = this.reloadCompleteTime > -1L ? (float) (l - this.reloadCompleteTime) / 1000.0F : -1.0F; + float g = this.reloadStartTime > -1L ? (float)(l - this.reloadStartTime) / 500.0F : -1.0F; + float alpha = 1.0F; + if(f >= 1.0F) alpha = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); + else if(this.reloading) alpha = MathHelper.ceil(MathHelper.clamp(g, 0.15, 1.0) * 255.0F); + return alpha; } - @Inject(at = @At("RETURN"), method = "render", cancellable = true) - public void render2(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "render", cancellable = true) + public void render(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { int i = context.getScaledWindowWidth(); int j = context.getScaledWindowHeight(); long l = Util.getMeasuringTimeMs(); @@ -109,65 +108,52 @@ public void render2(DrawContext context, int mouseX, int mouseY, float delta, Ca float f = this.reloadCompleteTime > -1L ? (float) (l - this.reloadCompleteTime) / 1000.0F : -1.0F; float g = this.reloadStartTime > -1L ? (float) (l - this.reloadStartTime) / 500.0F : -1.0F; - int k; + float alpha; + if (f >= 1.0F) { if (this.client.currentScreen != null) { this.client.currentScreen.render(context, 0, 0, delta); } - - k = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F); - context.fill(RenderLayer.getGuiOverlay(), 0, 0, i, j, withAlpha(ColorHelper.Argb.getArgb(255, 0, 0, 0), k)); + alpha = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); } else if (this.reloading) { if (this.client.currentScreen != null && g < 1.0F) { this.client.currentScreen.render(context, mouseX, mouseY, delta); } - - k = MathHelper.ceil(MathHelper.clamp(g, 0.15, 1.0) * 255.0); - context.fill(RenderLayer.getGuiOverlay(), 0, 0, i, j, withAlpha(ColorHelper.Argb.getArgb(255, 0, 0, 0), k)); + alpha = MathHelper.clamp(g, 0.0F, 1.0F); } else { - k = ColorHelper.Argb.getArgb(255, 0, 0, 0); - float m = (float) (k >> 16 & 255) / 255.0F; - float n = (float) (k >> 8 & 255) / 255.0F; - float o = (float) (k & 255) / 255.0F; - GlStateManager._clearColor(m, n, o, 1.0F); - GlStateManager._clear(16384, MinecraftClient.IS_SYSTEM_MAC); + alpha = 1.0F; } - double d = Math.min((double) this.client.getWindow().getScaledWidth() * 0.75D, this.client.getWindow().getScaledHeight()) * 0.25D; - float verticalPosition = 0.0F; - - float s = 1.0f; - - if (f >= 1.0F) s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); - else if (this.reloading) - s = MathHelper.clamp((this.reloadStartTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadStartTime) / 500.0F : -1.0F), 0.0F, 1.0F); + renderSplashBackground(context); - int w = (int) (d * 4); - if (this.reloading) { - float elapsedTime = (float) (Util.getMeasuringTimeMs() - this.reloadStartTime) / 1000.0F; - - verticalPosition = (float) MathHelper.lerp(elapsedTime / 4.0F, d, 0); - } + alpha = MathHelper.clamp(alpha, 0.0F, 1.0F); + RenderSystem.disableDepthTest(); + RenderSystem.depthMask(false); RenderSystem.enableBlend(); RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.defaultBlendFunc(); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha); - context.drawTexture(CLIENT_LOGO_TEXTURE, (int) (this.client.getWindow().getScaledWidth() * 0.5D) - (w / 2) - 12, (int) (d - verticalPosition), w + 5, w / 2, 0, 0, 1024, 512, 1024, 512); + int size = 100; + float halfScreenWidth = i/2.0f; + float halfScreenHeight = j/2.0f; + + context.drawTexture(CLIENT_ICON_TEXTURE, (int) halfScreenWidth - (size / 2), (int) halfScreenHeight - (size / 2), size, size, 0, 0, size, size, size, size); if (HeliosClient.MC.textRenderer != null) { - context.drawText(HeliosClient.MC.textRenderer, subtitleText, (int) (this.client.getWindow().getScaledWidth() * 0.5D) - HeliosClient.MC.textRenderer.getWidth(subtitleText) / 2, w / 2 + HeliosClient.MC.textRenderer.fontHeight + 17, 0xFFFFFF, true); + context.drawText(HeliosClient.MC.textRenderer, subtitleText, (int) halfScreenWidth - (HeliosClient.MC.textRenderer.getWidth(subtitleText) / 2) + 5, (int) halfScreenHeight + size/2 + HeliosClient.MC.textRenderer.fontHeight - 4, 0xFFFFFF, true); } - RenderSystem.defaultBlendFunc(); - RenderSystem.disableBlend(); float t = this.reload.getProgress(); this.progress = MathHelper.clamp(this.progress * 0.95F + t * 0.050000012F, 0.0F, 1.0F); - if (f < 1.0F) { - this.renderProgressBar(context, 1.0F - MathHelper.clamp(f, 0.0F, 1.0F)); - } + //opacity = 1.0F - MathHelper.clamp(f, 0.0F, 1.0F), + this.renderProgressBar(context, size); + + context.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.defaultBlendFunc(); + RenderSystem.disableBlend(); + RenderSystem.depthMask(true); + RenderSystem.enableDepthTest(); if (f >= 2.0F) { this.client.setOverlay(null); @@ -176,9 +162,9 @@ else if (this.reloading) if (this.reloadCompleteTime == -1L && this.reload.isComplete() && (!this.reloading || g >= 2.0F)) { try { this.reload.throwException(); - // this.exceptionHandler.accept(Optional.empty()); + this.exceptionHandler.accept(Optional.empty()); } catch (Throwable var23) { - // this.exceptionHandler.accept(Optional.of(var23)); + this.exceptionHandler.accept(Optional.of(var23)); } this.reloadCompleteTime = Util.getMeasuringTimeMs(); @@ -186,31 +172,30 @@ else if (this.reloading) this.client.currentScreen.init(this.client, context.getScaledWindowWidth(), context.getScaledWindowHeight()); } } - - ci.cancel(); } @Unique - private void renderProgressBar(DrawContext drawContext, float opacity) { + private void renderProgressBar(DrawContext drawContext, int logo_size) { int width = drawContext.getScaledWindowWidth(); int height = drawContext.getScaledWindowHeight(); - int progressBarHeight = 2; - - int minX = 0; - int minY = height - progressBarHeight; + Renderer2D.setDrawContext(drawContext); - int filledWidth = MathHelper.ceil((float) width * this.progress); + float roundX = (float) (width/2.0f - (logo_size / 2.0) - (width * 0.2f)); + float roundY = (float) (height/2.0f - (logo_size / 2.0) + logo_size + 18); + float backgroundWidth = (width/2.0f - roundX) * 2; - int j = Math.round(opacity * 255.0F); + float sliderWidth = MathHelper.ceil(backgroundWidth * this.progress); - if (filledWidth <= 0 || height <= 0 || minY <= 0) { + if(backgroundWidth <= 0 || sliderWidth <= 0){ return; } - Renderer2D.setDrawContext(drawContext); - Renderer2D.drawRectangleWithShadow(drawContext.getMatrices(), minX, minY, filledWidth, height, withAlpha(ColorUtils.getRainbowColor().getRGB(), j), 3); + Renderer2D.drawRoundedRectangle(drawContext.getMatrices().peek().getPositionMatrix(),roundX, roundY, backgroundWidth,20,5, Color.ORANGE.getRGB()); + int sliderColor = client.options.getMonochromeLogo().getValue() ? Color.BLACK.getRGB() : Color.WHITE.getRGB(); + Renderer2D.drawRoundedRectangleWithShadow(drawContext.getMatrices(), roundX + 3, roundY + 2, sliderWidth - 6, 15.4f,5,25, sliderColor); + if (HeliosClient.MC.textRenderer == null) return; @@ -219,11 +204,10 @@ private void renderProgressBar(DrawContext drawContext, float opacity) { String progressText = progressPercentage + "%"; - int textX = width - HeliosClient.MC.textRenderer.getWidth(progressText) - 5; - int textY = minY - HeliosClient.MC.textRenderer.fontHeight; + int textX = (int) (width/2.0f - HeliosClient.MC.textRenderer.getWidth(progressText)/2.0f); + int textY = (int) (roundY + 20 + HeliosClient.MC.textRenderer.fontHeight); drawContext.drawText(HeliosClient.MC.textRenderer, progressText, textX, textY, 0xFFFFFF, true); } - -} +} \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/mixin/MixinWorldRenderer.java b/src/main/java/dev/heliosclient/mixin/MixinWorldRenderer.java index 20be6137..f35000be 100644 --- a/src/main/java/dev/heliosclient/mixin/MixinWorldRenderer.java +++ b/src/main/java/dev/heliosclient/mixin/MixinWorldRenderer.java @@ -5,7 +5,7 @@ import dev.heliosclient.module.modules.render.ESP; import dev.heliosclient.module.modules.render.Freecam; import dev.heliosclient.module.modules.render.NoRender; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.*; diff --git a/src/main/java/dev/heliosclient/module/modules/chat/ChatHighlight.java b/src/main/java/dev/heliosclient/module/modules/chat/ChatHighlight.java index 33ae674f..34829104 100644 --- a/src/main/java/dev/heliosclient/module/modules/chat/ChatHighlight.java +++ b/src/main/java/dev/heliosclient/module/modules/chat/ChatHighlight.java @@ -10,7 +10,7 @@ import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.module.settings.StringListSetting; import dev.heliosclient.system.Friend; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.inputbox.InputBox; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; diff --git a/src/main/java/dev/heliosclient/module/modules/chat/Spammer.java b/src/main/java/dev/heliosclient/module/modules/chat/Spammer.java index 10e2fb93..4b15f5e7 100644 --- a/src/main/java/dev/heliosclient/module/modules/chat/Spammer.java +++ b/src/main/java/dev/heliosclient/module/modules/chat/Spammer.java @@ -11,8 +11,8 @@ import dev.heliosclient.system.UniqueID; import dev.heliosclient.system.config.Config; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.FileUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.inputbox.InputBox; import dev.heliosclient.util.misc.MapReader; import dev.heliosclient.util.timer.TickTimer; diff --git a/src/main/java/dev/heliosclient/module/modules/combat/AimAssist.java b/src/main/java/dev/heliosclient/module/modules/combat/AimAssist.java index b698bf63..65d34655 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/AimAssist.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/AimAssist.java @@ -238,7 +238,7 @@ public void simulateRotationLook(double range, boolean ignoreTeammate, LivingEnt LivingEntity targetEntity = entity; if (targetEntity == null) { - TargetUtils.getInstance().setSortMethod((SortMethod) sort.getOption()); + TargetUtils.getInstance().sortMethod((SortMethod) sort.getOption()); TargetUtils.getInstance().setRange(range); targetEntity = (LivingEntity) TargetUtils.getInstance().getNewTargetIfNull(entity1 -> entity1 instanceof LivingEntity e1 && diff --git a/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java b/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java index cd6fe63f..86f8bd6c 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/AutoTotem.java @@ -12,16 +12,22 @@ import dev.heliosclient.module.settings.KeyBind; import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.DamageUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.timer.TickTimer; +import net.minecraft.entity.EntityType; import net.minecraft.item.Items; +import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; +import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; +import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; import net.minecraft.network.packet.s2c.play.EntityStatusS2CPacket; +import net.minecraft.screen.GenericContainerScreenHandler; import net.minecraft.screen.slot.SlotActionType; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; public class AutoTotem extends Module_ { private final SettingGroup sgGeneral = new SettingGroup("General"); @@ -66,6 +72,34 @@ public class AutoTotem extends Module_ { .onSettingChange(this) .build() ); + BooleanSetting immediateNearCrystal = sgGeneral.add(new BooleanSetting.Builder() + .name("Immediate Near Crystal") + .description("Will autototem instantly as soon as we find a crystal near you that can damage you") + .defaultValue(false) + .onSettingChange(this) + .build() + ); + BooleanSetting stopMotion = sgGeneral.add(new BooleanSetting.Builder() + .name("Stop Motion") + .description("This will immediately stop you before switching to a totem") + .defaultValue(false) + .onSettingChange(this) + .build() + ); + BooleanSetting stopSprint = sgGeneral.add(new BooleanSetting.Builder() + .name("Stop Sprint") + .description("This will send a packet to the server to stop sprinting") + .defaultValue(false) + .onSettingChange(this) + .build() + ); + BooleanSetting swapInstead = sgGeneral.add(new BooleanSetting.Builder() + .name("Swap Instead") + .description("This will try to swap the totem instead of picking and moving it") + .defaultValue(false) + .onSettingChange(this) + .build() + ); KeyBind totemSwitchKey = sgGeneral.add(new KeyBind.Builder() .name("Totem Switch Key") .description("When you press this key, you will automatically switch to a totem") @@ -105,7 +139,6 @@ public void onKey(KeyPressedEvent e){ } } - //High @SubscribeEvent(priority = SubscribeEvent.Priority.HIGHEST) public void onTick(TickEvent.WORLD event) { if(!HeliosClient.shouldUpdate()) return; @@ -132,26 +165,64 @@ public void onTick(TickEvent.WORLD event) { } } + @SubscribeEvent(priority = SubscribeEvent.Priority.HIGH) + public void onPacketReceive(PacketEvent.RECEIVE event) { + if(event.packet instanceof EntitySpawnS2CPacket p){ + if(p.getEntityType() == EntityType.END_CRYSTAL){ + Vec3d crystalPos = new Vec3d(p.getX(),p.getY(),p.getZ()); + boolean willCrystalDamage = mc.player.getPos().squaredDistanceTo(crystalPos) < DamageUtils.CRYSTAL_POWER * DamageUtils.CRYSTAL_POWER; + if(willCrystalDamage){ + if(immediateNearCrystal.value){ + doAutoTotem(); + return; + } + + if(DamageUtils.calculateCrystalDamage(crystalPos,mc.player) >= healthThreshold.get()){ + timer.setTicks(delay.getInt()); + } + } + } + } + } + public boolean doAutoTotem(){ + if(mc.player.currentScreenHandler instanceof GenericContainerScreenHandler)return false; + boolean offhandHasItem = !mc.player.getOffHandStack().isEmpty(); int itemSlot = InventoryUtils.findItemInInventory(Items.TOTEM_OF_UNDYING); if(itemSlot == -1 || itemSlot == InventoryUtils.OFFHAND || mc.player.getOffHandStack().getItem() == Items.TOTEM_OF_UNDYING){ return false; } + if(stopMotion.value){ + mc.player.setVelocity(0,mc.player.getVelocity().y,0); + } + + if(stopSprint.value){ + mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.STOP_SPRINTING)); + } //if is hotbar then swap item with offhand super-fast. if(itemSlot >= 0 && itemSlot < 9){ - InventoryUtils.swapToSlot(itemSlot,true); + int prevSlot = mc.player.getInventory().selectedSlot; + mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(itemSlot)); + mc.player.getInventory().selectedSlot = itemSlot; mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN)); - InventoryUtils.swapBackHotbar(); + mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(prevSlot)); + mc.player.getInventory().selectedSlot = prevSlot; return true; - }else if(mc.player.playerScreenHandler == mc.player.currentScreenHandler){ + } else if(mc.player.playerScreenHandler == mc.player.currentScreenHandler){ + if(swapInstead.value) { + mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, itemSlot, 40, SlotActionType.SWAP, mc.player); + return true; + } + if(offhandHasItem){ mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId,InventoryUtils.OFFHAND,0,SlotActionType.PICKUP,mc.player); } InventoryUtils.moveItem(itemSlot,InventoryUtils.OFFHAND, SlotActionType.PICKUP, SlotActionType.PICKUP); } + return true; } diff --git a/src/main/java/dev/heliosclient/module/modules/combat/BowSpam.java b/src/main/java/dev/heliosclient/module/modules/combat/BowSpam.java index b68714c7..0317c72f 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/BowSpam.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/BowSpam.java @@ -14,7 +14,7 @@ public class BowSpam extends Module_ { private final SettingGroup sgGeneral = new SettingGroup("General"); private final DoubleSetting baseCharge = sgGeneral.add(new DoubleSetting.Builder() - .name("Charge ") + .name("Charge") .description("Min charge of the bow before releasing (in ticks)") .range(3, 20) .onSettingChange(this) diff --git a/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java b/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java index 751d595c..f3fce720 100644 --- a/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java +++ b/src/main/java/dev/heliosclient/module/modules/combat/TriggerBot.java @@ -12,12 +12,12 @@ import dev.heliosclient.module.settings.*; import dev.heliosclient.module.settings.lists.EntityTypeListSetting; import dev.heliosclient.system.TickRate; -import dev.heliosclient.util.misc.SortMethod; -import dev.heliosclient.util.timer.TickTimer; import dev.heliosclient.util.entity.TargetUtils; +import dev.heliosclient.util.misc.SortMethod; import dev.heliosclient.util.player.PlayerUtils; import dev.heliosclient.util.render.TargetRenderer; import dev.heliosclient.util.render.color.QuadColor; +import dev.heliosclient.util.timer.TickTimer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; @@ -157,7 +157,7 @@ public TriggerBot() { addQuickSettings(sgGeneral.getSettings()); - targetFinder.setSortMethod(SortMethod.LowestDistance); + targetFinder.sortMethod(SortMethod.LowestDistance); } @Override diff --git a/src/main/java/dev/heliosclient/module/modules/misc/CapeModule.java b/src/main/java/dev/heliosclient/module/modules/misc/CapeModule.java index fd122013..8add4a1e 100644 --- a/src/main/java/dev/heliosclient/module/modules/misc/CapeModule.java +++ b/src/main/java/dev/heliosclient/module/modules/misc/CapeModule.java @@ -8,8 +8,8 @@ import dev.heliosclient.module.settings.*; import dev.heliosclient.module.settings.buttonsetting.ButtonSetting; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.AnimationUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.inputbox.InputBox; import java.util.List; @@ -28,7 +28,7 @@ public class CapeModule extends Module_ { public DropDownSetting getCapeFrom = sgCape.add(new DropDownSetting.Builder() .name("Get Cape from") .description("Gets your favourite CURRENT_PLAYER_CAPE from the following places. Need valid UUID or player name") - .value(List.of(CapeManager.CapeType.values())) + .value(List.of(CapeManager.CapeOrigin.values())) .defaultListIndex(0) .addOptionToolTip("None") .addOptionToolTip("Fetch cape from optifine api") @@ -43,7 +43,7 @@ public class CapeModule extends Module_ { .value("") .characterLimit(16) .inputMode(InputBox.InputMode.DIGITS_AND_CHARACTERS_AND_UNDERSCORE) - .shouldRender(() -> (CapeManager.CapeType.values()[getCapeFrom.value] != CapeManager.CapeType.NONE) && (CapeManager.CapeType.values()[getCapeFrom.value] == CapeManager.CapeType.OPTIFINE)) + .shouldRender(() -> (CapeManager.CapeOrigin.values()[getCapeFrom.value] != CapeManager.CapeOrigin.LOCAL) && (CapeManager.CapeOrigin.values()[getCapeFrom.value] == CapeManager.CapeOrigin.OPTIFINE)) .onSettingChange(this) .build() ); @@ -53,7 +53,7 @@ public class CapeModule extends Module_ { .value("") .characterLimit(37) .inputMode(InputBox.InputMode.ALL) - .shouldRender(() -> (CapeManager.CapeType.values()[getCapeFrom.value] != CapeManager.CapeType.NONE) && (CapeManager.CapeType.values()[getCapeFrom.value] != CapeManager.CapeType.OPTIFINE)) + .shouldRender(() -> (CapeManager.CapeOrigin.values()[getCapeFrom.value] != CapeManager.CapeOrigin.LOCAL) && (CapeManager.CapeOrigin.values()[getCapeFrom.value] != CapeManager.CapeOrigin.OPTIFINE)) .onSettingChange(this) .build() ); @@ -102,11 +102,11 @@ public CapeModule() { loadCapes.addButton("Get Cape", 0, 0, () -> { try { - CapeManager.CapeType capeType = CapeManager.CapeType.values()[getCapeFrom.value]; - if (shouldUsePlayerName() && capeType == CapeManager.CapeType.OPTIFINE) { - CapeManager.getCapes(capeType, playerName.value, null); + CapeManager.CapeOrigin CapeOrigin = CapeManager.CapeOrigin.values()[getCapeFrom.value]; + if (shouldUsePlayerName() && CapeOrigin == CapeManager.CapeOrigin.OPTIFINE) { + CapeManager.getCapes(CapeOrigin, playerName.value, null); } else if (shouldUseUUID()) { - CapeManager.getCapes(capeType, null, UUID.value); + CapeManager.getCapes(CapeOrigin, null, UUID.value); } capes.iSettingChange.onSettingChange(capes); @@ -149,7 +149,7 @@ public boolean shouldUsePlayerName() { public void onEnable() { super.onEnable(); if(mc.player != null && capes.getOption() != null) { - CapeManager.capeTextureManager.assignCapeToPlayer(mc.player.getUuid(), capes.getOption().toString().toLowerCase()); + CapeManager.getTextureManager().assignCapeToPlayer(mc.player.getUuid(), capes.getOption().toString().toLowerCase()); } setCapes(); } @@ -159,7 +159,7 @@ public void onSettingChange(Setting setting) { super.onSettingChange(setting); if(setting == capes && mc.player != null && capes.getOption() != null){ - CapeManager.capeTextureManager.assignCapeToPlayer(mc.player.getUuid(),capes.getOption().toString().toLowerCase()); + CapeManager.getTextureManager().assignCapeToPlayer(mc.player.getUuid(),capes.getOption().toString().toLowerCase()); } setCapes(); } @@ -174,7 +174,7 @@ public void onLoad() { setCapes(); if(mc.player != null && capes.getOption() != null) { - CapeManager.capeTextureManager.assignCapeToPlayer(mc.player.getUuid(), capes.getOption().toString().toLowerCase()); + CapeManager.getTextureManager().assignCapeToPlayer(mc.player.getUuid(), capes.getOption().toString().toLowerCase()); } } } diff --git a/src/main/java/dev/heliosclient/module/modules/misc/ChestAura.java b/src/main/java/dev/heliosclient/module/modules/misc/ChestAura.java index 2d613d34..4f90db60 100644 --- a/src/main/java/dev/heliosclient/module/modules/misc/ChestAura.java +++ b/src/main/java/dev/heliosclient/module/modules/misc/ChestAura.java @@ -78,7 +78,7 @@ public void onTick(TickEvent.PLAYER e) { public void interact(BlockEntity blockEntity) { BlockPos pos = blockEntity.getPos(); - BlockHitResult blockInteractResult = new BlockHitResult(pos.toCenterPos(), BlockUtils.getClosestFace(pos), pos, false); + BlockHitResult blockInteractResult = new BlockHitResult(pos.toCenterPos(), BlockUtils.getBlockDirection(pos), pos, false); ActionResult result = mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, blockInteractResult); diff --git a/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java b/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java index 5fe07e3f..c3f6cf29 100644 --- a/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java +++ b/src/main/java/dev/heliosclient/module/modules/misc/Fucker.java @@ -1,5 +1,6 @@ package dev.heliosclient.module.modules.misc; +import dev.heliosclient.HeliosClient; import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.TickEvent; import dev.heliosclient.module.Categories; @@ -13,11 +14,13 @@ */ public class Fucker extends Module_ { public Fucker() { - super("Fucker", "Breaks beds for now", Categories.MISC); + super("Fucker", "Does not break anything", Categories.MISC); } @SubscribeEvent - public void onTick(TickEvent.PLAYER event) { + public void onTick(TickEvent.CLIENT.PRE event) { + if(!HeliosClient.shouldUpdate()) return; + BlockPos bedPos = EntityUtils.getNearestBed(mc.world, mc.player, (int) mc.interactionManager.getReachDistance()); if (bedPos == null) return; diff --git a/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java b/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java index 29747786..41d38664 100644 --- a/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java +++ b/src/main/java/dev/heliosclient/module/modules/misc/NotificationModule.java @@ -95,6 +95,10 @@ public void onDisable() { public boolean displayModuleNotification(){ return HeliosClient.shouldSendNotification() && moduleNotification.value; } + public boolean displayClientNotifications(){ + return HeliosClient.shouldSendNotification() && moduleNotification.value; + } + @Override public void onSettingChange(Setting setting) { diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java b/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java index 370918b7..83b401c7 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Scaffold.java @@ -8,8 +8,8 @@ import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.*; import dev.heliosclient.module.settings.lists.BlockListSetting; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.BlockUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.PlayerUtils; import dev.heliosclient.util.render.GradientBlockRenderer; @@ -150,6 +150,7 @@ public class Scaffold extends Module_ { .description("Silently switches to the item") .onSettingChange(this) .defaultValue(false) + .shouldRender(()-> autoSwitch.value) .build() ); /* Render */ @@ -208,7 +209,7 @@ public void onEnable() { @SubscribeEvent public void onTick(TickEvent.PLAYER event) { - if (towerMode.getOption() != TowerMode.None && mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed()) { + if (towerMode.getOption() != TowerMode.None && mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && !mc.world.getBlockState(mc.player.getBlockPos().down(2)).isReplaceable()) { //Only tower if there is air above. if (!mc.world.getBlockCollisions(mc.player,mc.player.getBoundingBox().stretch(0,0.4f,0)).iterator().hasNext()) { if (whileMoving.value || !PlayerUtils.isMoving(mc.player)) { diff --git a/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java b/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java index d8493f30..1cc55170 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/Sprint.java @@ -12,7 +12,7 @@ public class Sprint extends Module_ { SettingGroup sgGeneral = new SettingGroup("General"); - BooleanSetting strictMode = sgGeneral.add(new BooleanSetting("Strict Mode", "Only sprints when you are moving", this, true)); + BooleanSetting strictMode = sgGeneral.add(new BooleanSetting("Strict Mode", "Only sprints when you are moving and other checks", this, true)); BooleanSetting keepSprint = sgGeneral.add(new BooleanSetting("Keep Sprint", "Keeps sprinting even after attacking", this, false)); public Sprint() { @@ -41,8 +41,9 @@ public boolean strictModeCheck() { if(!strictMode.value){ return mc.currentScreen == null; } + return (mc.player.forwardSpeed != 0 || mc.player.sidewaysSpeed != 0) && - !mc.player.horizontalCollision && + (!mc.player.horizontalCollision || mc.player.collidedSoftly) && !mc.player.isTouchingWater() && !mc.player.isSubmergedInWater() && (mc.currentScreen == null || ModuleManager.get(GuiMove.class).isActive()); diff --git a/src/main/java/dev/heliosclient/module/modules/movement/TargetStrafe.java b/src/main/java/dev/heliosclient/module/modules/movement/TargetStrafe.java index 2389c231..dc41f102 100644 --- a/src/main/java/dev/heliosclient/module/modules/movement/TargetStrafe.java +++ b/src/main/java/dev/heliosclient/module/modules/movement/TargetStrafe.java @@ -10,8 +10,8 @@ import dev.heliosclient.module.modules.world.Teams; import dev.heliosclient.module.modules.world.Timer; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.misc.SortMethod; import dev.heliosclient.util.entity.TargetUtils; +import dev.heliosclient.util.misc.SortMethod; import dev.heliosclient.util.player.PlayerUtils; import dev.heliosclient.util.player.RotationUtils; import net.minecraft.entity.Entity; @@ -26,10 +26,7 @@ import java.util.List; -//IDK why I added this public class TargetStrafe extends Module_ { - - static boolean strafeDirectionChanged = false; SettingGroup sgGeneral = new SettingGroup("General"); SettingGroup sgEntities = new SettingGroup("Entities"); DropDownSetting sort = sgGeneral.add(new DropDownSetting.Builder() @@ -51,9 +48,10 @@ public class TargetStrafe extends Module_ { ); DoubleSetting speed = sgGeneral.add(new DoubleSetting.Builder() .name("Speed") - .description("Speed of the movement") + .description("Speed of strafing movement") .onSettingChange(this) .defaultValue(1) + .value(1) .min(0.0) .max(3) .roundingPlace(2) @@ -136,6 +134,7 @@ public class TargetStrafe extends Module_ { BooleanSetting tamed = sgEntities.add(new BooleanSetting("Tamed", "Aim at tamed", this, false, () -> true, true)); BooleanSetting others = sgEntities.add(new BooleanSetting("Other", "Aim at others", this, false, () -> true, true)); + boolean strafeDirectionChanged = false; public TargetStrafe() { super("TargetStrafe", "Strafe around a target", Categories.MOVEMENT); @@ -161,6 +160,7 @@ private boolean isEntityVisible(Entity entity) { return PlayerUtils.canSeeEntity(entity) || entity.isInvisible(); } + private boolean isAttackable(Entity entity) { if (!onlyAttackAttackable.value) { return true; @@ -168,6 +168,7 @@ private boolean isAttackable(Entity entity) { return entity.isAttackable(); } + private boolean isFriend(Entity entity) { if (!ignoreFriend.value || !(entity instanceof PlayerEntity)) { return false; @@ -193,25 +194,24 @@ public void onTick(TickEvent.PLAYER event) { if (legit.value) return; - TargetUtils.getInstance().setSortMethod((SortMethod) sort.getOption()); + TargetUtils.getInstance().sortMethod((SortMethod) sort.getOption()); TargetUtils.getInstance().setRange(range.value); Entity entity = TargetUtils.getInstance().getNewTargetIfNull(e -> !isBlackListed(e) && isEntityVisible(e) && isAttackable(e) && mc.player.distanceTo(e) <= range.value && (onlyAttackAttackable.value && e.isAttackable()) && !isFriend(e), true); - if (!(entity instanceof LivingEntity livingEntity) || (ignoreTeammate.value && ModuleManager.get(Teams.class).isInMyTeam(livingEntity))) { + if (!TargetUtils.getInstance().isLivingEntity() || (ignoreTeammate.value && ModuleManager.get(Teams.class).isInMyTeam((LivingEntity) entity))) { return; } if (entity.distanceTo(mc.player) <= range.value) { - if (mc.player == null || !livingEntity.isAlive()) return; + if (mc.player == null || !entity.isAlive()) return; if (timer.value != 1.0) { ModuleManager.get(Timer.class).setOverride(timer.value); } - if (!legit.value) { - strafeAround(entity); - } + strafeAround(entity); + // jump while strafing if (jump.value && mc.player.isOnGround()) { mc.player.jump(); @@ -219,6 +219,7 @@ public void onTick(TickEvent.PLAYER event) { } } + //Legit mode simulates target-strafe by modifying the input @SubscribeEvent public void onKeyBoardInput(KeyboardInputEvent event) { if(mc.options.leftKey.isPressed()){ @@ -227,14 +228,13 @@ public void onKeyBoardInput(KeyboardInputEvent event) { strafeDirectionChanged = false; } - if (!legit.value) return; - if (mc.player == null) return; + if (!legit.value || mc.player == null) return; - TargetUtils.getInstance().setSortMethod((SortMethod) sort.getOption()); + TargetUtils.getInstance().sortMethod((SortMethod) sort.getOption()); TargetUtils.getInstance().setRange(range.value); Entity entity = TargetUtils.getInstance().getNewTargetIfNull(e -> !isBlackListed(e) && isEntityVisible(e) && isAttackable(e) && mc.player.distanceTo(e) <= range.value && (onlyAttackAttackable.value && e.isAttackable()), true); - if (!(entity instanceof LivingEntity livingEntity) || (ignoreTeammate.value && ModuleManager.get(Teams.class).isInMyTeam(livingEntity))) { + if (!TargetUtils.getInstance().isLivingEntity() || (ignoreTeammate.value && ModuleManager.get(Teams.class).isInMyTeam((LivingEntity) entity))) { return; } @@ -242,14 +242,10 @@ public void onKeyBoardInput(KeyboardInputEvent event) { ModuleManager.get(Timer.class).setOverride(timer.value); } - //Look at target only if AimAssist is not enabled - //Major issue with this would be desync of target entities between AimAssist and target strafe. - //Could be fixed by having a TargetUtils class to handle targets which should keep them both in sync - //and every other module. - RotationUtils.lookAt(entity.getBoundingBox().getCenter()); + RotationUtils.instaLookAt(entity.getBoundingBox().getCenter()); //Move forward if player is not nearby to the entity enough - if (mc.player.distanceTo(entity) > range.value - 0.5) { + if (mc.player.distanceTo(entity) > range.value - 1) { event.pressingForward = true; } else { event.pressingBack = true; @@ -267,10 +263,14 @@ public void onKeyBoardInput(KeyboardInputEvent event) { strafeDirectionChanged = !strafeDirectionChanged; } - // jump while strafing - if (jump.value && !mc.player.isOnGround()) { - mc.player.jump(); + if(jump.value){ + event.jumping = true; } + + // jump while strafing + //if (jump.value && !mc.player.isOnGround()) { + // mc.player.jump(); + //} event.cancel(); } @@ -306,10 +306,11 @@ public void strafeAround(Entity target) { } // Rotate player to face the target - RotationUtils.lookAt(target, RotationUtils.LookAtPos.CENTER); + RotationUtils.instaLookAt(target, RotationUtils.LookAtPos.CENTER); } + //unused public void doMotionStrafe(Vec3d playerPos, Entity entity, Vec3d targetPos) { double dx = targetPos.x - playerPos.x; double dz = targetPos.z - playerPos.z; diff --git a/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java b/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java index 24949623..6b6ae9dc 100644 --- a/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java +++ b/src/main/java/dev/heliosclient/module/modules/player/AutoEat.java @@ -10,8 +10,8 @@ import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.module.settings.lists.ItemListSetting; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.BlockUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.PlayerUtils; import net.minecraft.item.FoodComponent; diff --git a/src/main/java/dev/heliosclient/module/modules/player/FakeLag.java b/src/main/java/dev/heliosclient/module/modules/player/FakeLag.java index c3b570f0..af89ac8a 100644 --- a/src/main/java/dev/heliosclient/module/modules/player/FakeLag.java +++ b/src/main/java/dev/heliosclient/module/modules/player/FakeLag.java @@ -9,7 +9,7 @@ import dev.heliosclient.module.settings.BooleanSetting; import dev.heliosclient.module.settings.DoubleSetting; import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; import dev.heliosclient.util.timer.TickTimer; @@ -116,4 +116,8 @@ public void sendPackets() { storedPackets.clear(); } } + + public Vec3d getFakeLagPos(){ + return lagPos; + } } diff --git a/src/main/java/dev/heliosclient/module/modules/render/BlockESP.java b/src/main/java/dev/heliosclient/module/modules/render/BlockESP.java index 21ed0808..5b7f20d6 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/BlockESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/BlockESP.java @@ -18,7 +18,7 @@ import dev.heliosclient.util.blocks.BlockUtils; import dev.heliosclient.util.blocks.ChunkChecker; import dev.heliosclient.util.blocks.ChunkUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.LineColor; import dev.heliosclient.util.render.color.QuadColor; diff --git a/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java b/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java index 8bfdd23c..4e383346 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java +++ b/src/main/java/dev/heliosclient/module/modules/render/BlockSelection.java @@ -8,7 +8,7 @@ import dev.heliosclient.module.settings.DoubleSetting; import dev.heliosclient.module.settings.RGBASetting; import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; import net.minecraft.block.BlockState; diff --git a/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java b/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java index b180fc78..7f1870d6 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java +++ b/src/main/java/dev/heliosclient/module/modules/render/BreakIndicator.java @@ -7,7 +7,7 @@ import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; import net.minecraft.block.BlockState; diff --git a/src/main/java/dev/heliosclient/module/modules/render/ESP.java b/src/main/java/dev/heliosclient/module/modules/render/ESP.java index b4862fcf..8ca12ef5 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/ESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/ESP.java @@ -9,7 +9,7 @@ import dev.heliosclient.module.modules.world.Teams; import dev.heliosclient.module.settings.*; import dev.heliosclient.system.Friend; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.entity.FreeCamEntity; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.WireframeEntityRenderer; diff --git a/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java b/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java index 7802a78d..ccd6595d 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java +++ b/src/main/java/dev/heliosclient/module/modules/render/Fullbright.java @@ -59,7 +59,7 @@ public void onEnable() { } @Override - public void onSettingChange(Setting setting) { + public void onSettingChange(Setting setting) { super.onSettingChange(setting); if (active.value) { if (mode.value == 0 && mc.player != null) { 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 1f89cc63..9f27cc7e 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/GUI.java +++ b/src/main/java/dev/heliosclient/module/modules/render/GUI.java @@ -116,7 +116,7 @@ public class GUI extends Module_ { ); public BooleanSetting background = sgVisuals.add(new BooleanSetting.Builder() .name("Background") - .description("Draws a very faint background behind the clickGUI with the clickGUI primary color") + .description("Draws a very faint background behind the clickGUI with the clickGUI primary color (only visible in game)") .value(false) .onSettingChange(this) .build() diff --git a/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java b/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java index 919a6d4b..907c3099 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/HoleESP.java @@ -6,8 +6,8 @@ import dev.heliosclient.module.Categories; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.HoleUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; import net.minecraft.util.math.Box; @@ -198,6 +198,8 @@ public class HoleESP extends Module_ { .build() ); + List holes = new ArrayList<>(); + public HoleESP() { super("HoleESP", "Displays holes in your area", Categories.RENDER); addSettingGroup(sgGeneral); @@ -207,10 +209,10 @@ public HoleESP() { addQuickSettings(sgColor.getSettings()); } - List holes = new ArrayList<>(); - @SubscribeEvent - public void onTick(TickEvent.PLAYER event) { + public void onTick(TickEvent.WORLD event) { + if(mc.player == null) return; + holes = HoleUtils.getHoles((int) holeRange.value, (int) holeRangeVertical.value,quads.value).stream().toList(); } diff --git a/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java b/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java index 9ee1fbec..01a86fb1 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/LightLevelESP.java @@ -6,8 +6,8 @@ import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.DoubleSetting; import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.BlockIterator; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/dev/heliosclient/module/modules/render/LogOutSpot.java b/src/main/java/dev/heliosclient/module/modules/render/LogOutSpot.java index 7a0265b8..900187db 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/LogOutSpot.java +++ b/src/main/java/dev/heliosclient/module/modules/render/LogOutSpot.java @@ -11,8 +11,8 @@ import dev.heliosclient.module.settings.RGBASetting; import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; import dev.heliosclient.util.render.Renderer3D; diff --git a/src/main/java/dev/heliosclient/module/modules/render/NameTags.java b/src/main/java/dev/heliosclient/module/modules/render/NameTags.java index d5477e26..48ae6fe1 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/NameTags.java +++ b/src/main/java/dev/heliosclient/module/modules/render/NameTags.java @@ -10,8 +10,8 @@ import dev.heliosclient.module.Module_; import dev.heliosclient.module.modules.world.Teams; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.entity.FreeCamEntity; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; @@ -262,6 +262,7 @@ public static String getHealthColorInString(float health) { @SubscribeEvent(priority = SubscribeEvent.Priority.HIGHEST) public void entityLabelRenderEvent(EntityLabelRenderEvent event) { + event.setCanceled(false); if (event.getEntity() instanceof FreeCamEntity) return; if (!(event.getEntity() instanceof LivingEntity entity)) return; @@ -269,14 +270,8 @@ public void entityLabelRenderEvent(EntityLabelRenderEvent event) { if (entity instanceof PlayerEntity && !players.value) return; if (entity instanceof MobEntity && !mobs.value) return; - if (ignoreArmorStand.value && entity instanceof ArmorStandEntity) { - event.setCanceled(false); - return; - } - if (ignoreInvisible.value && entity.isInvisible()) { - event.setCanceled(false); - return; - } + if (ignoreArmorStand.value && entity instanceof ArmorStandEntity) return; + if (ignoreInvisible.value && entity.isInvisible()) return; event.setCanceled(true); diff --git a/src/main/java/dev/heliosclient/module/modules/render/StorageESP.java b/src/main/java/dev/heliosclient/module/modules/render/StorageESP.java index 4ff5813b..adab6340 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/StorageESP.java +++ b/src/main/java/dev/heliosclient/module/modules/render/StorageESP.java @@ -6,8 +6,8 @@ import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.BooleanSetting; import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.ChunkUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.LineColor; import dev.heliosclient.util.render.color.QuadColor; diff --git a/src/main/java/dev/heliosclient/module/modules/render/Test.java b/src/main/java/dev/heliosclient/module/modules/render/Test.java index 5b2d2ed0..286abee8 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/Test.java +++ b/src/main/java/dev/heliosclient/module/modules/render/Test.java @@ -119,6 +119,18 @@ public void render(RenderEvent event) { if (GradientRounded.value) Renderer2D.drawRoundedGradientRectangleWithShadow(drawContext.getMatrices(), 22, 20, 40, 40, Color.BLUE, Color.WHITE, Color.BLACK, Color.GRAY, 2, 20, Color.WHITE); + + Color[] array = new Color[]{ + Color.RED, + Color.ORANGE, + Color.YELLOW, + Color.GREEN, + Color.BLUE, + Color.CYAN, + Color.PINK + }; + + Renderer2D.drawRoundedGradientRectangle(drawContext.getMatrices().peek().getPositionMatrix(),array, 22, 20, 40, 40, 2, true,true,true,true); } @SubscribeEvent diff --git a/src/main/java/dev/heliosclient/module/modules/render/hiteffect/HitEffectParticle.java b/src/main/java/dev/heliosclient/module/modules/render/hiteffect/HitEffectParticle.java index 7f94d611..f2fe6be5 100644 --- a/src/main/java/dev/heliosclient/module/modules/render/hiteffect/HitEffectParticle.java +++ b/src/main/java/dev/heliosclient/module/modules/render/hiteffect/HitEffectParticle.java @@ -1,6 +1,6 @@ package dev.heliosclient.module.modules.render.hiteffect; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.client.util.math.MatrixStack; import java.awt.*; diff --git a/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java b/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java index c83bf5d0..a0aad719 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java +++ b/src/main/java/dev/heliosclient/module/modules/world/PacketMine.java @@ -1,5 +1,6 @@ package dev.heliosclient.module.modules.world; +import dev.heliosclient.HeliosClient; import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.TickEvent; import dev.heliosclient.event.events.block.BeginBreakingBlockEvent; @@ -9,8 +10,8 @@ import dev.heliosclient.module.Module_; import dev.heliosclient.module.modules.render.BreakIndicator; import dev.heliosclient.module.settings.*; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.BlockUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.RotationUtils; import dev.heliosclient.util.render.Renderer3D; @@ -154,33 +155,43 @@ public void onEnable() { @Override public void onDisable() { super.onDisable(); - if (mc.interactionManager != null) - mc.interactionManager.syncSelectedSlot(); + if (shouldUpdateSlot) { + mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(mc.player.getInventory().selectedSlot)); + shouldUpdateSlot = false; + } miningQueue.clear(); } @SubscribeEvent public void onStartBreakingBlock(BeginBreakingBlockEvent event) { - if (!BlockUtils.canBreak(event.getPos(), mc.world.getBlockState(event.getPos()))) return; + if (!BlockUtils.canBreak(event.getPos())) return; - event.cancel(); swapped = false; + event.cancel(); + miningQueue.add(event.getPos(), event.getDir()); } @SubscribeEvent - public void onTick(TickEvent.PLAYER event) { + public void onTick(TickEvent.CLIENT.PRE event) { + if(!HeliosClient.shouldUpdate()) return; + if (shouldUpdateSlot) { - mc.interactionManager.syncSelectedSlot(); + mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(mc.player.getInventory().selectedSlot)); shouldUpdateSlot = false; } miningQueue.update(); if (!swapped && autoSwitch.value && (!mc.player.isUsingItem() || !notOnUse.value)) { - switchIfNeeded(miningQueue.getNextBlock()); + miningQueue.queue.forEach((pos,info)->{ + if(info.progress >= 1.0f) { + switchIfNeeded(miningQueue.getNextBlock()); + return; + } + }); } } @@ -189,7 +200,6 @@ private boolean shouldRemove(BlockPos pos, Direction direction) { mc.player.getEyePos() .subtract(0.5, 0, 0.5f) .distanceTo(pos.offset(direction).toCenterPos()) > mc.interactionManager.getReachDistance(); - if (isGettingRemoved) { mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, pos, direction)); mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); @@ -237,21 +247,20 @@ void update() { MiningInfo info = queue.get(nextBlock); + mine(nextBlock, info); + //Sometimes the blocks dont get mined but the calculated progress is 1. So we attempt to mine it again from scratch. if(info.progress >= 1.0f && !mc.world.getBlockState(nextBlock).isAir() && reattempt.value){ mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, nextBlock, info.direction)); mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); + if(info.attempts > maxReattempts.getInt()){ - mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, nextBlock, info.direction)); - mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); queue.remove(nextBlock); return; } info.restart(); } - - mine(nextBlock, info); } void clear() { @@ -275,7 +284,7 @@ private void mine(BlockPos pos, MiningInfo info) { sendMinePackets(pos, info); } int slot = InventoryUtils.getFastestTool(mc.world.getBlockState(pos),false); - info.progress += BlockUtils.calcBlockBreakingDelta(mc.world.getBlockState(pos),mc.player.getInventory().getStack(slot != -1 ? slot : mc.player.getInventory().selectedSlot)); + info.progress += BlockUtils.calcBlockBreakingDelta(mc.world.getBlockState(pos),slot != -1 ? slot : mc.player.getInventory().selectedSlot); } private void sendMinePackets(BlockPos pos, MiningInfo info) { @@ -295,6 +304,8 @@ private class MiningInfo { int timer; boolean started; int attempts; + + MiningInfo(Direction dir) { this.direction = dir; restart(); diff --git a/src/main/java/dev/heliosclient/module/modules/world/PaletteExploit.java b/src/main/java/dev/heliosclient/module/modules/world/PaletteExploit.java index 2e8e3ab3..df99b4f3 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/PaletteExploit.java +++ b/src/main/java/dev/heliosclient/module/modules/world/PaletteExploit.java @@ -9,7 +9,7 @@ import dev.heliosclient.module.settings.BooleanSetting; import dev.heliosclient.module.settings.DoubleSetting; import dev.heliosclient.module.settings.SettingGroup; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; import io.netty.buffer.Unpooled; @@ -28,10 +28,10 @@ import java.util.Set; public class PaletteExploit extends Module_ { - private final Set newChunks = Collections.synchronizedSet(new HashSet<>()); - private final Set oldChunks = Collections.synchronizedSet(new HashSet<>()); - private final Set beingUpdatedOldChunks = Collections.synchronizedSet(new HashSet<>()); - private final Set oldGenerationOldChunks = Collections.synchronizedSet(new HashSet<>()); + public final Set newChunks = Collections.synchronizedSet(new HashSet<>()); + public final Set oldChunks = Collections.synchronizedSet(new HashSet<>()); + public final Set beingUpdatedOldChunks = Collections.synchronizedSet(new HashSet<>()); + public final Set oldGenerationOldChunks = Collections.synchronizedSet(new HashSet<>()); SettingGroup sgGeneral = new SettingGroup("General"); public BooleanSetting remove = sgGeneral.add(new BooleanSetting.Builder() @@ -154,7 +154,7 @@ private void renderChunk(Box box, ChunkType type, Direction... exclude) { } } - private int getChunkTypeColor(ChunkType type) { + public int getChunkTypeColor(ChunkType type) { if (type == ChunkType.NEW) { return ColorUtils.changeAlphaGetInt(Color.GREEN.getRGB(), 120); } @@ -437,7 +437,7 @@ public void onChunkData(ChunkDataEvent event) { } - private enum ChunkType { + public enum ChunkType { NEW, OLD, BEING_UPDATED, diff --git a/src/main/java/dev/heliosclient/module/modules/world/TNTIgnite.java b/src/main/java/dev/heliosclient/module/modules/world/TNTIgnite.java index ed858f14..ada1ac6a 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/TNTIgnite.java +++ b/src/main/java/dev/heliosclient/module/modules/world/TNTIgnite.java @@ -8,9 +8,9 @@ import dev.heliosclient.module.settings.DoubleSetting; import dev.heliosclient.module.settings.SettingGroup; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.blocks.BlockIterator; import dev.heliosclient.util.blocks.BlockUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.InventoryUtils; import net.minecraft.block.Blocks; import net.minecraft.item.Items; @@ -113,7 +113,7 @@ public void onTick(TickEvent.PLAYER event) { boolean handHasFlintSteel = InventoryUtils.doesAnyHandStackHas(stack -> stack.getItem() == Items.FLINT_AND_STEEL); if (hasSwitched && handHasFlintSteel) { - mc.interactionManager.interactBlock(mc.player,offHand ? Hand.OFF_HAND : Hand.MAIN_HAND, new BlockHitResult(pos.toCenterPos(), BlockUtils.getClosestFace(pos), pos, false)); + mc.interactionManager.interactBlock(mc.player,offHand ? Hand.OFF_HAND : Hand.MAIN_HAND, new BlockHitResult(pos.toCenterPos(), BlockUtils.getBlockDirection(pos), pos, false)); //If a TNT has been ignited then it's not a block anymore, // so we can break out safely without worrying of looping into the same TNT again. diff --git a/src/main/java/dev/heliosclient/module/modules/world/painter/Painter.java b/src/main/java/dev/heliosclient/module/modules/world/painter/Painter.java index f598f243..56da49c3 100644 --- a/src/main/java/dev/heliosclient/module/modules/world/painter/Painter.java +++ b/src/main/java/dev/heliosclient/module/modules/world/painter/Painter.java @@ -10,9 +10,9 @@ import dev.heliosclient.module.settings.*; import dev.heliosclient.module.settings.buttonsetting.ButtonSetting; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.FileUtils; import dev.heliosclient.util.blocks.BlockUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.render.Renderer3D; import dev.heliosclient.util.render.color.QuadColor; diff --git a/src/main/java/dev/heliosclient/module/settings/CycleSetting.java b/src/main/java/dev/heliosclient/module/settings/CycleSetting.java index 7ce3f707..dc68a91e 100644 --- a/src/main/java/dev/heliosclient/module/settings/CycleSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/CycleSetting.java @@ -75,10 +75,6 @@ public void render(DrawContext drawContext, int x, int y, int mouseX, int mouseY } } - public void setValue(int value) { - this.value = value; - } - @Override public Integer get() { return value; @@ -141,6 +137,12 @@ public void setValue(Integer value) { this.value = value; } + public void setOption(Object value) { + if(options.contains(value)){ + setValue(options.indexOf(value)); + } + } + @Override public Object saveToFile(List objectList) { if (options.isEmpty() || options.size() - 1 < value) { diff --git a/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java b/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java index 596968c4..11569664 100644 --- a/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/DoubleSetting.java @@ -2,8 +2,8 @@ import dev.heliosclient.managers.ColorManager; import dev.heliosclient.ui.clickgui.Tooltip; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.inputbox.InputBox; import dev.heliosclient.util.interfaces.ISettingChange; diff --git a/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java b/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java index 887d60af..4511a815 100644 --- a/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/DropDownSetting.java @@ -19,7 +19,7 @@ import static com.mojang.text2speech.Narrator.LOGGER; public class DropDownSetting extends Setting { - public List options; + public List options; public int value; public boolean selecting = false; List tooltipText; @@ -39,7 +39,6 @@ public DropDownSetting(String name, String description, ISettingChange iSett maxOptionWidth = Math.max(maxOptionWidth, Math.round(Renderer2D.getFxStringWidth(option.toString()))); } this.tooltipText = optionsTooltips; - } public DropDownSetting(String name, String description, ISettingChange iSettingChange, T[] options, int value, BooleanSupplier shouldRender, int defaultValue, List optionsTooltips) { @@ -231,6 +230,12 @@ public void setValue(Integer value) { this.value = value; } + public void setOption(Object value) { + if(options.contains(value)){ + setValue(options.indexOf(value)); + } + } + @Override public Object saveToFile(List objectList) { if (options.isEmpty() || options.size() - 1 < value) { diff --git a/src/main/java/dev/heliosclient/module/settings/GradientSetting.java b/src/main/java/dev/heliosclient/module/settings/GradientSetting.java index bb50dc6a..fdda1e05 100644 --- a/src/main/java/dev/heliosclient/module/settings/GradientSetting.java +++ b/src/main/java/dev/heliosclient/module/settings/GradientSetting.java @@ -96,16 +96,18 @@ public void renderAllGradients(DrawContext context, int mouseX, int mouseY){ float y = (float) gE.y - (isMouseOver? 1 : 0); - Renderer2D.drawRoundedGradientRectangle(context.getMatrices().peek().getPositionMatrix(), - gE.gradient.getStartGradient(), - gE.gradient.getEndGradient(), - gE.gradient.getEndGradient(), - gE.gradient.getStartGradient(), + Renderer2D.drawRoundedGradientRectangleWithShadow(context.getMatrices(), (float) gE.x + 3, y, (float) gE.width - 3, 18, - 3 + gE.gradient.getStartGradient(), + gE.gradient.getEndGradient(), + gE.gradient.getEndGradient(), + gE.gradient.getStartGradient(), + 3, + 20, + gE.gradient.getStartGradient() ); if(this.value == gE.gradient){ diff --git a/src/main/java/dev/heliosclient/module/settings/Option.java b/src/main/java/dev/heliosclient/module/settings/Option.java deleted file mode 100644 index 2269f4d4..00000000 --- a/src/main/java/dev/heliosclient/module/settings/Option.java +++ /dev/null @@ -1,38 +0,0 @@ -package dev.heliosclient.module.settings; - -//what is this anyone explain pls. -public class Option { - private String name; - private T value; - private boolean enabled; - - public Option(String name, T value, boolean enabled) { - this.name = name; - this.value = value; - this.enabled = enabled; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public T getValue() { - return value; - } - - public void setValue(T value) { - this.value = value; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } -} diff --git a/src/main/java/dev/heliosclient/module/settings/RGBASetting.java b/src/main/java/dev/heliosclient/module/settings/RGBASetting.java index 110c920e..d67390b8 100644 --- a/src/main/java/dev/heliosclient/module/settings/RGBASetting.java +++ b/src/main/java/dev/heliosclient/module/settings/RGBASetting.java @@ -7,8 +7,8 @@ import dev.heliosclient.managers.ColorManager; import dev.heliosclient.managers.EventManager; import dev.heliosclient.ui.clickgui.settings.RGBASettingScreen; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.inputbox.InputBox; import dev.heliosclient.util.interfaces.ISettingChange; diff --git a/src/main/java/dev/heliosclient/module/settings/Setting.java b/src/main/java/dev/heliosclient/module/settings/Setting.java index 234dbe4e..d054fac8 100644 --- a/src/main/java/dev/heliosclient/module/settings/Setting.java +++ b/src/main/java/dev/heliosclient/module/settings/Setting.java @@ -258,7 +258,7 @@ public void keyReleased(int keyCode, int scanCode, int modifiers) { public void charTyped(char chr, int modifiers) { } - protected void postSettingChange(){ + public void postSettingChange(){ if(this.iSettingChange != null){ this.iSettingChange.onSettingChange(this); } diff --git a/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java b/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java index f59aa1a4..e2679f8e 100644 --- a/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java +++ b/src/main/java/dev/heliosclient/module/sysmodules/ClickGUI.java @@ -11,9 +11,9 @@ import dev.heliosclient.module.settings.buttonsetting.ButtonSetting; import dev.heliosclient.ui.clickgui.ModuleButton; import dev.heliosclient.ui.clickgui.Tooltip; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.FileUtils; import dev.heliosclient.util.animation.AnimationUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.fontutils.FontUtils; import dev.heliosclient.util.fontutils.fxFontRenderer; @@ -85,18 +85,6 @@ public class ClickGUI extends Module_ { .shouldRender(() -> ScrollType.value == 1) .build() ); - public DoubleSetting scrollingSmoothness = sgMisc.add(new DoubleSetting.Builder() - .name("Scrolling Smoothness") - .description("The smoothness applied while scrolling") - .onSettingChange(this) - .value(0.1) - .defaultValue(0.1) - .max(1) - .min(0.01) - .roundingPlace(2) - .shouldRender(() -> ScrollType.value == 1) - .build() - ); public DoubleSetting moduleButtonHeight = sgMisc.add(new DoubleSetting.Builder() .name("ModuleButton Height") .description("ModuleButton Height for the ClickGUI") @@ -109,6 +97,18 @@ public class ClickGUI extends Module_ { .roundingPlace(0) .build() ); + public DoubleSetting scrollingSmoothness = sgMisc.add(new DoubleSetting.Builder() + .name("Scrolling Smoothness") + .description("The smoothness applied while scrolling") + .onSettingChange(this) + .value(0.1) + .defaultValue(0.1) + .max(1) + .min(0.01) + .roundingPlace(2) + .shouldRender(() -> ScrollType.value == 1) + .build() + ); public DoubleSetting ScrollSpeed = sgMisc.add(new DoubleSetting.Builder() .name("Scroll Sensitivity") .description("Change your scroll speed multiplier for the ClickGUI") @@ -311,14 +311,6 @@ public class ClickGUI extends Module_ { .description("Reload, save or load configs") .build() ); - public BooleanSetting disableEventSystem = sgExpert.add(new BooleanSetting.Builder() - .name("Disable Event System") - .description("Disables the client's event system. Warning: This will cause ALL modules and features of the client to stop working and may get out of sync. This option will also only be turned off again via the config") - .onSettingChange(this) - .value(false) - .defaultValue(false) - .build() - ); ButtonSetting loadFonts = sgGeneral.add(new ButtonSetting.Builder() .name("Font") .build() @@ -337,6 +329,14 @@ public class ClickGUI extends Module_ { .value(true) .build() ); + public BooleanSetting disableGlobalShadows = sgExpert.add(new BooleanSetting.Builder() + .name("Disables all blurred shadow") + .description("Any blurred shadow rendering of HeliosClient will be disabled and all settings relying on it will be useless") + .onSettingChange(this) + .value(false) + .defaultValue(false) + .build() + ); public ClickGUI() { super("ClickGUI", "ClickGui related stuff.", Categories.RENDER); @@ -346,7 +346,7 @@ public ClickGUI() { addSettingGroup(sgSound); addSettingGroup(sgTooltip); addSettingGroup(sgConfig); - //addSettingGroup(sgExpert); + addSettingGroup(sgExpert); active.value = true; diff --git a/src/main/java/dev/heliosclient/scripting/LuaEventManager.java b/src/main/java/dev/heliosclient/scripting/LuaEventManager.java index 7362d740..f7f06f9f 100644 --- a/src/main/java/dev/heliosclient/scripting/LuaEventManager.java +++ b/src/main/java/dev/heliosclient/scripting/LuaEventManager.java @@ -2,7 +2,7 @@ import dev.heliosclient.HeliosClient; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import org.luaj.vm2.LuaFunction; import org.luaj.vm2.LuaValue; import org.luaj.vm2.Varargs; diff --git a/src/main/java/dev/heliosclient/scripting/LuaExecutor.java b/src/main/java/dev/heliosclient/scripting/LuaExecutor.java index 433da8d2..e23dcd24 100644 --- a/src/main/java/dev/heliosclient/scripting/LuaExecutor.java +++ b/src/main/java/dev/heliosclient/scripting/LuaExecutor.java @@ -6,9 +6,9 @@ import dev.heliosclient.scripting.libraries.PacketLib; import dev.heliosclient.scripting.libraries.PlayerLib; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.entity.EntityUtils; import dev.heliosclient.util.player.DamageUtils; import dev.heliosclient.util.player.InventoryUtils; @@ -24,12 +24,14 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; import net.minecraft.world.biome.BiomeKeys; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.luaj.vm2.Globals; import org.luaj.vm2.LuaValue; import org.luaj.vm2.lib.DebugLib; import org.luaj.vm2.lib.jse.CoerceJavaToLua; import org.luaj.vm2.lib.jse.JsePlatform; +import org.luaj.vm2.luajc.LuaJC; import java.io.Reader; @@ -77,6 +79,8 @@ public LuaExecutor(MinecraftClient mc, LuaEventManager eventManager) { globals.set("Vec3d", CoerceJavaToLua.coerce(Vec3d.class)); globals.set("Box", CoerceJavaToLua.coerce(Box.class)); globals.set("Hand", CoerceJavaToLua.coerce(Hand.class)); + + LuaJC.install(globals); } /** @@ -87,7 +91,7 @@ public LuaExecutor(MinecraftClient mc, LuaEventManager eventManager) { */ public LuaValue load(Reader reader) { if(luaFile == null){ - throw new RuntimeException("Load called before LuaFile was initialised"); + throw new IllegalStateException("LuaFile must be set before loading a script."); } return globals.load(reader, luaFile.getScriptName()); } @@ -110,7 +114,7 @@ public void setGlobals(Globals globals) { this.globals = globals; } - public void setLuaFile(LuaFile luaFile) { + public void setLuaFile(@NotNull LuaFile luaFile) { this.luaFile = luaFile; } } diff --git a/src/main/java/dev/heliosclient/scripting/LuaFile.java b/src/main/java/dev/heliosclient/scripting/LuaFile.java index b4f2876f..b6fd1a85 100644 --- a/src/main/java/dev/heliosclient/scripting/LuaFile.java +++ b/src/main/java/dev/heliosclient/scripting/LuaFile.java @@ -44,14 +44,7 @@ public void setLoaded(boolean loaded) { * @throws FileNotFoundException If the Lua script file does not exist. */ public Reader getReader() throws FileNotFoundException { - try { - if (reader == null || !reader.ready()) { - reader = new BufferedReader(new FileReader(this)); - } - } catch (IOException e) { - reader = new BufferedReader(new FileReader(this)); - } - return reader; + return getBufferedReader(); } /** * Retrieves a Buffered reader for the Lua script file. @@ -122,6 +115,17 @@ public String getText() throws IOException { } return text.toString(); } + /** + * Rewrites the contents of the Lua file with the provided text. + * + * @param newText The new content to be written into the file. + * @throws IOException If an I/O error occurs. + */ + public void setText(String newText) throws IOException { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(this))) { + writer.write(newText); + } + } @Override public boolean equals(Object obj) { @@ -130,4 +134,5 @@ public boolean equals(Object obj) { } return super.equals(obj); } + } diff --git a/src/main/java/dev/heliosclient/scripting/LuaFriendlyWrapper.java b/src/main/java/dev/heliosclient/scripting/LuaFriendlyWrapper.java deleted file mode 100644 index f2a631f0..00000000 --- a/src/main/java/dev/heliosclient/scripting/LuaFriendlyWrapper.java +++ /dev/null @@ -1,72 +0,0 @@ -package dev.heliosclient.scripting; - -import org.luaj.vm2.LuaValue; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * This class provides a Lua-friendly wrapper for Java objects. - * It allows Lua scripts to interact with Java objects by exposing their public fields and methods. - *

- * To be used in times when certain objects cant be {@link org.luaj.vm2.lib.jse.CoerceJavaToLua} - */ -@Deprecated(forRemoval = true) -public class LuaFriendlyWrapper { - private final Object javaObject; - - /** - * Constructs a new LuaFriendlyWrapper for the given Java object. - * - * @param javaObject the Java object to wrap - */ - public LuaFriendlyWrapper(Object javaObject) { - this.javaObject = javaObject; - } - - /** - * Gets the value of a public field of the wrapped Java object. - * - * @param fieldName the name of the field - * @return the value of the field - * @throws RuntimeException if the field does not exist or cannot be accessed - */ - public Object get(String fieldName) { - try { - Field field = javaObject.getClass().getField(fieldName); - return field.get(javaObject); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - /** - * Calls a method of the wrapped Java object. - * - * @param methodName the name of the method - * @param args the arguments to pass to the method - * @return the result of the method call - * @throws RuntimeException if the method does not exist, cannot be accessed, or throws an exception - */ - public Object call(String methodName, Object... args) { - try { - // Coerce Lua userdata to Java objects - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof org.luaj.vm2.LuaUserdata) { - args[i] = org.luaj.vm2.lib.jse.CoerceLuaToJava.coerce((LuaValue) args[i], Object.class); - } - } - - Method method; - if (args.length > 0) { - method = javaObject.getClass().getMethod(methodName, args.getClass()); - } else { - method = javaObject.getClass().getMethod(methodName); - } - return method.invoke(javaObject, args); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - throw new RuntimeException(e); - } - } -} \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/scripting/LuaLoader.java b/src/main/java/dev/heliosclient/scripting/LuaLoader.java index 71c53991..031b5e44 100644 --- a/src/main/java/dev/heliosclient/scripting/LuaLoader.java +++ b/src/main/java/dev/heliosclient/scripting/LuaLoader.java @@ -6,8 +6,8 @@ import dev.heliosclient.module.modules.misc.NotificationModule; import dev.heliosclient.ui.notification.notifications.InfoNotification; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.color.ColorUtils; import org.luaj.vm2.LuaValue; import java.io.File; @@ -96,10 +96,10 @@ public void close(LuaFile file) { file.getReader().close(); - //Call the Garbage collector to collect any leftover garbage by the script. Might cause lag or crash if unused properly + //Call the Garbage collector to collect any leftover garbage by the script. Might cause lag or crash System.gc(); - file.setLoaded(false); + ChatUtils.sendHeliosMsg(ColorUtils.green + "Closed LuaFile" + ColorUtils.gray + " [" + ColorUtils.aqua + file.getScriptName() + ColorUtils.gray + "]"); if (HeliosClient.shouldSendNotification() && ModuleManager.get(NotificationModule.class).scriptNotifications.value) { NotificationManager.addNotification(new InfoNotification(file.getScriptName(), "was unloaded!", 1000, SoundUtils.TING_SOUNDEVENT)); diff --git a/src/main/java/dev/heliosclient/scripting/LuaScriptManager.java b/src/main/java/dev/heliosclient/scripting/LuaScriptManager.java index f6b7e075..268241a2 100644 --- a/src/main/java/dev/heliosclient/scripting/LuaScriptManager.java +++ b/src/main/java/dev/heliosclient/scripting/LuaScriptManager.java @@ -1,7 +1,7 @@ package dev.heliosclient.scripting; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/heliosclient/scripting/libraries/ChatLib.java b/src/main/java/dev/heliosclient/scripting/libraries/ChatLib.java index b950600f..d831f100 100644 --- a/src/main/java/dev/heliosclient/scripting/libraries/ChatLib.java +++ b/src/main/java/dev/heliosclient/scripting/libraries/ChatLib.java @@ -1,15 +1,13 @@ package dev.heliosclient.scripting.libraries; import dev.heliosclient.util.ChatUtils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import org.luaj.vm2.LuaValue; import org.luaj.vm2.lib.OneArgFunction; import org.luaj.vm2.lib.TwoArgFunction; public class ChatLib extends TwoArgFunction { - public ChatLib() { - - } + public ChatLib() {} @Override public LuaValue call(LuaValue modname, LuaValue env) { @@ -22,46 +20,48 @@ public LuaValue call(LuaValue modname, LuaValue env) { library.set("sendScriptMsg", new sendScriptMsg()); env.set("chatLib", library); - env.get("package").get("loaded").set("chatLib", library); + + if (!env.get("package").isnil()) + env.get("package").get("loaded").set("chatLib", library); return library; } - static class sendHeliosMsg extends OneArgFunction { + static final class sendHeliosMsg extends OneArgFunction { public LuaValue call(LuaValue textString) { ChatUtils.sendHeliosMsg(textString.tojstring()); return NIL; } } - static class sendMsg extends OneArgFunction { + static final class sendMsg extends OneArgFunction { public LuaValue call(LuaValue textString) { ChatUtils.sendMsg(textString.tojstring()); return NIL; } } - static class sendScriptMsg extends TwoArgFunction { + static final class sendScriptMsg extends TwoArgFunction { public LuaValue call(LuaValue scriptName, LuaValue textString) { ChatUtils.sendMsg(ColorUtils.gray + "[" + ColorUtils.darkAqua + scriptName.tojstring() + ColorUtils.gray + "]" + textString.tojstring()); return NIL; } } - static class sendPlayerMsg extends OneArgFunction { + static final class sendPlayerMsg extends OneArgFunction { public LuaValue call(LuaValue textString) { ChatUtils.sendPlayerMessage(textString.tojstring()); return NIL; } } - static class sendCommandMsg extends OneArgFunction { + static final class sendCommandMsg extends OneArgFunction { public LuaValue call(LuaValue textString) { ChatUtils.sendCommand(textString.tojstring()); return NIL; } } - static class sendCommand extends OneArgFunction { + static final class sendCommand extends OneArgFunction { public LuaValue call(LuaValue textString) { ChatUtils.sendCommand(textString.tojstring()); return NIL; diff --git a/src/main/java/dev/heliosclient/scripting/libraries/PacketLib.java b/src/main/java/dev/heliosclient/scripting/libraries/PacketLib.java index f8397a2b..61e91258 100644 --- a/src/main/java/dev/heliosclient/scripting/libraries/PacketLib.java +++ b/src/main/java/dev/heliosclient/scripting/libraries/PacketLib.java @@ -25,7 +25,10 @@ public LuaValue call(LuaValue modname, LuaValue env) { LuaValue library = tableOf(); library.set("sendChatMessagePacket", new sendChatMessagePacket()); - env.set("PacketLib", library); + env.set("packetLib", library); + if (!env.get("package").isnil()) + env.get("package").get("loaded").set("packetLib", library); + return library; } diff --git a/src/main/java/dev/heliosclient/scripting/libraries/PlayerLib.java b/src/main/java/dev/heliosclient/scripting/libraries/PlayerLib.java index d7de84a7..37ebfa53 100644 --- a/src/main/java/dev/heliosclient/scripting/libraries/PlayerLib.java +++ b/src/main/java/dev/heliosclient/scripting/libraries/PlayerLib.java @@ -1,7 +1,6 @@ package dev.heliosclient.scripting.libraries; import dev.heliosclient.HeliosClient; -import dev.heliosclient.module.settings.Option; import dev.heliosclient.util.blocks.BlockUtils; import dev.heliosclient.util.player.InventoryUtils; import dev.heliosclient.util.player.RotationUtils; @@ -22,8 +21,6 @@ import org.luaj.vm2.lib.ZeroArgFunction; import org.luaj.vm2.lib.jse.CoerceJavaToLua; -import java.util.ArrayList; - public class PlayerLib extends TwoArgFunction { private final PlayerEntity player; @@ -46,7 +43,6 @@ public LuaValue call(LuaValue modname, LuaValue env) { library.set("getEmptySlot", new getEmptySlot()); library.set("getFastestTool", new getFastestTool()); library.set("getFastestToolAB", new getFastestToolAntibreak()); - library.set("getItemNames", new getItemNames()); library.set("getItemCountInInventory", new getItemCountInInventory()); library.set("canSwapItem", new canSwapItem()); library.set("swapBackHotbar", new swapBackHotbar()); @@ -55,7 +51,9 @@ public LuaValue call(LuaValue modname, LuaValue env) { library.set("lookAtVec3d", new lookAtVec3d()); env.set("playerLib", library); - env.get("package").get("loaded").set("playerLib", library); + + if (!env.get("package").isnil()) + env.get("package").get("loaded").set("playerLib", library); return library; } @@ -157,25 +155,6 @@ public LuaValue call(LuaValue blockState, LuaValue antibreak) { } } - static class getItemNames extends ZeroArgFunction { - public LuaValue call() { - ArrayList> itemNames = InventoryUtils.getItemNames(); - - // Create a new Lua table - LuaTable luaItemNames = new LuaTable(); - - // Populate the Lua table with the item names - for (int i = 0; i < itemNames.size(); i++) { - Option option = itemNames.get(i); - String itemName = option.getName(); - luaItemNames.set(i + 1, LuaValue.valueOf(itemName)); - } - - // Return the Lua table - return luaItemNames; - } - } - static class lookAtCoords extends ThreeArgFunction { public LuaValue call(LuaValue x, LuaValue y, LuaValue z) { double x1 = x.todouble(); diff --git a/src/main/java/dev/heliosclient/system/ConsoleAppender.java b/src/main/java/dev/heliosclient/system/ConsoleAppender.java index 808bedef..88e7f1e8 100644 --- a/src/main/java/dev/heliosclient/system/ConsoleAppender.java +++ b/src/main/java/dev/heliosclient/system/ConsoleAppender.java @@ -1,7 +1,7 @@ package dev.heliosclient.system; import dev.heliosclient.ui.clickgui.ConsoleScreen; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.appender.AbstractAppender; diff --git a/src/main/java/dev/heliosclient/system/config/Config.java b/src/main/java/dev/heliosclient/system/config/Config.java index 82b06231..1d479c58 100644 --- a/src/main/java/dev/heliosclient/system/config/Config.java +++ b/src/main/java/dev/heliosclient/system/config/Config.java @@ -7,6 +7,7 @@ import dev.heliosclient.hud.HudElementList; import dev.heliosclient.managers.*; import dev.heliosclient.module.Categories; +import dev.heliosclient.module.Category; import dev.heliosclient.module.Module_; import dev.heliosclient.module.settings.Setting; import dev.heliosclient.module.settings.SettingGroup; @@ -20,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; import static dev.heliosclient.HeliosClient.LOGGER; @@ -52,7 +52,6 @@ public void init() { public void loadEverything() { loadConfigManagers(); - load(); } @@ -132,16 +131,14 @@ public void loadModules() { // | // // module settings // - 2 loops (setting groups and the setting list) - // Very space efficient ik. - - // I should get a darwin award for this + // Programmers get spooked by this on Halloween LOGGER.info("Loading Modules... "); CategoryManager.getCategories().forEach((s, category) -> { if (category == Categories.SEARCH) return; - if (panesMap.map() != null && panesMap.has(category.name)) { + if (panesMap.mapExists() && panesMap.has(category.name)) { MapReader trashMap = panesMap.getMap(category.name); for (Module_ m : ModuleManager.getModulesByCategory(category)) { @@ -169,15 +166,14 @@ public void loadClientConfigModules() { if (setting.name != null) { try { - if (settingsMap != null) - setting.loadFromFile(settingsMap); - }catch (Throwable e){ + if (settingsMap != null) setting.loadFromFile(settingsMap); + } catch (Throwable e){ e.printStackTrace(); continue; } - if (setting.iSettingChange != null && setting != HeliosClient.CLICKGUI.FontRenderer) { - setting.iSettingChange.onSettingChange(setting); + if (setting != HeliosClient.CLICKGUI.FontRenderer) { + setting.postSettingChange(); } } } @@ -210,7 +206,7 @@ public void writeClientConfig() { } /** - * Gets the hud configuration for the client. + * This will write all the Hud elements data we have to the "hud" sub-config */ public void writeHudConfig() { try { @@ -256,28 +252,34 @@ public void loadFriendConfig() { } } - // Generates the default configuration for the modules. public void writeDefaultModuleConfig() { - final AtomicInteger[] xOffset = {new AtomicInteger(4)}; - final int[] yOffset = {4}; Map categoryPaneMap = new HashMap<>(); - CategoryManager.getCategories().forEach((s, category) -> { + int xOffset = 4; + int yOffset = 4; + + for (Map.Entry entry : CategoryManager.getCategories().entrySet()) { + Category category = entry.getValue(); Map paneConfigMap = new HashMap<>(); - if (xOffset[0].get() > 400) { - xOffset[0].set(4); - yOffset[0] = 128; + + if (xOffset > 400) { + xOffset = 4; + yOffset = 128; } - paneConfigMap.put("x", xOffset[0].get()); - paneConfigMap.put("y", yOffset[0]); + + paneConfigMap.put("x", xOffset); + paneConfigMap.put("y", yOffset); paneConfigMap.put("collapsed", category != Categories.SEARCH); + for (Module_ module : ModuleManager.getModulesByCategory(category)) { paneConfigMap.put(module.name.replace(" ", ""), module.saveToFile(new ArrayList<>())); } + categoryPaneMap.put(category.name, paneConfigMap); - moduleConfigManager.put("panes", categoryPaneMap); - xOffset[0].addAndGet(100); - }); + xOffset += 100; + } + + moduleConfigManager.put("panes", categoryPaneMap); } public void loadHudElements() { diff --git a/src/main/java/dev/heliosclient/system/config/ConfigManager.java b/src/main/java/dev/heliosclient/system/config/ConfigManager.java index 7aa5bf09..b92d6764 100644 --- a/src/main/java/dev/heliosclient/system/config/ConfigManager.java +++ b/src/main/java/dev/heliosclient/system/config/ConfigManager.java @@ -29,7 +29,7 @@ public class ConfigManager { private final ConcurrentHashMap configs; private SubConfig currentConfig; private final List configNames; - private String defaultFileName; + private final String defaultFileName; public ConfigManager(String configDir, String defaultFileName) { this(Path.of(configDir), defaultFileName); @@ -197,6 +197,7 @@ public void setConfigFile(File file) { public String getName() { return name; } + public boolean create() { try { return configFile.toFile().createNewFile(); @@ -213,6 +214,7 @@ public Map getData() { public Path getConfigPath() { return configFile; } + public File getConfigFile() { return configFile.toFile(); } @@ -232,12 +234,15 @@ public void load() { Type type = new TypeToken>(){}.getType(); Map loadedData = GSON.fromJson(reader, type); data.clear(); + //I know 10 ways in which this would have caused a problem if(loadedData == null) return; + data.putAll(loadedData); } catch (IOException e) { HeliosClient.LOGGER.error("Failed to load config: {}", name, e); } } + public T get(String key, Class type) { Object value = data.get(key); if (type.isInstance(value)) { diff --git a/src/main/java/dev/heliosclient/ui/HeliosClientInfoScreen.java b/src/main/java/dev/heliosclient/ui/HeliosClientInfoScreen.java index 1ec94dd7..01129f78 100644 --- a/src/main/java/dev/heliosclient/ui/HeliosClientInfoScreen.java +++ b/src/main/java/dev/heliosclient/ui/HeliosClientInfoScreen.java @@ -1,6 +1,6 @@ package dev.heliosclient.ui; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen; diff --git a/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java b/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java index 68793e27..2e1b488c 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/ClickGUIScreen.java @@ -11,10 +11,10 @@ import dev.heliosclient.module.sysmodules.ClickGUI; import dev.heliosclient.ui.clickgui.gui.PolygonMeshPatternRenderer; import dev.heliosclient.ui.clickgui.navbar.NavBar; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.MathUtils; import dev.heliosclient.util.animation.Easing; import dev.heliosclient.util.animation.EasingType; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.MinecraftClient; @@ -104,7 +104,7 @@ private void updateScale(float speed, boolean close) { } else { this.scale += speed * Easing.ease(EasingType.QUADRATIC_IN, MathHelper.clamp((currentTime - timeOnOpen) / 1000f, 0, 1f)); } - this.scale = MathHelper.clamp(this.scale, 0.0f, 1.4f); + this.scale = MathHelper.clamp(this.scale, 0.0f, 1.0f); } else { this.scale = 1.0f; if (shouldClose) { diff --git a/src/main/java/dev/heliosclient/ui/clickgui/ConsoleScreen.java b/src/main/java/dev/heliosclient/ui/clickgui/ConsoleScreen.java index fd945e1c..8d6ad41a 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/ConsoleScreen.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/ConsoleScreen.java @@ -5,6 +5,7 @@ import dev.heliosclient.ui.clickgui.navbar.NavBar; import dev.heliosclient.util.inputbox.InputBox; import dev.heliosclient.util.inputbox.MultiLineInputBox; +import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; @@ -24,12 +25,7 @@ public ConsoleScreen() { consoleBox.autoScroll = true; enterBox = new InputBox(29, 13, "", 256, InputBox.InputMode.ALL); - enterButton = new Button("Enter", () -> { - if (!enterBox.getValue().isEmpty()) { - HeliosClient.LOGGER.info(enterBox.getValue()); - enterBox.setText(""); - } - }, 20, 20, 45, 13); + enterButton = new Button("Enter", this::setText, 20, 20, 45, 13); } @Override @@ -80,13 +76,21 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { return super.mouseClicked(mouseX, mouseY, button); } + public void setText(){ + if (!enterBox.getValue().isEmpty()) { + HeliosClient.LOGGER.info(enterBox.getValue()); + if(enterBox.getValue().equalsIgnoreCase(".clearCache")){ + Renderer2D.INSTANCE.deleteShadowCache(); + HeliosClient.LOGGER.info("Shadow Cache Cleared"); + } + enterBox.setText(""); + } + } + @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) { - if (!enterBox.getValue().isEmpty()) { - HeliosClient.LOGGER.info(enterBox.getValue()); - enterBox.setText(""); - } + setText(); } if (keyCode == GLFW.GLFW_KEY_TAB ) { enterBox.setFocused(true); diff --git a/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java b/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java index 7c0ab03c..b3f63af7 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/ModuleButton.java @@ -13,9 +13,9 @@ import dev.heliosclient.module.sysmodules.ClickGUI; import dev.heliosclient.ui.clickgui.gui.HudBox; import dev.heliosclient.ui.clickgui.settings.SettingsScreen; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.KeyboardUtils; import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; diff --git a/src/main/java/dev/heliosclient/ui/clickgui/SearchBar.java b/src/main/java/dev/heliosclient/ui/clickgui/SearchBar.java index c1a6794b..65c6a738 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/SearchBar.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/SearchBar.java @@ -1,7 +1,7 @@ package dev.heliosclient.ui.clickgui; import dev.heliosclient.managers.ColorManager; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.inputbox.InputBox; import dev.heliosclient.util.render.Renderer2D; diff --git a/src/main/java/dev/heliosclient/ui/clickgui/gui/Window.java b/src/main/java/dev/heliosclient/ui/clickgui/gui/Window.java index 9be3bb93..f1e39c1b 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/gui/Window.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/gui/Window.java @@ -9,16 +9,15 @@ import dev.heliosclient.managers.NavBarManager; import dev.heliosclient.ui.clickgui.ClickGUIScreen; import dev.heliosclient.ui.clickgui.navbar.NavBarItem; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.Easing; import dev.heliosclient.util.animation.EasingType; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.interfaces.IWindowContentRenderer; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import java.awt.*; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/heliosclient/ui/clickgui/hudeditor/HudEditorScreen.java b/src/main/java/dev/heliosclient/ui/clickgui/hudeditor/HudEditorScreen.java index 7f22cfe4..b09b12f8 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/hudeditor/HudEditorScreen.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/hudeditor/HudEditorScreen.java @@ -35,7 +35,6 @@ public class HudEditorScreen extends Screen implements Listener { public static HudEditorScreen INSTANCE = new HudEditorScreen(); private final List selectedElements = new ArrayList<>(); private final MapReader copiedSettings = new MapReader(new HashMap<>()); - private final int defaultSnapSize = 120; private final Color LIGHT_YELLOW = new Color(223, 248, 89, 121); float thickness = 0.5f; // Thickness of the alignment lines float threshold = 1; // Threshold between two HudBoxes for the alignment lines to show. @@ -114,7 +113,7 @@ public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) float textWidth = Renderer2D.getFxStringWidth(sizeChangeText); float textHeight = Renderer2D.getFxStringHeight(sizeChangeText); float x = this.width / 2f - textWidth / 2f; - float y = this.height - textHeight * 2f; + float y = this.height - textHeight * 5f; AnimationUtils.drawFadingAndPoppingBoxBetter(Renderer2D.drawContext, fadeAnimation, x - 2, y - 2, textWidth + 4, textHeight + 4, LIGHT_YELLOW.getRGB(), true, 3f); AnimationUtils.drawFadingAndPoppingText(Renderer2D.drawContext, fadeAnimation, sizeChangeText, x, y, -1, true); diff --git a/src/main/java/dev/heliosclient/ui/clickgui/script/ScriptManagerScreen.java b/src/main/java/dev/heliosclient/ui/clickgui/script/ScriptManagerScreen.java index 885dbd2d..ca6a70a9 100644 --- a/src/main/java/dev/heliosclient/ui/clickgui/script/ScriptManagerScreen.java +++ b/src/main/java/dev/heliosclient/ui/clickgui/script/ScriptManagerScreen.java @@ -9,9 +9,9 @@ import dev.heliosclient.ui.clickgui.gui.tables.Table; import dev.heliosclient.ui.clickgui.gui.tables.TableEntry; import dev.heliosclient.ui.clickgui.navbar.NavBar; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.KeyboardUtils; import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/dev/heliosclient/ui/notification/notifications/InfoNotification.java b/src/main/java/dev/heliosclient/ui/notification/notifications/InfoNotification.java index 26e0ae61..9654cf69 100644 --- a/src/main/java/dev/heliosclient/ui/notification/notifications/InfoNotification.java +++ b/src/main/java/dev/heliosclient/ui/notification/notifications/InfoNotification.java @@ -4,8 +4,8 @@ import dev.heliosclient.managers.ModuleManager; import dev.heliosclient.module.modules.misc.NotificationModule; import dev.heliosclient.ui.notification.Notification; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.SoundUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.fontutils.fxFontRenderer; import dev.heliosclient.util.render.Renderer2D; diff --git a/src/main/java/dev/heliosclient/util/ChatUtils.java b/src/main/java/dev/heliosclient/util/ChatUtils.java index f6cda1a8..5f5d9a6d 100644 --- a/src/main/java/dev/heliosclient/util/ChatUtils.java +++ b/src/main/java/dev/heliosclient/util/ChatUtils.java @@ -1,5 +1,6 @@ package dev.heliosclient.util; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; diff --git a/src/main/java/dev/heliosclient/util/animation/AnimationUtils.java b/src/main/java/dev/heliosclient/util/animation/AnimationUtils.java index c8c66f0c..b71fab3a 100644 --- a/src/main/java/dev/heliosclient/util/animation/AnimationUtils.java +++ b/src/main/java/dev/heliosclient/util/animation/AnimationUtils.java @@ -1,9 +1,9 @@ package dev.heliosclient.util.animation; import dev.heliosclient.HeliosClient; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.toasts.ErrorToast; import dev.heliosclient.util.animation.toasts.InfoToast; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.toast.Toast; diff --git a/src/main/java/dev/heliosclient/util/blocks/BlockUtils.java b/src/main/java/dev/heliosclient/util/blocks/BlockUtils.java index 30b32229..75f20119 100644 --- a/src/main/java/dev/heliosclient/util/blocks/BlockUtils.java +++ b/src/main/java/dev/heliosclient/util/blocks/BlockUtils.java @@ -54,9 +54,7 @@ public static Block getBlockFromString(String blockString) throws InvalidIdentif } public static boolean canBreak(BlockPos blockPos, BlockState state) { - if (mc.player.isCreative()) return true; - - if (state.getHardness(mc.world, blockPos) < 0) return false; + if (!mc.player.isCreative() && state.getHardness(mc.world, blockPos) < 0) return false; return state.getOutlineShape(mc.world, blockPos) != VoxelShapes.empty(); } @@ -67,7 +65,7 @@ public static boolean canBreak(BlockPos blockPos) { } public static boolean canBreakInstantly(BlockState state, float speed) { - return mc.player.isCreative() || calcBlockBreakingDelta2(state, speed) >= 1; + return mc.player.isCreative() || calcBlockBreakingDelta3(state, speed) >= 1; } public static boolean canPlace(BlockPos pos, BlockState state) { @@ -80,13 +78,12 @@ public static boolean canPlace(BlockPos pos) { } public static boolean breakBlock(BlockPos pos, boolean swing) { - if (!canBreak(pos, mc.world.getBlockState(pos))) return false; - BlockPos bp = pos instanceof BlockPos.Mutable ? new BlockPos(pos) : pos; - + // if (!canBreak(pos, mc.world.getBlockState(pos))) return false; + BlockPos bp = pos instanceof BlockPos.Mutable ? new BlockPos(pos) : pos; if (mc.interactionManager.isBreakingBlock()) - mc.interactionManager.updateBlockBreakingProgress(pos, getClosestFace(bp)); - else mc.interactionManager.attackBlock(pos, getClosestFace(bp)); + mc.interactionManager.updateBlockBreakingProgress(pos, getBlockDirection(bp)); + else mc.interactionManager.attackBlock(pos, getBlockDirection(bp)); if (swing) mc.player.swingHand(Hand.MAIN_HAND); else mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); @@ -98,26 +95,60 @@ public static BlockPos toBlockPos(Vec3d pos) { return new BlockPos((int) pos.x, (int) pos.y, (int) pos.z); } - /** - * @see AbstractBlock#calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos) - */ - public static double calcBlockBreakingDelta(BlockState state, ItemStack stack) { - return calcBlockBreakingDelta2(state, getMiningSpeedForBlockState(state, stack)); + public static float calcBlockBreakingDelta3(BlockState state, float breakSpeed) { + float f = state.getHardness(null,null); + if (f == -1.0F) { + return 0.0F; + } else { + int i = mc.player.canHarvest(state) ? 30 : 100; + return breakSpeed / f / (float) i; + } + } + + public static double calcBlockBreakingDelta2(BlockState state) { + return calcBlockBreakingDelta(state, mc.player.getInventory().selectedSlot); } /** * @see AbstractBlock#calcBlockBreakingDelta(BlockState, PlayerEntity, BlockView, BlockPos) */ - public static double calcBlockBreakingDelta2(BlockState state, double speed) { + public static double calcBlockBreakingDelta(BlockState state, int slot) { float f = state.getHardness(null, null); if (f == -1.0F) { return 0.0F; } else { - int i = HeliosClient.MC.player.canHarvest(state) ? 30 : 100; - return speed / f / (double) i; + ItemStack stack = mc.player.getInventory().getStack(slot); + int i = (!state.isToolRequired() || stack.isSuitableFor(state)) ? 30 : 100; + return getMiningSpeedForBlockState(state, stack) / f / (double) i; } } + // Determine the best direction to interact with the block + public static Direction getBlockDirection(BlockPos position) { + Vec3d playerEyesPos = mc.player.getEyePos(); + int blockPosY = position.getY(); + + BlockPos belowBlockPos = position.down(); + BlockPos aboveBlockPos = position.up(); + + // Check if block is above player's eye level + if (blockPosY > playerEyesPos.y) { + // Check if block below the target position is replaceable + if (mc.world.getBlockState(belowBlockPos).isReplaceable()) { + return Direction.DOWN; + } else { + return mc.player.getHorizontalFacing().getOpposite(); + } + } + + // Check if block above the target position is not replaceable + if (!mc.world.getBlockState(aboveBlockPos).isReplaceable()) { + return mc.player.getHorizontalFacing().getOpposite(); + } + + return Direction.UP; + } + /** * @see PlayerEntity#getBlockBreakingSpeed(BlockState) */ @@ -157,13 +188,6 @@ public static double getMiningSpeedForBlockState(BlockState blockState, ItemStac return speed; } - /** - * Returns the best possible block direction to interact with. - */ - public static Direction getClosestFace(BlockPos blockPos) { - Vec3d vec = mc.player.getEyePos().subtract(Vec3d.ofCenter(blockPos)); - return Direction.getFacing(vec.x, vec.y, vec.z); - } public static void useItem(BlockPos pos) { useItem(pos, Hand.MAIN_HAND); diff --git a/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java b/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java index 91720654..eb66f7a3 100644 --- a/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java +++ b/src/main/java/dev/heliosclient/util/blocks/HoleUtils.java @@ -13,7 +13,7 @@ public class HoleUtils { // List of blocks considered blast-proof (cannot be destroyed by explosions) static List blastProofBlocks = List.of(Blocks.BEDROCK, Blocks.OBSIDIAN, Blocks.ENDER_CHEST,Blocks.CRYING_OBSIDIAN); - + static Set checkedPositions = Collections.synchronizedSet(new HashSet<>()); // Arrays to define the relative positions of blast-resistant blocks and air blocks in a quad hole // North and south are on the Z axis @@ -53,9 +53,7 @@ public class HoleUtils { public static Set getHoles(int range, int vRange, boolean quadChecker) { Set holes = Collections.synchronizedSet(new HashSet<>()); BlockIterator iterator = new BlockIterator(HeliosClient.MC.player, range, vRange); - Set checkedPositions = Collections.synchronizedSet(new HashSet<>()); - - while (iterator.hasNext()) { + for(int iterations = 0; iterations < 1_000_000 && iterator.hasNext(); iterations++ ){ BlockPos pos = iterator.next(); if (checkedPositions.contains(pos)) continue; @@ -64,6 +62,7 @@ public static Set getHoles(int range, int vRange, boolean quadChecker) holes.add(hole); } } + checkedPositions.clear(); return holes; } @@ -223,7 +222,7 @@ private static HoleInfo getHoleType(World world, BlockPos pos, Set che } else if (block == Blocks.BEDROCK) { bedrock++; } else if (block == Blocks.AIR && world.isAir(newPos.offset(Direction.UP))) { - if (quadChecker && (obsidian + bedrock == 2) && !quadChecked) { + if (quadChecker && (obsidian + bedrock == 2) && !quadChecked) { if (isQuad(pos, world, checkedPositions)) { //Return a box containing all the four poses. BlockPos start = pos.offset(airOffset[0][0]).offset(airOffset[0][1]); diff --git a/src/main/java/dev/heliosclient/util/cape/CapeTextureManager.java b/src/main/java/dev/heliosclient/util/cape/CapeTextureManager.java index 9f1bd9bf..ca704e6d 100644 --- a/src/main/java/dev/heliosclient/util/cape/CapeTextureManager.java +++ b/src/main/java/dev/heliosclient/util/cape/CapeTextureManager.java @@ -9,24 +9,21 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; -//Space complexity = o(infinite) public class CapeTextureManager { - public final Map> gifCapeTextures = new HashMap<>(); - private final Map> gifElytraTextures = new HashMap<>(); - - public final Map staticCapeTextures = new HashMap<>(); - private final Map staticElytraTextures = new HashMap<>(); - - public final Map playerCapes = new HashMap<>(); - private final Map currentFrame = new HashMap<>(); - - private Timer timer = new Timer("CapeTextureManager"); + private final ConcurrentHashMap> gifTextures; + private final ConcurrentHashMap staticTextures; + private final ConcurrentHashMap playerCapes; public CapeTextureManager() { - gifCapeTextures.clear(); - gifElytraTextures.clear(); + this.gifTextures = new ConcurrentHashMap<>(); + this.staticTextures = new ConcurrentHashMap<>(); + this.playerCapes = new ConcurrentHashMap<>(); + this.startCapeAnimation(); } @@ -34,85 +31,73 @@ public void registerCapeTextures(InputStream stream, File capeFile, String prefi if (capeFile.getName().toLowerCase().endsWith(".gif")) { final GifTextureManager gifTextureManager = new GifTextureManager(); gifTextureManager.registerGifTextures(capeFile, prefix); - gifCapeTextures.put(prefix, gifTextureManager.getCapeTextureIdentifiers()); - gifElytraTextures.put(prefix, gifTextureManager.getElytraTextureIdentifiers()); + gifTextures.put(prefix + "_cape", gifTextureManager.getCapeTextureIdentifiers()); + gifTextures.put(prefix + "_elytra", gifTextureManager.getElytraTextureIdentifiers()); gifTextureManager.discardAll(); } else { NativeImage image = NativeImage.read(stream); - HeliosClient.MC.execute(()->{ - Identifier capeIdentifier = HeliosClient.MC.getTextureManager().registerDynamicTexture(prefix + "_cape", new NativeImageBackedTexture(CapeManager.parseCape(image))); - Identifier elytraIdentifier = HeliosClient.MC.getTextureManager().registerDynamicTexture(prefix + "_elytra", new NativeImageBackedTexture(image)); - staticCapeTextures.put(prefix, capeIdentifier); - staticElytraTextures.put(prefix, elytraIdentifier); + HeliosClient.MC.execute(() -> { + Identifier capeIdentifier = HeliosClient.MC.getTextureManager().registerDynamicTexture(prefix + "_cape", new NativeImageBackedTexture(CapeManager.parseCape(image))); + Identifier elytraIdentifier = HeliosClient.MC.getTextureManager().registerDynamicTexture(prefix + "_elytra", new NativeImageBackedTexture(image)); + staticTextures.put(prefix + "_cape", capeIdentifier); + staticTextures.put(prefix + "_elytra", elytraIdentifier); }); } } - public void assignCapeToPlayer(UUID playerUUID, String capeName) { - playerCapes.put(playerUUID, capeName); - currentFrame.put(playerUUID, 0); + playerCapes.put(playerUUID, new CapeData(capeName)); } - public Identifier getCurrentCapeTexture(UUID playerUUID) { - String capeName = playerCapes.get(playerUUID); - if (capeName == null) { + public Identifier getCurrentTexture(UUID playerUUID, boolean isElytra) { + CapeData capeData = playerCapes.get(playerUUID); + if (capeData == null) { return CapeManager.DEFAULT_CAPE_TEXTURE; } - if (gifCapeTextures.containsKey(capeName)) { - List frames = gifCapeTextures.get(capeName); - int frameIndex = currentFrame.get(playerUUID); - return frames.get(frameIndex); - } else { - return staticCapeTextures.getOrDefault(capeName, CapeManager.DEFAULT_CAPE_TEXTURE); - } - } - public Identifier getStaticCapeTexture(String capeName) { - return staticCapeTextures.getOrDefault(capeName, CapeManager.DEFAULT_CAPE_TEXTURE); - } - public Identifier getCurrentElytraTexture(UUID playerUUID) { - String capeName = playerCapes.get(playerUUID); - if (capeName == null) { - return CapeManager.DEFAULT_CAPE_TEXTURE; - } + String textureKey = capeData.capeName + (isElytra ? "_elytra" : "_cape"); + List frames = gifTextures.get(textureKey); - if (gifElytraTextures.containsKey(capeName)) { - List frames = gifElytraTextures.get(capeName); - int frameIndex = currentFrame.get(playerUUID); - return frames.get(frameIndex); + if (frames != null) { + return frames.get(capeData.currentFrame % frames.size()); } else { - return staticElytraTextures.getOrDefault(capeName, CapeManager.DEFAULT_CAPE_TEXTURE); + return staticTextures.getOrDefault(textureKey, CapeManager.DEFAULT_CAPE_TEXTURE); } } public void cycleCapeTextures() { - for (UUID playerUUID : playerCapes.keySet()) { - String capeName = playerCapes.get(playerUUID); - - if (gifCapeTextures.containsKey(capeName)) { - List frames = gifCapeTextures.get(capeName); - int frameIndex = (currentFrame.get(playerUUID) + 1) % frames.size(); - currentFrame.put(playerUUID, frameIndex); - }else if (gifElytraTextures.containsKey(capeName)) { - List frames = gifElytraTextures.get(capeName); - int frameIndex = (currentFrame.get(playerUUID) + 1) % frames.size(); - currentFrame.put(playerUUID, frameIndex); + playerCapes.forEach((uuid, capeData) -> { + List frames = gifTextures.get(capeData.capeName + "_cape"); + if (frames != null && !frames.isEmpty()) { + capeData.currentFrame = (capeData.currentFrame + 1) % frames.size(); } - } + }); } public void startCapeAnimation() { - timer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - CapeTextureManager.this.cycleCapeTextures(); + Thread animationThread = new Thread(() -> { + while (!Thread.currentThread().isInterrupted()) { + cycleCapeTextures(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } } - },0,100); + }); + animationThread.setName("CapeAnimationThread"); + animationThread.setDaemon(true); + animationThread.start(); } - public void stopCapeAnimation() { - timer.cancel(); + private static class CapeData { + String capeName; + int currentFrame; + + CapeData(String capeName) { + this.capeName = capeName; + this.currentFrame = 0; + } } } diff --git a/src/main/java/dev/heliosclient/util/ColorUtils.java b/src/main/java/dev/heliosclient/util/color/ColorUtils.java similarity index 99% rename from src/main/java/dev/heliosclient/util/ColorUtils.java rename to src/main/java/dev/heliosclient/util/color/ColorUtils.java index 94888ac9..23c269b9 100644 --- a/src/main/java/dev/heliosclient/util/ColorUtils.java +++ b/src/main/java/dev/heliosclient/util/color/ColorUtils.java @@ -1,4 +1,4 @@ -package dev.heliosclient.util; +package dev.heliosclient.util.color; import dev.heliosclient.HeliosClient; import net.minecraft.util.math.random.Random; @@ -67,6 +67,7 @@ public static int rgbToInt(int r, int g, int b) { public static int argbToRgb(int argb) { return argbToRgb(argb,255); } + public static int argbToRgb(int argb,int injectAlpha) { // Extract the individual components int red = ColorUtils.getRed(argb); @@ -200,8 +201,6 @@ public static Color changeAlpha(Integer color, float lessThanValue,int changeToA return new Color(Objects.requireNonNullElse(color, -1)); } - - /** * Changes alpha on integer color. * diff --git a/src/main/java/dev/heliosclient/util/entity/TargetUtils.java b/src/main/java/dev/heliosclient/util/entity/TargetUtils.java index 0f7f3626..376dd392 100644 --- a/src/main/java/dev/heliosclient/util/entity/TargetUtils.java +++ b/src/main/java/dev/heliosclient/util/entity/TargetUtils.java @@ -3,6 +3,7 @@ import dev.heliosclient.util.misc.SortMethod; import dev.heliosclient.util.player.PlayerUtils; import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import org.jetbrains.annotations.Nullable; @@ -20,7 +21,6 @@ public class TargetUtils { private double range; private Predicate filter = (entity) -> true; - public TargetUtils() { } @@ -35,12 +35,14 @@ public static boolean isEntityVisible(Entity entity) { return PlayerUtils.canSeeEntity(entity); } - public void setRange(double range) { + public TargetUtils setRange(double range) { this.range = range; + return this; } - public void setFilter(Predicate filter) { + public TargetUtils setFilter(Predicate filter) { this.filter = filter; + return this; } public Entity getTarget(PlayerEntity player) { @@ -48,7 +50,7 @@ public Entity getTarget(PlayerEntity player) { player.getWorld(), player, range, - filter, + filter.and(entity -> !(entity instanceof FreeCamEntity)), sortMethod); } @@ -78,12 +80,7 @@ public Entity getNewTargetIfNull(boolean applyFilter) { } public Entity findTarget(Consumer run) { - currentTarget = EntityUtils.getNearestEntity( - mc.world, - mc.player, - range, - filter, - sortMethod); + getTarget(mc.player); if (currentTarget != null) { run.accept(currentTarget); @@ -92,14 +89,21 @@ public Entity findTarget(Consumer run) { return currentTarget; } - public Entity findTarget(Consumer run, Predicate filter) { + public boolean found(){ + return currentTarget != null && this.filter.test(currentTarget); + } + public boolean isLivingEntity(){ + return currentTarget instanceof LivingEntity; + } + + public Entity findTarget(Consumer run, Predicate filter) { setFilter(filter); return findTarget(run); } - - public void setSortMethod(SortMethod sortMethod) { + public TargetUtils sortMethod(SortMethod sortMethod) { this.sortMethod = sortMethod; + return this; } } \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/util/fontutils/fxFontRenderer.java b/src/main/java/dev/heliosclient/util/fontutils/fxFontRenderer.java index ff36c010..9fab2bf9 100644 --- a/src/main/java/dev/heliosclient/util/fontutils/fxFontRenderer.java +++ b/src/main/java/dev/heliosclient/util/fontutils/fxFontRenderer.java @@ -1,6 +1,6 @@ package dev.heliosclient.util.fontutils; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import me.x150.renderer.font.FontRenderer; import net.minecraft.client.util.math.MatrixStack; diff --git a/src/main/java/dev/heliosclient/util/inputbox/InputBox.java b/src/main/java/dev/heliosclient/util/inputbox/InputBox.java index d030bd32..cc1ec38c 100644 --- a/src/main/java/dev/heliosclient/util/inputbox/InputBox.java +++ b/src/main/java/dev/heliosclient/util/inputbox/InputBox.java @@ -8,8 +8,8 @@ import dev.heliosclient.event.events.input.MouseClickEvent; import dev.heliosclient.event.listener.Listener; import dev.heliosclient.managers.EventManager; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.AnimationUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; diff --git a/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBox.java b/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBox.java index c5ba75da..74cfc85b 100644 --- a/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBox.java +++ b/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBox.java @@ -8,8 +8,8 @@ import dev.heliosclient.event.events.input.MouseClickEvent; import dev.heliosclient.event.listener.Listener; import dev.heliosclient.managers.EventManager; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.AnimationUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.inputbox.lua.LuaSyntaxManager; import dev.heliosclient.util.render.Renderer2D; diff --git a/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBoxOld.java b/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBoxOld.java index 6988b43f..f78967f9 100644 --- a/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBoxOld.java +++ b/src/main/java/dev/heliosclient/util/inputbox/MultiLineInputBoxOld.java @@ -8,8 +8,8 @@ import dev.heliosclient.event.events.input.MouseClickEvent; import dev.heliosclient.event.listener.Listener; import dev.heliosclient.managers.EventManager; -import dev.heliosclient.util.ColorUtils; import dev.heliosclient.util.animation.AnimationUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.render.Renderer2D; import net.minecraft.client.MinecraftClient; @@ -28,7 +28,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static dev.heliosclient.util.ColorUtils.reset; +import static dev.heliosclient.util.color.ColorUtils.reset; public class MultiLineInputBoxOld implements Listener { protected final InputBox.InputMode inputMode; diff --git a/src/main/java/dev/heliosclient/util/inputbox/lua/LuaSyntaxManager.java b/src/main/java/dev/heliosclient/util/inputbox/lua/LuaSyntaxManager.java index ab965e07..3683c4ce 100644 --- a/src/main/java/dev/heliosclient/util/inputbox/lua/LuaSyntaxManager.java +++ b/src/main/java/dev/heliosclient/util/inputbox/lua/LuaSyntaxManager.java @@ -1,6 +1,6 @@ package dev.heliosclient.util.inputbox.lua; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/dev/heliosclient/util/misc/MapReader.java b/src/main/java/dev/heliosclient/util/misc/MapReader.java index 49f4f702..4c79182c 100644 --- a/src/main/java/dev/heliosclient/util/misc/MapReader.java +++ b/src/main/java/dev/heliosclient/util/misc/MapReader.java @@ -44,4 +44,8 @@ public MapReader getMap(String key) { } return new MapReader(nestedMap); } + + public boolean mapExists(){ + return map != null; + } } diff --git a/src/main/java/dev/heliosclient/util/player/InventoryUtils.java b/src/main/java/dev/heliosclient/util/player/InventoryUtils.java index 25789b5a..82867dcc 100644 --- a/src/main/java/dev/heliosclient/util/player/InventoryUtils.java +++ b/src/main/java/dev/heliosclient/util/player/InventoryUtils.java @@ -1,7 +1,6 @@ package dev.heliosclient.util.player; import dev.heliosclient.HeliosClient; -import dev.heliosclient.module.settings.Option; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.network.ClientPlayerEntity; @@ -9,12 +8,9 @@ import net.minecraft.enchantment.Enchantments; import net.minecraft.inventory.Inventory; import net.minecraft.item.*; -import net.minecraft.registry.Registries; import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.slot.SlotActionType; -import net.minecraft.text.Text; -import java.util.ArrayList; import java.util.function.Predicate; public class InventoryUtils { @@ -219,17 +215,6 @@ public static int getFastestTool(BlockState blockState, boolean antibreak) { return bestToolSlot; // Return the fastest tool slot, or -1 if no tools were found } - public static ArrayList> getItemNames() { - ArrayList> options = new ArrayList<>(); - for (Item item : Registries.ITEM) { - String itemName = Text.translatable(item.getTranslationKey()).getLiteralString(); - //Why is this a thing????????? - //Why did I add this. When did I add this. Do I have dementia? I think I am going to keep this for now. - options.add(new Option<>(itemName, item, false)); - } - return options; - } - /** * Moves an item from a slot using quick move. * diff --git a/src/main/java/dev/heliosclient/util/player/PlayerUtils.java b/src/main/java/dev/heliosclient/util/player/PlayerUtils.java index 07924d80..4cfcf7c0 100644 --- a/src/main/java/dev/heliosclient/util/player/PlayerUtils.java +++ b/src/main/java/dev/heliosclient/util/player/PlayerUtils.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; -import static dev.heliosclient.util.ColorUtils.blend; +import static dev.heliosclient.util.color.ColorUtils.blend; public class PlayerUtils { public static MinecraftClient mc = MinecraftClient.getInstance(); @@ -35,6 +35,7 @@ public static boolean canSeeEntity(Entity entity) { return mc.player.getWorld().raycast(new RaycastContext(playerEyePos, entityBox.getCenter(), RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player)).getType() == HitResult.Type.MISS; } + //Probably doesn't work but, it should work as a placeholder public static boolean isPlayerNearEdge(double threshold) { BlockPos playerPos = mc.player.getBlockPos(); Box playerBox = mc.player.getBoundingBox(); @@ -109,13 +110,13 @@ public static boolean isPlayerLookingAtEntity(PlayerEntity player, Entity target public static boolean hasWeaponInHand(PlayerEntity player) { if (player.getMainHandStack() == null) return false; Item item = player.getMainHandStack().getItem(); - return item instanceof SwordItem || item instanceof AxeItem || item instanceof TridentItem /* || item instanceof MaceItem*/; + return item instanceof SwordItem || item instanceof AxeItem || item instanceof TridentItem || item instanceof PickaxeItem /* || item instanceof MaceItem*/; } public static boolean hasRangedWeaponInHand(PlayerEntity player) { if (player.getMainHandStack() == null) return false; Item item = player.getMainHandStack().getItem(); - return item instanceof BowItem || item instanceof CrossbowItem || item instanceof SnowballItem || item instanceof EggItem; + return item instanceof BowItem || item instanceof CrossbowItem || item instanceof SnowballItem || item instanceof EggItem || item instanceof TridentItem; } public static boolean isSprinting(PlayerEntity player) { diff --git a/src/main/java/dev/heliosclient/util/player/RotationUtils.java b/src/main/java/dev/heliosclient/util/player/RotationUtils.java index fba85d9e..30cca3f5 100644 --- a/src/main/java/dev/heliosclient/util/player/RotationUtils.java +++ b/src/main/java/dev/heliosclient/util/player/RotationUtils.java @@ -25,14 +25,6 @@ public class RotationUtils { // Queue to store rotations private static final Queue rotationQueue = new LinkedList<>(); - public static void lookAt(Entity entity, LookAtPos lookAtPos) { - lookAt(lookAtPos.positionGetter.getPosition(entity)); - } - - public static void lookAt(Entity entity) { - lookAt(LookAtPos.CENTER.positionGetter.getPosition(entity)); - } - public static void lookAtEntityMC(Entity entity, LookAtPos lookAtPos) { Vec3d vec3d = lookAtPos.positionGetter.getPosition(mc.player); double d = entity.getPos().x - vec3d.x; @@ -48,10 +40,34 @@ public static void lookAtEntityMC(Entity entity, LookAtPos lookAtPos) { mc.player.bodyYaw = mc.player.headYaw; mc.player.prevBodyYaw = mc.player.bodyYaw; } + /* == Instantly looks at a given pos == */ + public static void instaLookAt(Vec3d pos) { + instaLookAt(pos.getX(), pos.getY(), pos.getZ()); + } + public static void instaLookAt(Entity entity, LookAtPos lookAtPos) { + instaLookAt(lookAtPos.positionGetter.getPosition(entity)); + } + public static void instaLookAt(Entity entity) { + instaLookAt(LookAtPos.CENTER.positionGetter.getPosition(entity)); + } + + public static void instaLookAt(double targetX, double targetY, double targetZ) { + float yaw = (float) getYaw(targetX, targetZ); + float pitch = (float) getPitch(targetX,targetY, targetZ); + setPlayerRotations(yaw,pitch); + } + + /* == Schedules look at a given pos == */ public static void lookAt(Vec3d pos) { lookAt(pos.getX(), pos.getY(), pos.getZ()); } + public static void lookAt(Entity entity, LookAtPos lookAtPos) { + lookAt(lookAtPos.positionGetter.getPosition(entity)); + } + public static void lookAt(Entity entity) { + lookAt(LookAtPos.CENTER.positionGetter.getPosition(entity)); + } public static void lookAt(double targetX, double targetY, double targetZ) { rotate((float) getYaw(targetX, targetZ), (float) getPitch(targetX, targetY, targetZ), false, null); diff --git a/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java b/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java index bbbd7d10..2430f601 100644 --- a/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java +++ b/src/main/java/dev/heliosclient/util/render/GradientBlockRenderer.java @@ -1,6 +1,6 @@ package dev.heliosclient.util.render; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.render.color.QuadColor; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/dev/heliosclient/util/render/Renderer2D.java b/src/main/java/dev/heliosclient/util/render/Renderer2D.java index 12c1c4cc..1983c0f7 100644 --- a/src/main/java/dev/heliosclient/util/render/Renderer2D.java +++ b/src/main/java/dev/heliosclient/util/render/Renderer2D.java @@ -7,7 +7,7 @@ import dev.heliosclient.event.SubscribeEvent; import dev.heliosclient.event.events.render.RenderEvent; import dev.heliosclient.event.listener.Listener; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.entity.DisplayPreviewEntity; import dev.heliosclient.util.fontutils.FontRenderers; import dev.heliosclient.util.fontutils.fxFontRenderer; @@ -32,6 +32,7 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -52,10 +53,9 @@ public class Renderer2D implements Listener { public static DrawContext drawContext; public static Renderers renderer = Renderers.CUSTOM; public static final HashMap shadowCache = new HashMap<>(); - private static final HashMap roundedRectangleCache = new HashMap<>(); + public static final HashMap outlineShadowCache = new HashMap<>(); public static VertexSorter vertexSorter; - static { for (int i = 0; i < 36; i++) { float angle = (float) (i * Math.PI / 18); @@ -63,6 +63,9 @@ public class Renderer2D implements Listener { } } + public static void init(){ + } + /** * Draws a singular gradient rectangle on screen with the given parameters * @@ -207,6 +210,23 @@ public static void drawRectangle(Matrix4f matrix4f, float x, float y, float widt RenderSystem.disableBlend(); } + /** + * Draws a quad with the given positions as vertices on a 2D plane + */ + public static void drawQuad(Matrix4f matrix, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int color) { + RenderSystem.setShader(GameRenderer::getPositionColorProgram); + + BufferBuilder bufferBuilder = setupAndBegin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + + bufferBuilder.vertex(matrix, x1, y1, 0).color(color).next(); + bufferBuilder.vertex(matrix, x2, y2, 0).color(color).next(); + bufferBuilder.vertex(matrix, x3, y3, 0).color(color).next(); + bufferBuilder.vertex(matrix, x4, y4, 0).color(color).next(); + + draw(); + } + + /** * Draws a singular outline rectangle on screen with the given parameters * @@ -223,7 +243,7 @@ public static void drawOutlineBox(Matrix4f matrix4f, float x, float y, float wid /** * Draws a singular outline rectangle on screen with the given parameters. */ - public static void drawOutlineBox(Matrix4f matrix4f, float x, float y, float width, float height, float thickness,boolean TOP,boolean BOTTOM, boolean LEFT,boolean RIGHT, int color) { + public static void drawOutlineBox(Matrix4f matrix4f, float x, float y, float width, float height, float thickness, boolean TOP, boolean BOTTOM, boolean LEFT, boolean RIGHT, int color) { RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.setShader(GameRenderer::getPositionColorProgram); @@ -235,10 +255,10 @@ public static void drawOutlineBox(Matrix4f matrix4f, float x, float y, float wid float blue = (float) (color & 255) / 255.0F; float alpha = (float) (color >> 24 & 255) / 255.0F; - if(TOP) drawRectangleBufferInternal(matrix4f,bufferBuilder, x - thickness, y, width + thickness*2, -thickness, red,green,blue,alpha); - if(BOTTOM) drawRectangleBufferInternal(matrix4f,bufferBuilder, x - thickness, y + height, width + thickness*2, thickness, red,green,blue,alpha); - if(LEFT) drawRectangleBufferInternal(matrix4f,bufferBuilder, x, y, -thickness, height, red,green,blue,alpha); - if(RIGHT) drawRectangleBufferInternal(matrix4f,bufferBuilder, x + width, y, thickness, height, red,green,blue,alpha); + if (TOP) drawRectangleBufferInternal(matrix4f, bufferBuilder, x, y - thickness, width, thickness, red, green, blue, alpha); + if (BOTTOM) drawRectangleBufferInternal(matrix4f, bufferBuilder, x, y + height, width, thickness, red, green, blue, alpha); + if (LEFT) drawRectangleBufferInternal(matrix4f, bufferBuilder, x - thickness, y, thickness, height, red, green, blue, alpha); + if (RIGHT) drawRectangleBufferInternal(matrix4f, bufferBuilder, x + width, y, thickness, height, red, green, blue, alpha); draw(); @@ -246,7 +266,17 @@ public static void drawOutlineBox(Matrix4f matrix4f, float x, float y, float wid } /** - * Draws a outline rounded gradient rectangle + * Draws a singular outline rectangle with a blurred shadow + */ + public static void drawOutlineBoxWithShadow(MatrixStack stack, float x, float y, float width, float height, float thickness, boolean TOP, boolean BOTTOM, boolean LEFT, boolean RIGHT, int color, int shadowRadius, Color shadowColor) { + drawOutlineBlurredShadow(stack,x,y,width,height,shadowRadius, shadowColor); + + drawOutlineBox(stack.peek().getPositionMatrix(), x,y,width,height,thickness,TOP,BOTTOM,LEFT,RIGHT,color); + } + + + /** + * Draws an outline rounded gradient rectangle * * @param matrix4f Matrix4f object to draw the gradient rectangle * @param color1 is applied to the bottom-left vertex (x, y + height). @@ -260,12 +290,31 @@ public static void drawOutlineBox(Matrix4f matrix4f, float x, float y, float wid */ public static void drawOutlineGradientBox(Matrix4f matrix4f, float x, float y, float width, float height, float thickness, Color color1, Color color2, Color color3, Color color4) { // Draw the rectangles for the outline with gradient - drawGradient(matrix4f, x, y, width, thickness, color1.getRGB(), color2.getRGB(), Direction.LEFT_RIGHT); // Top rectangle - drawGradient(matrix4f, x, y + height - thickness, width, thickness, color3.getRGB(), color4.getRGB(), Direction.RIGHT_LEFT); // Bottom rectangle + drawGradient(matrix4f, x + thickness, y, width - thickness * 2, thickness, color1.getRGB(), color2.getRGB(), Direction.LEFT_RIGHT); // Top rectangle + drawGradient(matrix4f, x + thickness, y + height - thickness, width - thickness * 2, thickness, color3.getRGB(), color4.getRGB(), Direction.RIGHT_LEFT); // Bottom rectangle drawGradient(matrix4f, x, y, thickness, height, color4.getRGB(), color1.getRGB(), Direction.BOTTOM_TOP); // Left rectangle drawGradient(matrix4f, x + width - thickness, y, thickness, height, color2.getRGB(), color3.getRGB(), Direction.TOP_BOTTOM); // Right rectangle } + /** + * Draws an outline rounded gradient rectangle with a shadow + * + * @param matrices MatrixStack object to draw the gradient rectangle + * @param color1 is applied to the bottom-left vertex (x, y + height). + * @param color2 is applied to the bottom-right vertex (x + width, y + height). + * @param color3 is applied to the top-right vertex (x + width, y). + * @param color4 is applied to the top-left vertex (x, y). + * @param x X pos + * @param y Y pos + * @param width Width of gradient rectangle + * @param height Height of gradient rectangle + */ + public static void drawOutlineGradientBoxWithShadow(MatrixStack matrices, float x, float y, float width, float height, float thickness, Color color1, Color color2, Color color3, Color color4, int shadowRadius, Color shadowColor) { + //First draw the shadow + drawOutlineBlurredShadow(matrices,x,y,width,height,shadowRadius,shadowColor); + + drawOutlineGradientBox(matrices.peek().getPositionMatrix(), x,y,width,height,thickness,color1,color2,color3,color4); + } /** * Draws a singular rectangle with a dark shadow on screen with the given parameters @@ -388,6 +437,24 @@ public static void drawOutlineRoundedBox(Matrix4f matrix4f, float x, float y, fl drawArc(matrix4f, x + width - radius, y + height - radius, radius, thickness, color, 0, 90); // Bottom-right arc drawArc(matrix4f, x + radius, y + height - radius, radius, thickness, color, 270, 360); // Bottom-left arc } + /** + * Draws an outline rounded rectangle with a shadow + * + * @param matrices MatrixStack object to draw the rounded rectangle and shadow + * @param x X pos + * @param y Y pos + * @param width Width of rounded rectangle + * @param height Height of rounded rectangle + * @param radius Radius of the quadrants / the rounded rectangle + * @param color Color of the rounded rectangle + * @param thickness thickness of the outline + */ + public static void drawOutlineRoundedBoxWithShadow(MatrixStack matrices, float x, float y, float width, float height, float radius, float thickness, int color, int shadowRadius, Color shadowColor) { + //First draw shadow + drawOutlineBlurredShadow(matrices,x,y,width,height,shadowRadius,shadowColor,true,radius); + + drawOutlineRoundedBox(matrices.peek().getPositionMatrix(),x,y,width,height,radius,thickness,color); + } public static void drawRainbowGradientRectangle(Matrix4f matrix4f, float x, float y, float width, float height) { BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); @@ -464,6 +531,8 @@ public static void drawRainbowGradient(Matrix4f matrix, float x, float y, float */ public static void drawBlurredShadow(MatrixStack matrices, float x, float y, float width, float height, int blurRadius, Color color) { + if(HeliosClient.CLICKGUI.disableGlobalShadows.value) return; + width = width + blurRadius * 2; height = height + blurRadius * 2; x = x - blurRadius; @@ -492,6 +561,74 @@ public static void drawBlurredShadow(MatrixStack matrices, float x, float y, flo RenderSystem.disableBlend(); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); } + /** + * Draws a singular outline blurred shadow using the GaussianBlur algorithm on screen with the given parameters + * + * @param matrices MatrixStack object to draw the blurred shadow + * @param x X position of the blurred shadow + * @param y Y position of the blurred shadow + * @param width Width of the blurred shadow + * @param height Height of the blurred shadow + * @param blurRadius blur radius of the shadow for gaussian blur algorithm + * @param color color of the blurred shadow + */ + public static void drawOutlineBlurredShadow(MatrixStack matrices, float x, float y, float width, float height, int blurRadius, Color color, boolean rounded, float radius) { + if(HeliosClient.CLICKGUI.disableGlobalShadows.value) return; + width = width + blurRadius * 2; + height = height + blurRadius * 2; + x = x - blurRadius; + y = y - blurRadius; + + int identifier = (int) (width * height + width * blurRadius + radius * radius); + if (outlineShadowCache.containsKey(identifier)) { + outlineShadowCache.get(identifier).bind(); + RenderSystem.defaultBlendFunc(); + } else { + // Create the original image with a transparent center + int radiusR = Math.round(radius); + BufferedImage original = new BufferedImage((int) width, (int) height, BufferedImage.TYPE_INT_ARGB); + Graphics2D g = original.createGraphics(); + g.setComposite(AlphaComposite.Src); + g.setColor(new Color(-1)); + if (rounded) { + g.fillRoundRect(blurRadius, blurRadius, (int) (width - blurRadius * 2), (int) (height - blurRadius * 2), radiusR, radiusR); + } else { + g.fillRect(blurRadius, blurRadius, (int) (width - blurRadius * 2), (int) (height - blurRadius * 2)); + } + g.dispose(); + + // Apply the Gaussian blur + GaussianBlur op = new GaussianBlur(blurRadius); + BufferedImage blurred = op.applyFilter(original, null); + + // Clear the center of the blurred image to make it transparent + g = blurred.createGraphics(); + g.setComposite(AlphaComposite.Clear); + if (rounded) { + g.fillRoundRect(blurRadius, blurRadius, (int) (width - blurRadius * 2), (int) (height - blurRadius * 2),radiusR,radiusR); + } else { + g.fillRect(blurRadius, blurRadius, (int) (width - blurRadius * 2), (int) (height - blurRadius * 2)); + } + g.dispose(); + + outlineShadowCache.put(identifier, new BlurredShadow(blurred)); + return; + } + + RenderSystem.setShaderColor(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + RenderSystem.enableBlend(); + renderTexture(matrices, x, y, width, height, 0, 0, width, height, width, height); + RenderSystem.disableBlend(); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + } + + /** + * This is the same as the previous one but with fewer parameters + */ + public static void drawOutlineBlurredShadow(MatrixStack matrices, float x, float y, float width, float height, int blurRadius, Color color) { + drawOutlineBlurredShadow(matrices,x,y,width,height,blurRadius,color,false,0); + } + /** * Draws a circular blurred shadow using the GaussianBlur algorithm on screen with the given parameters @@ -504,6 +641,8 @@ public static void drawBlurredShadow(MatrixStack matrices, float x, float y, flo * @param blurRadius blur radius of the shadow for gaussian blur algorithm */ public static void drawCircularBlurredShadow(MatrixStack matrices, float xCenter, float yCenter, float radius, Color color, int blurRadius) { + if(HeliosClient.CLICKGUI.disableGlobalShadows.value) return; + // Calculate the size of the shadow image int diameter = (int) (radius * 2); int shadowWidth = diameter + blurRadius * 2; @@ -741,7 +880,6 @@ public static void drawArc(Matrix4f matrix4f, float xCenter, float yCenter, floa float blue = (float) (color & 255) / 255.0F; float alpha = (float) (color >> 24 & 255) / 255.0F; - BufferBuilder bufferBuilder = setupAndBegin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR); RenderSystem.setShader(GameRenderer::getPositionColorProgram); @@ -829,7 +967,6 @@ public static void drawFilledTriangle(Matrix4f matrix4f, int x1, int y1, int x2, bufferBuilder.vertex(matrix4f, x1, y1, 0).color(color).next(); bufferBuilder.vertex(matrix4f, x2, y2, 0).color(color).next(); bufferBuilder.vertex(matrix4f, x3, y3, 0).color(color).next(); - // bufferBuilder.vertex(matrix4f, x1, y1, 0).color(color).next(); draw(); } @@ -1045,6 +1182,7 @@ public static void drawRoundedRectangleDeprecated(Matrix4f matrix4f, float x, fl } RenderSystem.disableBlend(); } + public static void drawRectangleBufferInternal(Matrix4f matrix4f, BufferBuilder bufferBuilder, float x, float y, float width, float height, float red, float green, float blue, float alpha) { bufferBuilder.vertex(matrix4f, x, y + height, 0.0F).color(red, green, blue, alpha).next(); bufferBuilder.vertex(matrix4f, x + width, y + height, 0.0F).color(red, green, blue, alpha).next(); @@ -1081,18 +1219,25 @@ public static void drawOutlineGradientRoundedBox(Matrix4f matrix4f, float x, flo drawArc(matrix4f, x + radius, y + height - radius, radius, thickness, color4.getRGB(), 270, 360); // Bottom-left arc } - public static void unscaledProjection() { - vertexSorter = RenderSystem.getVertexSorting(); - RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0, mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight(), 0, 1000, 21000), VertexSorter.BY_Z); - } - - public static void scaledProjection() { - RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0, (float) (mc.getWindow().getFramebufferWidth() / mc.getWindow().getScaleFactor()), (float) (mc.getWindow().getFramebufferHeight() / mc.getWindow().getScaleFactor()), 0, 1000, 21000), vertexSorter); - } + /** + * Draws an outline rounded gradient rectangle + * + * @param matrices MatrixStack object to draw the rounded gradient rectangle + * @param color1 is applied to the bottom-left vertex (x, y + height). + * @param color2 is applied to the bottom-right vertex (x + width, y + height). + * @param color3 is applied to the top-right vertex (x + width, y). + * @param color4 is applied to the top-left vertex (x, y). + * @param x X pos + * @param y Y pos + * @param width Width of rounded gradient rectangle + * @param height Height of rounded gradient rectangle + * @param radius Radius of the quadrants / the rounded gradient rectangle + */ + public static void drawOutlineGradientRoundedBoxWithShadow(MatrixStack matrices, float x, float y, float width, float height, float radius, float thickness, Color color1, Color color2, Color color3, Color color4, int shadowRadius, Color shadowColor) { + //Draw the shadow first + drawOutlineBlurredShadow(matrices,x,y,width,height,shadowRadius,shadowColor,true,radius); - public static void customScaledProjection(float scale) { - vertexSorter = RenderSystem.getVertexSorting(); - RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0, mc.getWindow().getFramebufferWidth() / scale, mc.getWindow().getFramebufferHeight() / scale, 0, 1000, 21000), VertexSorter.BY_Z); + drawOutlineGradientRoundedBox(matrices.peek().getPositionMatrix(), x,y,width,height,radius,thickness,color1,color2,color3,color4); } /** @@ -1236,6 +1381,74 @@ public static void drawRoundedGradientRectangle(Matrix4f matrix, Color color1, C RenderSystem.defaultBlendFunc(); } + private static List generateGradientColors(Color[] colors, int steps) { + List gradientColors = new ArrayList<>(); + + for (int i = 0; i < colors.length - 1; i++) { + Color startColor = colors[i]; + Color endColor = colors[i + 1]; + + for (int j = 0; j < steps; j++) { + float ratio = (float) j / (float) steps; + int red = (int) (startColor.getRed() * (1 - ratio) + endColor.getRed() * ratio); + int green = (int) (startColor.getGreen() * (1 - ratio) + endColor.getGreen() * ratio); + int blue = (int) (startColor.getBlue() * (1 - ratio) + endColor.getBlue() * ratio); + int alpha = (int) (startColor.getAlpha() * (1 - ratio) + endColor.getAlpha() * ratio); + + gradientColors.add(new Color(red, green, blue, alpha)); + } + } + + // Add the final end color + gradientColors.add(colors[colors.length - 1]); + + return gradientColors; + } + + public static void drawRoundedGradientRectangle(Matrix4f matrix, Color[] colors, float x, float y, float width, float height, float radius, boolean TL, boolean TR, boolean BL, boolean BR) { + // Generate intermediate colors with 10 steps for each transition + List gradientColors = generateGradientColors(colors, 10); + + // Draw a single rounded rectangle for the same colors + if (Arrays.stream(colors).allMatch(color -> color.equals(colors[0]))) { + drawRoundedRectangle(matrix, x, y, TL, TR, BL, BR, width, height, radius, colors[0].getRGB()); + return; + } + + RenderSystem.enableBlend(); + RenderSystem.colorMask(false, false, false, true); + RenderSystem.clearColor(0.0F, 0.0F, 0.0F, 0.0F); + RenderSystem.clear(GL40C.GL_COLOR_BUFFER_BIT, false); + RenderSystem.colorMask(true, true, true, true); + drawRoundedRectangle(matrix, x, y, TL, TR, BL, BR, width, height, radius, colors[0].getRGB()); + + RenderSystem.blendFunc(GL40C.GL_DST_ALPHA, GL40C.GL_ONE_MINUS_DST_ALPHA); + RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + RenderSystem.enableBlend(); + + BufferBuilder bufferBuilder = setupAndBegin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + + float stepY = y; + float stepHeight = height / (gradientColors.size() - 1); // Ensure proper interpolation steps + + for (int i = 0; i < gradientColors.size() - 1; i++) { + Color colorTop = gradientColors.get(i); + Color colorBottom = gradientColors.get(i + 1); + + bufferBuilder.vertex(matrix, x, stepY + stepHeight, 0.0F).color(colorBottom.getRGB()).next(); + bufferBuilder.vertex(matrix, x + width, stepY + stepHeight, 0.0F).color(colorBottom.getRGB()).next(); + bufferBuilder.vertex(matrix, x + width, stepY, 0.0F).color(colorTop.getRGB()).next(); + bufferBuilder.vertex(matrix, x, stepY, 0.0F).color(colorTop.getRGB()).next(); + + stepY += stepHeight; + } + + draw(); + RenderSystem.disableBlend(); + RenderSystem.defaultBlendFunc(); + } + + /** * Draws and masks to a gradient; */ @@ -1461,6 +1674,21 @@ public static float getStringWidth(String text) { return getFontRenderer() != null ? getFontRenderer().getStringWidth(text) : 0; } + /* ==== Projection ==== */ + + public static void unscaledProjection() { + vertexSorter = RenderSystem.getVertexSorting(); + RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0, mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight(), 0, 1000, 21000), VertexSorter.BY_Z); + } + + public static void scaledProjection() { + RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0, (float) (mc.getWindow().getFramebufferWidth() / mc.getWindow().getScaleFactor()), (float) (mc.getWindow().getFramebufferHeight() / mc.getWindow().getScaleFactor()), 0, 1000, 21000), vertexSorter); + } + + public static void customScaledProjection(float scale) { + vertexSorter = RenderSystem.getVertexSorting(); + RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0, mc.getWindow().getFramebufferWidth() / scale, mc.getWindow().getFramebufferHeight() / scale, 0, 1000, 21000), VertexSorter.BY_Z); + } /* ==== Drawing Custom Text ==== */ @@ -1709,6 +1937,15 @@ public static void drawBottomText(MatrixStack stack,int x,fxFontRenderer fontRen } } + /** + * + */ + public void deleteShadowCache(){ + outlineShadowCache.clear(); + shadowCache.clear(); + } + + @SubscribeEvent public void renderEvent(RenderEvent renderEvent) { drawContext = renderEvent.getDrawContext(); @@ -1746,4 +1983,9 @@ public void bind() { RenderSystem.setShaderTexture(0, id); } } + + public enum RectRenderStyle { + ROUNDED, + PLAIN + } } \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/util/render/Renderer3D.java b/src/main/java/dev/heliosclient/util/render/Renderer3D.java index 70b55406..c5e25883 100644 --- a/src/main/java/dev/heliosclient/util/render/Renderer3D.java +++ b/src/main/java/dev/heliosclient/util/render/Renderer3D.java @@ -2,7 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import dev.heliosclient.HeliosClient; -import dev.heliosclient.util.ColorUtils; +import dev.heliosclient.util.color.ColorUtils; import dev.heliosclient.util.fontutils.fxFontRenderer; import dev.heliosclient.util.render.color.LineColor; import dev.heliosclient.util.render.color.QuadColor; diff --git a/src/main/java/dev/heliosclient/util/render/Texture.java b/src/main/java/dev/heliosclient/util/render/Texture.java deleted file mode 100644 index 34acbc71..00000000 --- a/src/main/java/dev/heliosclient/util/render/Texture.java +++ /dev/null @@ -1,27 +0,0 @@ -package dev.heliosclient.util.render; - -import net.minecraft.util.Identifier; - -// https://github.com/Pan4ur/ThunderHack-Recode/blob/main/src/main/java/thunder/hack -public class Texture extends Identifier { - public Texture(String path) { - super("heliosclient", validatePath(path)); - } - - public Texture(Identifier i) { - super(i.getNamespace(), i.getPath()); - } - - static String validatePath(String path) { - if (isValid(path)) { - return path; - } - StringBuilder ret = new StringBuilder(); - for (char c : path.toLowerCase().toCharArray()) { - if (isPathCharacterValid(c)) { - ret.append(c); - } - } - return ret.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/dev/heliosclient/util/render/color/QuadColor.java b/src/main/java/dev/heliosclient/util/render/color/QuadColor.java index b58734da..4b638bda 100644 --- a/src/main/java/dev/heliosclient/util/render/color/QuadColor.java +++ b/src/main/java/dev/heliosclient/util/render/color/QuadColor.java @@ -1,10 +1,8 @@ package dev.heliosclient.util.render.color; -import dev.heliosclient.util.ColorUtils; -import me.x150.renderer.util.Colors; +import dev.heliosclient.util.color.ColorUtils; import net.minecraft.util.math.Box; -import java.util.Arrays; import java.util.function.Function; public class QuadColor extends RenderColor { diff --git a/src/main/java/dev/heliosclient/util/render/textures/ClearTexture.java b/src/main/java/dev/heliosclient/util/render/textures/ClearTexture.java index acd5e2fa..3b9f6492 100644 --- a/src/main/java/dev/heliosclient/util/render/textures/ClearTexture.java +++ b/src/main/java/dev/heliosclient/util/render/textures/ClearTexture.java @@ -1,5 +1,6 @@ package dev.heliosclient.util.render.textures; +import dev.heliosclient.HeliosClient; import net.minecraft.client.resource.metadata.TextureResourceMetadata; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.ResourceTexture; @@ -10,10 +11,14 @@ import java.io.InputStream; public class ClearTexture extends ResourceTexture { + private static final Identifier CLEAR_TEXTURE = new Identifier(HeliosClient.MODID, "splashscreen/clear.png"); public ClearTexture(Identifier location) { super(location); } + public ClearTexture() { + super(CLEAR_TEXTURE); + } protected TextureData loadTextureData(ResourceManager resourceManager) { try { diff --git a/src/main/java/dev/heliosclient/util/render/textures/ClientTexture.java b/src/main/java/dev/heliosclient/util/render/textures/ClientTexture.java index 66cff785..1803991e 100644 --- a/src/main/java/dev/heliosclient/util/render/textures/ClientTexture.java +++ b/src/main/java/dev/heliosclient/util/render/textures/ClientTexture.java @@ -1,7 +1,6 @@ package dev.heliosclient.util.render.textures; import dev.heliosclient.HeliosClient; -import dev.heliosclient.util.fontutils.FontLoader; import net.minecraft.client.resource.metadata.TextureResourceMetadata; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.ResourceTexture; @@ -14,35 +13,32 @@ public class ClientTexture extends ResourceTexture { public static final Identifier CLIENT_LOGO_TEXTURE = new Identifier(HeliosClient.MODID, "splashscreen/client_splash.png"); + public static final Identifier CLIENT_ICON_TEXTURE = new Identifier(HeliosClient.MODID, "icon.png"); - public ClientTexture() { - super(CLIENT_LOGO_TEXTURE); + public ClientTexture(boolean icon) { + super(icon ? CLIENT_ICON_TEXTURE : CLIENT_LOGO_TEXTURE); } @Override protected TextureData loadTextureData(ResourceManager resourceManager) { - try (InputStream inputStream = FontLoader.class.getResourceAsStream("/assets/heliosclient/splashscreen/client_splash.png")) { + try (InputStream inputStream = resourceManager.open(location)) { if (inputStream == null) { - return new ResourceTexture.TextureData(new FileNotFoundException(CLIENT_LOGO_TEXTURE.toString())); + return new ResourceTexture.TextureData(new FileNotFoundException(location.toString())); } ResourceTexture.TextureData textureData; try { textureData = new ResourceTexture.TextureData(new TextureResourceMetadata(true, true), NativeImage.read(inputStream)); } catch (Throwable throwable) { - if (inputStream != null) { - try { - inputStream.close(); - } catch (Throwable var7) { - throwable.addSuppressed(var7); - } + try { + inputStream.close(); + } catch (Throwable var7) { + throwable.addSuppressed(var7); } throw throwable; } - if (inputStream != null) { - inputStream.close(); - } + inputStream.close(); return textureData; } catch (IOException exception) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 6e47e83e..8df5e52c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,6 +20,9 @@ "entrypoints": { "main": [ "dev.heliosclient.HeliosClient" + ], + "preLaunch": [ + "dev.heliosclient.PreLaunchMain" ] }, "accessWidener": "heliosclient.accesswidener",