From 848ada0fb25f69d09246181b1a9f119437e84033 Mon Sep 17 00:00:00 2001 From: Bella Date: Sun, 10 May 2020 14:35:52 -0400 Subject: [PATCH] Added auto delay for crystalaura and close #784 --- .../kami/module/modules/client/InfoOverlay.java | 6 +++--- .../kami/module/modules/combat/CrystalAura.java | 13 +++++++++++-- .../me/zeroeightsix/kami/util/InfoCalculator.java | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/client/InfoOverlay.java b/src/main/java/me/zeroeightsix/kami/module/modules/client/InfoOverlay.java index 15ff2873c..cfdedead3 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/client/InfoOverlay.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/client/InfoOverlay.java @@ -51,7 +51,7 @@ public class InfoOverlay extends Module { private Setting godApples = register(Settings.booleanBuilder("God Apples").withValue(false).withVisibility(v -> page.getValue().equals(Page.TWO)).build()); /* Page Three */ private Setting speed = register(Settings.booleanBuilder("Speed").withValue(true).withVisibility(v -> page.getValue().equals(Page.THREE)).build()); - private Setting speedPrecision = register(Settings.integerBuilder("S Decimals").withValue(2).withMinimum(0).withMaximum(10).withVisibility(v -> speed.getValue() && page.getValue().equals(Page.THREE)).build()); + private Setting decimalPlaces = register(Settings.integerBuilder("Decimal Places").withValue(2).withMinimum(0).withMaximum(10).withVisibility(v -> speed.getValue() && page.getValue().equals(Page.THREE)).build()); private Setting speedUnit = register(Settings.enumBuilder(SpeedUnit.class).withName("Speed Unit").withValue(SpeedUnit.KMH).withVisibility(v -> page.getValue().equals(Page.THREE) && speed.getValue()).build()); private Setting time = register(Settings.booleanBuilder("Time").withValue(true).withVisibility(v -> page.getValue().equals(Page.THREE)).build()); public Setting timeTypeSetting = register(Settings.enumBuilder(TimeUtil.TimeType.class).withName("Time Format").withValue(TimeUtil.TimeType.HHMMSS).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build()); @@ -77,11 +77,11 @@ public class InfoOverlay extends Module { } if (time.getValue()) { infoContents.add(getStringColour(setToText(firstColour.getValue())) + TimeUtil.getFinalTime(setToText(secondColour.getValue()), setToText(firstColour.getValue()), timeUnitSetting.getValue(), timeTypeSetting.getValue(), doLocale.getValue())); } if (tps.getValue()) { - infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.tps() + getStringColour(setToText(secondColour.getValue())) + " tps"); + infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.tps(decimalPlaces.getValue()) + getStringColour(setToText(secondColour.getValue())) + " tps"); } 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, speedPrecision.getValue()) + getStringColour(setToText(secondColour.getValue())) + " " + unitType(speedUnit.getValue())); + infoContents.add(getStringColour(setToText(firstColour.getValue())) + speed(useUnitKmH(), mc, decimalPlaces.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()) { diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/combat/CrystalAura.java b/src/main/java/me/zeroeightsix/kami/module/modules/combat/CrystalAura.java index de67d90d9..e6791b6b7 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/combat/CrystalAura.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/combat/CrystalAura.java @@ -66,7 +66,8 @@ public class CrystalAura extends Module { private Setting explode = register(Settings.booleanBuilder("Explode").withValue(false).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting checkAbsorption = register(Settings.booleanBuilder("Check Absorption").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); public Setting range = register(Settings.doubleBuilder("Range").withMinimum(1.0).withValue(4.0).withMaximum(10.0).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); - private Setting delay = register(Settings.doubleBuilder("Hit Delay").withMinimum(0.0).withValue(5.0).withMaximum(10.0).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); + private Setting autoDelay = register(Settings.booleanBuilder("Auto Delay").withValue(false).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); + private Setting delay = register(Settings.doubleBuilder("Hit Delay").withMinimum(0.0).withValue(5.0).withMaximum(10.0).withVisibility(v -> !autoDelay.getValue() && p.getValue().equals(Page.ONE)).build()); private Setting hitAttempts = register(Settings.integerBuilder("Hit Attempts").withValue(-1).withMinimum(-1).withMaximum(20).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting minDmg = register(Settings.doubleBuilder("Minimum Damage").withMinimum(0.0).withValue(0.0).withMaximum(32.0).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); private Setting sneakEnable = register(Settings.booleanBuilder("Sneak Surround").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build()); @@ -165,7 +166,7 @@ public class CrystalAura extends Module { if (explode.getValue() && crystal != null && mc.player.getDistance(crystal) <= range.getValue() && passSwordCheck()) { // Added delay to stop ncp from flagging "hitting too fast" - if (((System.nanoTime() / 1000000f) - systemTime) >= 25*delay.getValue()) { + if (((System.nanoTime() / 1000000f) - systemTime) >= 25 * getDelay()) { if (antiWeakness.getValue() && mc.player.isPotionActive(MobEffects.WEAKNESS)) { if (!isAttacking) { // save initial player hand @@ -596,4 +597,12 @@ public class CrystalAura extends Module { sendChatMessage(getChatName() + message); } } + + private double getDelay() { + if (!autoDelay.getValue()) { + return delay.getValue(); + } + int ping = InfoCalculator.ping(mc); + return 2 * ping * (InfoCalculator.tps(2) / 20) + (ping / 10.0); + } } diff --git a/src/main/java/me/zeroeightsix/kami/util/InfoCalculator.java b/src/main/java/me/zeroeightsix/kami/util/InfoCalculator.java index f9b8c30b9..e9e301ece 100644 --- a/src/main/java/me/zeroeightsix/kami/util/InfoCalculator.java +++ b/src/main/java/me/zeroeightsix/kami/util/InfoCalculator.java @@ -75,8 +75,8 @@ public class InfoCalculator { // } // Ticks Per Second { - public static String tps() { - return "" + Math.round(LagCompensator.INSTANCE.getTickRate()); + public static double tps(int places) { + return MathsUtils.round(LagCompensator.INSTANCE.getTickRate(), places); } // }