Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a HUD #93

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/net/wurstclient/hack/HackList.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public final class HackList implements UpdateListener
public final HeadRollHack headRollHack = new HeadRollHack();
public final HealthTagsHack healthTagsHack = new HealthTagsHack();
public final HighJumpHack highJumpHack = new HighJumpHack();
public final HUDHack hudHack = new HUDHack();
public final InfiniChatHack infiniChatHack = new InfiniChatHack();
public final InstantBunkerHack instantBunkerHack = new InstantBunkerHack();
public final ItemEspHack itemEspHack = new ItemEspHack();
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/net/wurstclient/hacks/HUDHack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.wurstclient.hacks;

import net.wurstclient.Category;
import net.wurstclient.SearchTags;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;

@SearchTags({"HUD"})
public final class HUDHack extends Hack
{
private final CheckboxSetting fps = new CheckboxSetting("FPS","Display your current FPS", true);
private final CheckboxSetting speed = new CheckboxSetting("Speed","Display your current speed", true);
private final CheckboxSetting coords = new CheckboxSetting("Coordinates","Display your current coordinates", true);
private final CheckboxSetting dim_coord = new CheckboxSetting("Dimension Coordinates","Display your Nether coordinates in the Owerworld or your Owerworld coordinates in the Nether", true);

public HUDHack() {
super("HUD", "Display useful information on your screen");
setCategory(Category.OTHER);
addSetting(fps);
addSetting(speed);
addSetting(coords);
addSetting(dim_coord);
}
}
98 changes: 98 additions & 0 deletions src/main/java/net/wurstclient/hud/InfoHUD.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package net.wurstclient.hud;

import java.util.Map;

import net.minecraft.client.font.TextRenderer;
import net.minecraft.util.math.Position;
import net.minecraft.world.dimension.DimensionType;
import net.wurstclient.WurstClient;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.Setting;

public class InfoHUD {
private double speed;
private Position prevPos;
private long prevTime;
private Map<String,Setting> settings;
public InfoHUD() {
settings = WurstClient.INSTANCE.getHax().hudHack.getSettings();
prevTime = System.currentTimeMillis();
speed = 0;
prevPos = new Position(){

@Override
public double getZ() {
return 0;
}

@Override
public double getY() {
return 0;
}

@Override
public double getX() {
return 0;
}
};
}
public void renderer(float partialTicks) {
int screenHeight = WurstClient.MC.getWindow().getScaledHeight();
int xPos = 2;
int yOffset = 10;
int yPos = screenHeight-yOffset;

Position pos = WurstClient.MC.player.getPos();

if(((CheckboxSetting)settings.get("dimension coordinates")).isChecked()){
int color;
String dimension_pos;
if(WurstClient.MC.player.dimension == DimensionType.THE_NETHER) {
color = 0xffffffff;
dimension_pos = "X: " + (int)Math.floor(pos.getX()*8) + " Y: " + (int)Math.floor(pos.getY()) + " Z: " + (int)Math.floor(pos.getZ()*8);
}
else {
color = 0xffff0000;
dimension_pos = "X: " + (int)Math.floor(pos.getX()/8) + " Y: " + (int)Math.floor(pos.getY()) + " Z: " + (int)Math.floor(pos.getZ()/8);
}
drawText(dimension_pos, xPos, yPos, color);
yPos-=yOffset;
}

if(((CheckboxSetting)settings.get("coordinates")).isChecked()){
String defpos = "X: " + (int)Math.floor(pos.getX()) + " Y: " + (int)Math.floor(pos.getY()) + " Z: " + (int)Math.floor(pos.getZ());
int color;
if(WurstClient.MC.player.dimension == DimensionType.THE_NETHER) {
color = 0xffff0000;
}
else {
color = 0xffffffff;
}
drawText(defpos, xPos, yPos, color);
yPos -= yOffset;
}
//TODO: Calculate the speed more accurately
if(((CheckboxSetting)settings.get("speed")).isChecked()){
long currTime = System.currentTimeMillis();
long deltaTime = currTime-prevTime;
if(deltaTime > 500){
double dist = Math.sqrt(Math.pow(Math.abs(pos.getX()-prevPos.getX()),2)+Math.pow(Math.abs(pos.getZ()-prevPos.getZ()),2));
speed = (double)dist/((double)deltaTime/1000);
prevPos = pos;
prevTime = currTime;
}
drawText(Math.round(speed*10.0)/10.0 + " m/s", xPos, yPos, 0xffffffff);
yPos-=yOffset;
}
if(((CheckboxSetting)settings.get("fps")).isChecked()) {
drawText(WurstClient.MC.fpsDebugString.split(" fps")[0]+" FPS", xPos, yPos, 0xffffffff);
yPos -= yOffset;
}
}

public void drawText(String s, int x, int y, int color) {
TextRenderer tr = WurstClient.MC.textRenderer;

tr.draw(s, x, y, color);
}
}
4 changes: 4 additions & 0 deletions src/main/java/net/wurstclient/hud/IngameHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public final class IngameHUD implements GUIRenderListener
{
private final WurstLogo wurstLogo = new WurstLogo();
private final HackListHUD hackList = new HackListHUD();
private final InfoHUD infoHUD = new InfoHUD();
private TabGui tabGui;

@Override
Expand All @@ -41,6 +42,9 @@ public void onRenderGUI(float partialTicks)
wurstLogo.render();
hackList.render(partialTicks);
tabGui.render(partialTicks);

if(WurstClient.INSTANCE.getHax().hudHack.isEnabled())
infoHUD.renderer(partialTicks);

// pinned windows
if(!(WurstClient.MC.currentScreen instanceof ClickGuiScreen))
Expand Down