Added custom decimal points for speedometer and close #773

This commit is contained in:
Bella 2020-05-05 15:23:55 -04:00
parent 9b79fd2cc1
commit 8154f0715f
No known key found for this signature in database
GPG Key ID: DBD4A6030080C8B3
2 changed files with 4 additions and 3 deletions

View File

@ -51,6 +51,7 @@ public class InfoOverlay extends Module {
private Setting<Boolean> godApples = register(Settings.booleanBuilder("God Apples").withValue(false).withVisibility(v -> page.getValue().equals(Page.TWO)).build());
/* Page Three */
private Setting<Boolean> speed = register(Settings.booleanBuilder("Speed").withValue(true).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
private Setting<Integer> speedPrecision = register(Settings.integerBuilder("S Decimals").withValue(2).withMinimum(0).withMaximum(10).withVisibility(v -> speed.getValue() && page.getValue().equals(Page.THREE)).build());
private Setting<SpeedUnit> speedUnit = register(Settings.enumBuilder(SpeedUnit.class).withName("Speed Unit").withValue(SpeedUnit.KMH).withVisibility(v -> page.getValue().equals(Page.THREE) && speed.getValue()).build());
private Setting<Boolean> time = register(Settings.booleanBuilder("Time").withValue(true).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public Setting<TimeUtil.TimeType> timeTypeSetting = register(Settings.enumBuilder(TimeUtil.TimeType.class).withName("Time Format").withValue(TimeUtil.TimeType.HHMMSS).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
@ -80,7 +81,7 @@ public class InfoOverlay extends Module {
} if (fps.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + Minecraft.debugFPS + getStringColour(setToText(secondColour.getValue())) + " fps");
} if (speed.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + speed(useUnitKmH(), mc) + getStringColour(setToText(secondColour.getValue())) + " " + unitType(speedUnit.getValue()));
infoContents.add(getStringColour(setToText(firstColour.getValue())) + speed(useUnitKmH(), mc, speedPrecision.getValue()) + getStringColour(setToText(secondColour.getValue())) + " " + unitType(speedUnit.getValue()));
} if (timerSpeed.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + TimerSpeed.returnGui() + getStringColour(setToText(secondColour.getValue())) + "t");
} if (ping.getValue()) {

View File

@ -45,11 +45,11 @@ public class InfoCalculator {
// Speed {
private static DecimalFormat formatter = new DecimalFormat("#.#");
public static String speed(boolean useUnitKmH, Minecraft mc) {
public static String speed(boolean useUnitKmH, Minecraft mc, int places) {
float currentTps = mc.timer.tickLength / 1000.0f;
double multiply = 1.0;
if (useUnitKmH) multiply = 3.6; // convert mps to kmh
return formatter.format(((MathHelper.sqrt(Math.pow(coordsDiff('x', mc), 2) + Math.pow(coordsDiff('z', mc), 2)) / currentTps)) * multiply);
return "" + MathsUtils.round(((MathHelper.sqrt(Math.pow(coordsDiff('x', mc), 2) + Math.pow(coordsDiff('z', mc), 2)) / currentTps)) * multiply, places);
}
private static double coordsDiff(char s, Minecraft mc) {