Skip to content

Commit

Permalink
Fixed issues with HUD rendering
Browse files Browse the repository at this point in the history
Fixed HUD elements not starting with proper width.
Fixed color problems when hovering over HUD elements.
  • Loading branch information
coltonk9043 committed Dec 5, 2024
1 parent 6b1a4b0 commit 29244b3
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 261 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/aoba/gui/GuiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ public void onKeyDown(KeyDownEvent event) {
public void SetHudActive(HudWindow hud, boolean state) {
if (state) {
pinnedHuds.put(hud.getClass(), hud);
hudPane.AddWindow(hud);
hud.activated.silentSetValue(true);
hudPane.AddWindow(hud);
} else {
this.pinnedHuds.remove(hud.getClass());
hudPane.RemoveWindow(hud);
hud.activated.silentSetValue(false);
hudPane.RemoveWindow(hud);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/net/aoba/gui/colors/Color.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public Color(int r, int g, int b, int alpha) {
this.alpha = alpha;
}

public Color(float r, float g, float b, float alpha) {
this.r = (int) (r * 255f);
this.g = (int) (g * 255f);
this.b = (int) (b * 255f);
this.alpha = (int) (alpha * 255f);
}

public Color getAsSolid() {
return new Color(r, g, b, 255);
}
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/net/aoba/gui/navigation/huds/CoordsHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ public class CoordsHud extends HudWindow {
private static final MinecraftClient MC = MinecraftClient.getInstance();

public CoordsHud(int x, int y) {
super("CoordsHud", x, y);
resizeMode = ResizeMode.None;
super("CoordsHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 20f;
this.maxHeight = 20f;
resizeMode = ResizeMode.None;
}

@Override
Expand All @@ -26,13 +27,6 @@ public void draw(DrawContext drawContext, float partialTicks) {
if (pos.isDrawable()) {
String coordsText = String.format("X: %.1f, Y: %.1f, Z: %.1f", MC.player.getX(), MC.player.getY(),
MC.player.getZ());

int textWidth = MC.textRenderer.getWidth(coordsText);
int textHeight = MC.textRenderer.fontHeight;

// setWidth(textWidth * 2);
// setHeight(textHeight * 2);

Render2D.drawString(drawContext, coordsText, pos.getX(), pos.getY(),
GuiManager.foregroundColor.getValue().getColorAsInt());
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/net/aoba/gui/navigation/huds/DayHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ public class DayHud extends HudWindow {
private String timeText = null;

public DayHud(int x, int y) {
super("DayHud", x, y);
this.minHeight = 20f;
this.maxHeight = 20f;

super("DayHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 24f;
this.maxHeight = 24f;
resizeMode = ResizeMode.None;
}

@Override
public void update() {
super.update();
timeText = "Day: " + (int) (MC.world.getTime() / 24000);
int textWidth = MC.textRenderer.getWidth(timeText);
// setMinWidth(textWidth * 2);
}

@Override
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/net/aoba/gui/navigation/huds/FPSHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ public class FPSHud extends HudWindow {
private static final MinecraftClient MC = MinecraftClient.getInstance();

public FPSHud(int x, int y) {
super("FPSHud", x, y);
resizeMode = ResizeMode.None;
super("FPSHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 20f;
this.maxHeight = 20f;
resizeMode = ResizeMode.None;
}

@Override
Expand All @@ -26,13 +27,6 @@ public void draw(DrawContext drawContext, float partialTicks) {
if (pos.isDrawable()) {
int fps = MC.getCurrentFps();
String fpsText = "FPS: " + fps;

int textWidth = MC.textRenderer.getWidth(fpsText);
int textHeight = MC.textRenderer.fontHeight;

// setWidth(textWidth * 2);
// setHeight(textHeight * 2);

Render2D.drawString(drawContext, fpsText, pos.getX(), pos.getY(),
GuiManager.foregroundColor.getValue().getColorAsInt());
}
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/net/aoba/gui/navigation/huds/NetherCoordsHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ public class NetherCoordsHud extends HudWindow {
private static final MinecraftClient MC = MinecraftClient.getInstance();

public NetherCoordsHud(int x, int y) {
super("NetherCoordsHud", x, y);
resizeMode = ResizeMode.None;
super("NetherCoordsHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 20f;
this.maxHeight = 20f;
resizeMode = ResizeMode.None;
}

@Override
Expand All @@ -26,13 +27,6 @@ public void draw(DrawContext drawContext, float partialTicks) {
if (pos.isDrawable()) {
String coordsText = String.format("X: %.1f, Y: %.1f, Z: %.1f", MC.player.getX() * 8, MC.player.getY(),
MC.player.getZ() * 8);

int textWidth = MC.textRenderer.getWidth(coordsText);
int textHeight = MC.textRenderer.fontHeight;

// setWidth(textWidth * 2);
// setHeight(textHeight * 2);

Render2D.drawString(drawContext, coordsText, pos.getX(), pos.getY(),
GuiManager.foregroundColor.getValue().getColorAsInt());
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/net/aoba/gui/navigation/huds/PingHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ public class PingHud extends HudWindow {
String pingText = null;

public PingHud(int x, int y) {
super("PingHud", x, y);
resizeMode = ResizeMode.None;
super("PingHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 20f;
this.maxHeight = 20f;
resizeMode = ResizeMode.None;
}

@Override
Expand All @@ -32,9 +33,6 @@ public void update() {
} else {
pingText = "Ping: ?";
}

int textWidth = MC.textRenderer.getWidth(pingText);
// setWidth(textWidth * 2);
} else
pingText = null;
}
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/net/aoba/gui/navigation/huds/SpeedHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class SpeedHud extends HudWindow {
private String speedText = null;

public SpeedHud(int x, int y) {
super("SpeedHud", x, y);
super("SpeedHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 20f;
this.maxHeight = 20f;

resizeMode = ResizeMode.None;
}

Expand All @@ -34,9 +34,6 @@ public void update() {
double speed = distance * 20 * 3.6;

speedText = String.format("Speed: %.2f km/h", speed);

int textWidth = MC.textRenderer.getWidth(speedText);
// setWidth(textWidth * 2);
} else
speedText = null;
}
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/net/aoba/gui/navigation/huds/TimeHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ public class TimeHud extends HudWindow {
private String timeText = null;

public TimeHud(int x, int y) {
super("TimeHud", x, y);

super("TimeHud", x, y, 80, 24);
this.minWidth = 80f;
this.minHeight = 20f;
this.maxHeight = 20f;

resizeMode = ResizeMode.None;
}

Expand All @@ -41,8 +40,6 @@ public void update() {
timeString = new StringBuilder(hours + ":" + sm.charAt(0) + sm.charAt(1) + suffix);

timeText = timeString.toString();
int textWidth = MC.textRenderer.getWidth(timeText);
// setWidth(textWidth * 2);
}

@Override
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/net/aoba/gui/navigation/huds/WatermarkHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
public class WatermarkHud extends HudWindow {

public WatermarkHud(int x, int y) {
super("WatermarkHud", x, y);

resizeMode = ResizeMode.None;

super("WatermarkHud", x, y, 50, 24);
this.minWidth = 50f;
this.minHeight = 20f;
this.maxHeight = 20f;
resizeMode = ResizeMode.None;
}

@Override
Expand All @@ -24,13 +23,6 @@ public void draw(DrawContext drawContext, float partialTicks) {
Rectangle pos = position.getValue();
if (pos.isDrawable()) {
String watermarkText = "Aoba Client";

int textWidth = MC.textRenderer.getWidth(watermarkText);
int textHeight = MC.textRenderer.fontHeight;

// setWidth(textWidth * 2);
// setHeight(textHeight * 2);

Render2D.drawString(drawContext, watermarkText, pos.getX(), pos.getY(),
GuiManager.foregroundColor.getValue().getColorAsInt());
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/aoba/module/AntiCheat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.aoba.module;

public enum AntiCheat {
Vanilla, NoCheatPlus, Vulcan, AdvancedAntiCheat, Verus, Grim, Matrix, Negativity, Karhu,

}
16 changes: 9 additions & 7 deletions src/main/java/net/aoba/module/modules/misc/AntiHunger.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ public void onSendPacket(SendPacketEvent event) {
return;
}

if (MC.player.hasVehicle() || MC.player.isTouchingWater() || MC.player.isSubmergedInWater())
return;
if (MC.player != null) {
if (MC.player.hasVehicle() || MC.player.isTouchingWater() || MC.player.isSubmergedInWater())
return;

if (event.GetPacket() instanceof PlayerMoveC2SPacket packet && onGround.getValue() && MC.player.isOnGround()
&& MC.player.fallDistance <= 0.0 && !MC.interactionManager.isBreakingBlock()) {
((IPlayerMoveC2SPacket) packet).setOnGround(false);
}
}

if (event.GetPacket() instanceof ClientCommandC2SPacket packet && sprint.getValue()) {
if (packet.getMode() == ClientCommandC2SPacket.Mode.START_SPRINTING)
event.cancel();
}

if (event.GetPacket() instanceof PlayerMoveC2SPacket packet && onGround.getValue() && MC.player.isOnGround()
&& MC.player.fallDistance <= 0.0 && !MC.interactionManager.isBreakingBlock()) {
((IPlayerMoveC2SPacket) packet).setOnGround(false);
}
}

@Override
Expand Down
Loading

0 comments on commit 29244b3

Please sign in to comment.