Skip to content

Commit

Permalink
Lots of changes, as follows:
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
tanishisherewithhh committed Oct 31, 2024
1 parent dcb61ec commit 52cdbbe
Show file tree
Hide file tree
Showing 124 changed files with 1,406 additions and 862 deletions.
34 changes: 12 additions & 22 deletions src/main/java/dev/heliosclient/HeliosClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -69,12 +72,11 @@ public static void loadConfig() {

private static void load(Consumer<Config> 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));
}

Expand Down Expand Up @@ -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();
Expand All @@ -145,7 +149,6 @@ public void onInitialize() {

LOGGER.info("Initialising Helios Client...");

ColorManager.createInstance();
CONFIG.init();
CLICKGUI = new ClickGUI();

Expand All @@ -155,7 +158,6 @@ public void onInitialize() {

LuaScriptManager.getScripts();


FontManager.INSTANCE.refresh();
ADDONMANAGER.loadAddons();
AddonManager.initializeAddons();
Expand All @@ -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() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/dev/heliosclient/PreLaunchMain.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
4 changes: 2 additions & 2 deletions src/main/java/dev/heliosclient/altmanager/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) { }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/command/commands/Bind.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/command/commands/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/dev/heliosclient/event/SubscribeEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -19,5 +19,3 @@ enum Priority {
}
}



6 changes: 6 additions & 0 deletions src/main/java/dev/heliosclient/event/events/TickEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 52cdbbe

Please sign in to comment.