Skip to content

Commit

Permalink
Some things and changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishisherewithhh committed Jul 1, 2024
1 parent aa50760 commit fda7b0c
Show file tree
Hide file tree
Showing 49 changed files with 724 additions and 143 deletions.
5 changes: 5 additions & 0 deletions src/main/java/dev/heliosclient/HeliosClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public void onInitialize() {

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

CONFIG.init();

EventManager.register(this);
registerEvents();

Expand Down Expand Up @@ -161,6 +163,9 @@ public void onInitialize() {
}
HeliosClient.CLICKGUI.onLoad();
});

if (fonts != null)
EventManager.postEvent(new FontChangeEvent(fonts));
}

public void registerEvents() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/heliosclient/hud/HudElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public void onSettingChange(Setting<?> setting) {

@SubscribeEvent
public void onFontChange(FontChangeEvent event) {
this.height = (int) Renderer2D.getStringHeight();
this.height = Math.round(Renderer2D.getStringHeight());
}

@Override
Expand All @@ -467,7 +467,7 @@ public Object saveToToml(List<Object> objects) {
map.put("positions", objects);

for (SettingGroup settingGroup : settingGroups) {
for (Setting setting : settingGroup.getSettings()) {
for (Setting<?> setting : settingGroup.getSettings()) {
if (setting.name != null) {
map.put(setting.name.replace(" ", ""), setting.saveToToml(new ArrayList<>()));
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/dev/heliosclient/hud/hudelements/Bps.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@


public class Bps extends HudElement {
public static HudElementData<Bps> DATA = new HudElementData<>("Player Speed", "Shows player speed in blocks per second", Bps::new);

public Bps() {
super(DATA);
this.width = 40;
this.height = 10;
this.height = Math.round(Renderer2D.getStringHeight());
}

@Override
Expand All @@ -34,7 +36,8 @@ private double moveSpeed() {
Vec3d move = new Vec3d(mc.player.getX() - mc.player.prevX, 0, mc.player.getZ() - mc.player.prevZ).multiply(20);

return Math.abs(MathUtils.length2D(move));
} public static HudElementData<Bps> DATA = new HudElementData<>("Player Speed", "Shows player speed in blocks per second", Bps::new);
}




Expand Down
11 changes: 6 additions & 5 deletions src/main/java/dev/heliosclient/hud/hudelements/ClientTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
import net.minecraft.client.gui.DrawContext;

public class ClientTag extends HudElement {

public static HudElementData<ClientTag> DATA = new HudElementData<>("Client Tag", "Shows client watermark", ClientTag::new);


public ClientTag() {
super(DATA);
this.width = 20;
this.height = 13;
this.height = Math.round(Renderer2D.getStringHeight());
this.draggable = false;
this.renderOutLineBox = false;
}
Expand All @@ -27,7 +31,4 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {

super.renderElement(drawContext, textRenderer);
Renderer2D.drawString(drawContext.getMatrices(), text, this.x, this.y, ColorManager.INSTANCE.hudColor);
}

public static HudElementData<ClientTag> DATA = new HudElementData<>("Client Tag", "Shows client watermark", ClientTag::new);
}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ private String getCardinalDirection(int i) {
};
}

public static HudElementData<CompassHud> DATA = new HudElementData<>("CompassHud", "Displays an isometric circular compass", CompassHud::new);
public static HudElementData<CompassHud> DATA = new HudElementData<>("Compass", "Displays an elliptical compass", CompassHud::new);
}
61 changes: 51 additions & 10 deletions src/main/java/dev/heliosclient/hud/hudelements/CoordinatesHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,84 @@
import dev.heliosclient.managers.ColorManager;
import dev.heliosclient.hud.HudElement;
import dev.heliosclient.hud.HudElementData;
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.render.Renderer2D;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.entity.Entity;


public class CoordinatesHud extends HudElement {

public SettingGroup sgSettings = new SettingGroup("Settings");

private final BooleanSetting noXYZ = sgSettings.add(new BooleanSetting.Builder()
.name("NoXYZ")
.description("Does not show the XYZ coordinates")
.onSettingChange(this)
.defaultValue(false)
.build()
);
private final BooleanSetting cameraEntity = sgSettings.add(new BooleanSetting.Builder()
.name("Camera Coords")
.description("Shows the coordinates of camera instead of player")
.onSettingChange(this)
.defaultValue(false)
.build()
);
private final BooleanSetting netherCoords = sgSettings.add(new BooleanSetting.Builder()
.name("Nether Coords")
.description("Shows the coordinates of nether")
.onSettingChange(this)
.defaultValue(false)
.build()
);

int coordX, coordY, coordZ;

public CoordinatesHud() {
super(DATA);
this.width = 50;
this.height = 10;
this.height = Math.round(Renderer2D.getStringHeight());
addSettingGroup(sgSettings);
}

@Override
public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
super.renderElement(drawContext, textRenderer);
int coordX, coordY, coordZ;
if (mc.player == null) {

Entity entityForCoords = cameraEntity.value ? mc.getCameraEntity() : mc.player;

if (entityForCoords == null) {
coordX = 0;
coordY = 0;
coordZ = 0;
} else {
coordX = (int) MathUtils.round(mc.player.getX(), 0);
coordY = (int) MathUtils.round(mc.player.getY(), 0);
coordZ = (int) MathUtils.round(mc.player.getZ(), 0);
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);
}

String text = "X: " + ColorUtils.gray + coordX + ColorUtils.reset +
" Y: " + ColorUtils.gray + coordY + ColorUtils.reset +
" Z: " + ColorUtils.gray + coordZ;
String x = ColorUtils.gray + coordX + ColorUtils.reset;
String y = ColorUtils.gray + coordY + ColorUtils.reset;
String z = ColorUtils.gray + coordZ;


String text = (!noXYZ.value? "X: ": "") + x +
(!noXYZ.value? " Y: ": ", ")+ y +
(!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);
}

public static HudElementData<CoordinatesHud> DATA = new HudElementData<>("Coords", "Shows player coords", CoordinatesHud::new);
public static HudElementData<CoordinatesHud> DATA = new HudElementData<>("Coordinates", "Shows player coords", CoordinatesHud::new);


}
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/hud/hudelements/Fps.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Fps extends HudElement {
public Fps() {
super(DATA);
this.width = 20;
this.height = 10;
this.height = Math.round(Renderer2D.getStringHeight());
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/dev/heliosclient/hud/hudelements/Ping.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@

public class Ping extends HudElement {

public static HudElementData<Ping> DATA = new HudElementData<>("Ping", "Shows current player ping", Ping::new);


public Ping() {
super(DATA);

this.width = 20;
this.height = 10;
this.height = Math.round(Renderer2D.getStringHeight());
}

public static int getPing() {
Expand All @@ -37,7 +40,4 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
Renderer2D.drawString(drawContext.getMatrices(), text, this.x, this.y, ColorManager.INSTANCE.hudColor);
}

public static HudElementData<Ping> DATA = new HudElementData<>("Ping", "Shows current player ping", Ping::new);


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.util.math.MathHelper;

import java.awt.*;

Expand All @@ -35,15 +36,15 @@ public PlayerModel() {

@Override
public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
this.width = 30;
this.height = 55;
this.width = 30 + (int) (size.value * size.value);
this.height = Math.round((float) (55 * size.value));
super.renderElement(drawContext, textRenderer);
ClientPlayerEntity player = HeliosClient.MC.player;
if (player == null && !renderBg.value) {
Renderer2D.drawRectangle(drawContext.getMatrices().peek().getPositionMatrix(), this.x, this.y, width - 1, height - 1, Color.BLACK.getRGB());
}
if (player != null) {
Renderer2D.drawEntity(drawContext, x + width / 2, y + height - 6, ((int) (25 * size.value)), player, HeliosClient.MC.getTickDelta());
Renderer2D.drawEntity(drawContext, x + width / 2, (int) (y + height - (6 * size.value)), ((int) (25 * size.value)), player, HeliosClient.MC.getTickDelta());
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/dev/heliosclient/hud/hudelements/Radar.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class Radar extends HudElement {
private static int MAX_DISTANCE = 25; // Maximum entity distance
public SettingGroup sgRadarSettings = new SettingGroup("General");
public SettingGroup sgRadarColors = new SettingGroup("Colors");

public static HudElementData<Radar> 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")
Expand All @@ -34,7 +37,7 @@ public class Radar extends HudElement {
.value(25.0D)
.onSettingChange(this)
.build()
); public static HudElementData<Radar> DATA = new HudElementData<>("Radar", "Shows entities radar", Radar::new);
);
public DoubleSetting size = sgRadarSettings.add(new DoubleSetting.Builder()
.name("Size")
.description("Radar size")
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/hud/hudelements/Tps.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Tps extends HudElement {
public Tps() {
super(DATA);
this.width = 20;
this.height = 10;
this.height = Math.round(Renderer2D.getStringHeight());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class WelcomeHud extends HudElement {
public WelcomeHud() {
super(DATA);
addSettingGroup(sgGeneral);

this.height = Math.round(Renderer2D.getStringHeight());
}
@Override
public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/managers/CapeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static String[] loadCapes() {
if (inputStream == null) {
HeliosClient.LOGGER.error("Failed to load open inputStream to default cape resource");
} else {
HeliosClient.LOGGER.info("Copying default CURRENT_PLAYER_CAPE in directory");
HeliosClient.LOGGER.info("Copying default cape file in directory");
Files.copy(inputStream, defaultCapeFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
HeliosClient.LOGGER.info("Copying completed");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/heliosclient/managers/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public ConfigManager(String pathName) {
* @param hashmap The configuration map.
*/
public void registerConfig(String name, Map<String, Object> hashmap) {
if (configMaps.containsKey(name) || tomls.containsKey(name) || configFiles.containsKey(name)) return;
if (configMaps.containsKey(name) || tomls.containsKey(name) || configFiles.containsKey(name)) {
return;
}
configMaps.put(name, hashmap);
tomls.put(name, new Toml());
configFiles.put(name, new File(configDir, name + ".toml"));
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/dev/heliosclient/managers/EventManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.concurrent.*;

public class EventManager {
private static final Map<Class<?>, List<EventListener>> listeners = new ConcurrentHashMap<>();
private static final WeakHashMap<Class<?>, LinkedList<EventListener>> listeners = new WeakHashMap<>();

private static final Comparator<EventListener> METHOD_COMPARATOR = Comparator.comparingInt(el -> {
SubscribeEvent annotation = el.method.getAnnotation(SubscribeEvent.class);
Expand Down Expand Up @@ -41,13 +41,13 @@ public static void register(Listener listener) {
}

private static List<EventListener> getListeners(Class<?> eventClass) {
return listeners.computeIfAbsent(eventClass, key -> new ArrayList<>());
return listeners.computeIfAbsent(eventClass, key -> new LinkedList<>());
}


public static void unregister(Listener listener) {
for (List<EventListener> eventListeners : new CopyOnWriteArraySet<>(listeners.values())) {
eventListeners.removeIf(el -> el.listener == listener);
for (List<EventListener> eventListeners : new CopyOnWriteArraySet<>(listeners.values())) {
eventListeners.removeIf(el -> el.listener == listener || el.listener == null);
}
}

Expand All @@ -59,6 +59,10 @@ public static Event postEvent(Event event) {
List<EventListener> eventListeners = listeners.get(event.getClass());
if (eventListeners != null && !eventListeners.isEmpty()) {
for (EventListener listener : new CopyOnWriteArraySet<>(eventListeners)) {
if(listener == null){
eventListeners.remove(listener);
continue;
}
listener.accept(event);
}
}
Expand Down Expand Up @@ -98,7 +102,6 @@ private static void handleException(Throwable e, Listener listener, Event event)
private record EventListener(Listener listener, Method method) {
public void accept(Event event) {
try {
if(method != null)
method.invoke(listener, event);
} catch (Throwable e) {
handleException(e, listener, event);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/heliosclient/managers/ModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import dev.heliosclient.module.modules.chat.ChatTweaks;
import dev.heliosclient.module.modules.chat.Spammer;
import dev.heliosclient.module.modules.combat.AimAssist;
import dev.heliosclient.module.modules.combat.BowSpam;
import dev.heliosclient.module.modules.combat.Criticals;
import dev.heliosclient.module.modules.misc.*;
import dev.heliosclient.module.modules.movement.*;
Expand All @@ -30,6 +31,7 @@ public static void init() {
//Combat
registerModules(
new AimAssist(),
new BowSpam(),
new Criticals()
);

Expand Down Expand Up @@ -95,6 +97,7 @@ public static void init() {
new Speed(),
new Step(),
new Velocity(),
new TargetStrafe(),
new TridentTweaker(),
new TickShift()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.*;

public class NotificationManager implements Listener {
private static final int HEIGHT = 25;
private static final Queue<Notification> notificationQueue = new LinkedList<>(); // Queue to hold notifications
private static final Deque<Notification> displayedNotifications = new ArrayDeque<>(); // Deque to hold currently displayed notifications
public static NotificationManager INSTANCE = new NotificationManager();
Expand Down Expand Up @@ -47,11 +46,12 @@ private static void updateNotifications() {

private static void updatePositions() {
int screenHeight = HeliosClient.MC.getWindow().getScaledHeight();
int y = screenHeight - HEIGHT - 5;
int y = screenHeight - 5;

for (Notification notification : displayedNotifications) {
notification.moveY(y - notification.targetY);
y -= HEIGHT + 5;
int notificationHeight = notification.HEIGHT;
notification.moveY(y - notificationHeight - notification.targetY);
y -= notificationHeight + 5;
}
}

Expand Down
Loading

0 comments on commit fda7b0c

Please sign in to comment.