From 11ade0921fb9d9aa279e303e29c1bef9aa6579d4 Mon Sep 17 00:00:00 2001 From: onixiya1337 <47077455+onixiya1337@users.noreply.github.com> Date: Tue, 9 Jul 2024 02:06:54 +0200 Subject: [PATCH] Improved failsafe tab --- gradle.properties | 2 +- .../farmhelperv2/config/FarmHelperConfig.java | 204 ++++++++---------- .../failsafe/impl/EvacuateFailsafe.java | 2 +- .../failsafe/impl/GuestVisitFailsafe.java | 4 +- .../failsafe/impl/KnockbackFailsafe.java | 2 +- .../failsafe/impl/LowerAvgBpsFailsafe.java | 55 +++-- .../failsafe/impl/RotationFailsafe.java | 6 +- .../failsafe/impl/TeleportFailsafe.java | 8 +- .../failsafe/impl/WorldChangeFailsafe.java | 2 +- .../farmhelperv2/feature/impl/BPSTracker.java | 15 +- 10 files changed, 147 insertions(+), 153 deletions(-) diff --git a/gradle.properties b/gradle.properties index 53880f81..bcdf90c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ mcVersion=1.8.9 modid=farmhelperv2 modName=FarmHelper version=2.8.2-pre3 -shouldRelease=true +shouldRelease=false diff --git a/src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java b/src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java index 07239ad8..7f61953f 100644 --- a/src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java +++ b/src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java @@ -394,103 +394,83 @@ public class FarmHelperConfig extends Config { // // - // - @Switch( - name = "Pop-up Notification", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Enable pop-up notification" - ) - public static boolean popUpNotification = true; - @Switch( - name = "Auto alt-tab when failsafe triggered", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Automatically alt-tabs to the game when the dark times come" - ) + + // General Settings + @Switch(name = "Pop-up Notifications", category = FAILSAFE, subcategory = "General", + description = "Enable on-screen failsafe notifications") + public static boolean popUpNotifications = true; + + @Switch(name = "Auto Alt-Tab", category = FAILSAFE, subcategory = "General", + description = "Switch to game window when failsafe triggers") public static boolean autoAltTab = false; - @Switch( - name = "Try to use jumping and flying in failsafes reactions", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Tries to use jumping and flying in failsafes reactions" - ) - public static boolean tryToUseJumpingAndFlying = true; - @Slider( - name = "Failsafe Stop Delay", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The delay to stop the macro after failsafe has been triggered (in milliseconds)", - min = 1_000, max = 7_500 - ) - public static int failsafeStopDelay = 2_000; - @Switch( - name = "Auto TP back on World Change", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Automatically warps back to the garden on server reboot, server update, etc" - ) - public static boolean autoTPOnWorldChange = true; - @Switch( - name = "Auto Evacuate on World update", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Automatically evacuates the island on server reboot, server update, etc" - ) - public static boolean autoEvacuateOnWorldUpdate = true; - @Switch( - name = "Auto reconnect on disconnect", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Automatically reconnects to the server when disconnected" - ) - public static boolean autoReconnect = true; - @Switch( - name = "Pause the macro when a guest arrives", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Pauses the macro when a guest arrives" - ) - public static boolean pauseWhenGuestArrives = false; - @Slider( - name = "Teleport Check Lag Sensitivity", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Variation in distance between expected and actual positions when lagging", - min = 0, max = 2 - ) - public static float teleportCheckLagSensitivity = 0.5f; - @Slider( - name = "Teleport/Rotation Check Time Window (in milliseconds)", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The time window to check for teleports (in seconds)", - min = 50, max = 4000, step = 50 - ) - public static int teleportRotationCheckTimeWindow = 500; - @Slider( - name = "Rotation Check Pitch Sensitivity", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The sensitivity of the rotation check; the lower the sensitivity, the more accurate the check is, but it will also increase the chance of getting false positives.", - min = 1, max = 30 - ) - public static float rotationCheckPitchSensitivity = 7; - @Slider( - name = "Rotation Check Yaw Sensitivity", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The sensitivity of the rotation check; the lower the sensitivity, the more accurate the check is, but it will also increase the chance of getting false positives.", - min = 1, max = 30 - ) - public static float rotationCheckYawSensitivity = 5; - @Slider( - name = "Teleport Check Sensitivity", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The minimum distance between the previous and teleported position to trigger failsafe", - min = 0.5f, max = 20f - ) - public static float teleportCheckSensitivity = 4; - @Slider( - name = "Knockback Check Vertical Sensitivity", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The minimum power of vertical knockback (motionY) to trigger failsafe", - min = 2000, max = 10000, step = 1000 - ) - public static float knockbackCheckVerticalSensitivity = 4000; - @Switch( - name = "Average BPS Drop check", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Checks for average BPS drop" - ) - public static boolean averageBPSDropCheck = true; + @Slider(name = "Failsafe Stop Delay", category = FAILSAFE, subcategory = "General", + description = "Delay before stopping macro after failsafe (ms)", + min = 1000, max = 7500) + public static int failsafeStopDelay = 2000; - @Slider( - name = "BPS drop threshold (seconds)", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Keeps track of the duration for which the BPS has been dropping", - min = 2, max = 10 - ) - public static int BPSDropThreshold = 5; + // Automatic Actions + @Switch(name = "Auto Warp on World Change", category = FAILSAFE, subcategory = "Auto Actions", + description = "Warp to garden after server reboot or update") + public static boolean autoWarpOnWorldChange = true; - @Button( - name = "Test failsafe", category = FAILSAFE, subcategory = "Miscellaneous", - description = "Tests failsafe", - text = "Test failsafe" - ) + @Switch(name = "Auto Evacuate on Server Reboot", category = FAILSAFE, subcategory = "Auto Actions", + description = "Leave island during server reboot or update") + public static boolean autoEvacuateOnServerReboot = true; + + @Switch(name = "Auto Reconnect", category = FAILSAFE, subcategory = "Auto Actions", + description = "Automatically reconnect after disconnect") + public static boolean autoReconnect = true; + + @Switch(name = "Pause on Guest Arrival", category = FAILSAFE, subcategory = "Auto Actions", + description = "Pause macro when a guest joins your island") + public static boolean pauseOnGuestArrival = false; + + // Detection Sensitivity + @Slider(name = "Teleport Lag Tolerance", category = FAILSAFE, subcategory = "Detection", + description = "Variation in distance between expected and actual positions when lagging", + min = 0, max = 2) + public static float teleportLagTolerance = 0.5f; + + @Slider(name = "Detection Time Window", category = FAILSAFE, subcategory = "Detection", + description = "Time frame for teleport/rotation checks (ms)", + min = 50, max = 4000, step = 50) + public static int detectionTimeWindow = 500; + + @Slider(name = "Pitch Sensitivity", category = FAILSAFE, subcategory = "Detection", + description = "Pitch change sensitivity (lower = stricter)", + min = 1, max = 30) + public static float pitchSensitivity = 7; + + @Slider(name = "Yaw Sensitivity", category = FAILSAFE, subcategory = "Detection", + description = "Yaw change sensitivity (lower = stricter)", + min = 1, max = 30) + public static float yawSensitivity = 5; + + @Slider(name = "Teleport Distance Threshold", category = FAILSAFE, subcategory = "Detection", + description = "Minimum teleport distance to trigger failsafe (blocks)", + min = 0.5f, max = 20f) + public static float teleportDistanceThreshold = 4; + + @Slider(name = "Vertical Knockback Threshold", category = FAILSAFE, subcategory = "Detection", + description = "Minimum vertical knockback to trigger failsafe", + min = 2000, max = 10000, step = 1000) + public static float verticalKnockbackThreshold = 4000; + + // BPS Check + @Switch(name = "Enable BPS Check", category = FAILSAFE, subcategory = "BPS", + description = "Monitor for drops in blocks per second") + public static boolean enableBpsCheck = true; + + @Slider(name = "Minimum BPS", category = FAILSAFE, subcategory = "BPS", + description = "Trigger failsafe if BPS falls below this value", + min = 5, max = 15) + public static float minBpsThreshold = 10f; + + // Failsafe Testing + @Button(name = "Test Failsafe", category = FAILSAFE, subcategory = "Testing", + description = "Simulate a failsafe trigger", + text = "Run Test") Runnable _testFailsafe = () -> { if (!MacroHandler.getInstance().isMacroToggled()) { LogUtils.sendError("You need to start the macro first!"); @@ -498,34 +478,30 @@ public class FarmHelperConfig extends Config { } LogUtils.sendWarning("Testing failsafe..."); PlayerUtils.closeScreen(); - if (testFailsafeTypeSelected == 0) { - FailsafeManager.getInstance().possibleDetection(FailsafeManager.getInstance().failsafes.get(testFailsafeTypeSelected)); + if (testFailsafeType == 0) { + FailsafeManager.getInstance().possibleDetection(FailsafeManager.getInstance().failsafes.get(testFailsafeType)); return; - } // else if (testFailsafeTypeSelected != 6) - // LowerAvgBpsFailsafe.getInstance().clearQueue(); // Clear the queue to avoid false positives - FailsafeManager.getInstance().possibleDetection(FailsafeManager.getInstance().failsafes.get(testFailsafeTypeSelected + 2)); + } + FailsafeManager.getInstance().possibleDetection(FailsafeManager.getInstance().failsafes.get(testFailsafeType + 2)); }; - @Dropdown( - name = "Test Failsafe Type", category = FAILSAFE, subcategory = "Miscellaneous", - description = "The failsafe type to test", + @Dropdown(name = "Test Failsafe Type", category = FAILSAFE, subcategory = "Testing", + description = "Select failsafe scenario to test", options = { "Banwave", -// "Bedrock Cage Check", -// "Dirt Check", "Disconnect", "Evacuate", + "Full Inventory", "Guest Visit", - "Item Change Check", + "Item Change", "Jacob", - "Knockback Check", - "Lower Average Bps", - "Rotation Check", - "Teleport Check", - "World Change Check" - } - ) - public static int testFailsafeTypeSelected = 0; + "Knockback", + "Low BPS", + "Rotation", + "Teleport", + "World Change" + }) + public static int testFailsafeType = 0; // @@ -562,7 +538,7 @@ public class FarmHelperConfig extends Config { public static int captureClipDelay = 30; @Info( - text = "You need to use ShadowPlay (or any alternative with Replay Buffer) and configure it to capture clips!", + text = "You need to use either ShadowPlay, OBS, Medal.tv or any alternative with Replay Buffer, then configure it to capture clips!", type = InfoType.WARNING, category = FAILSAFE, subcategory = "Clip Capturing", @@ -2188,7 +2164,7 @@ public FarmHelperConfig() { this.addDependency("pestRepellentType", "autoPestRepellent"); - this.addDependency("averageBPSDrop", "averageBPSDropCheck"); + this.addDependency("averageBPSDrop", "enableBpsCheck"); this.addDependency("captureClipKeybind", "", () -> captureClipAfterFailsafe || captureClipAfterGettingBanned); this.addDependency("clipCapturingType", "", () -> captureClipAfterFailsafe || captureClipAfterGettingBanned); diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/EvacuateFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/EvacuateFailsafe.java index af1ed2c0..6aad1993 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/EvacuateFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/EvacuateFailsafe.java @@ -54,7 +54,7 @@ public boolean shouldAltTab() { @Override public void onTickDetection(TickEvent.ClientTickEvent event) { if (!MacroHandler.getInstance().isMacroToggled()) return; - if (!FarmHelperConfig.autoEvacuateOnWorldUpdate) return; + if (!FarmHelperConfig.autoEvacuateOnServerReboot) return; if (evacuateState != EvacuateState.NONE) return; GameStateHandler.getInstance().getServerClosingSeconds().ifPresent(seconds -> { diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/GuestVisitFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/GuestVisitFailsafe.java index 481f0626..f587795d 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/GuestVisitFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/GuestVisitFailsafe.java @@ -57,7 +57,7 @@ public boolean shouldAltTab() { @Override public void onTickDetection(TickEvent.ClientTickEvent event) { tabListCheckDelay.schedule(5000L); - if (FarmHelperConfig.pauseWhenGuestArrives && wasGuestOnGarden && GameStateHandler.getInstance().isGuestOnGarden()) { + if (FarmHelperConfig.pauseOnGuestArrival && wasGuestOnGarden && GameStateHandler.getInstance().isGuestOnGarden()) { if (!MacroHandler.getInstance().isCurrentMacroPaused()) { LogUtils.sendFailsafeMessage("[Failsafe] Paused the macro because of guest visit!", false); MacroHandler.getInstance().pauseMacro(); @@ -101,7 +101,7 @@ public void onChatDetection(ClientChatReceivedEvent event) { wasGuestOnGarden = true; tabListCheckDelay.schedule(5000L); FailsafeManager.getInstance().possibleDetection(this); - if (!FarmHelperConfig.pauseWhenGuestArrives) + if (!FarmHelperConfig.pauseOnGuestArrival) Multithreading.schedule(() -> { if (FailsafeManager.getInstance().triggeredFailsafe.isPresent() && FailsafeManager.getInstance().triggeredFailsafe.get().getType() == FailsafeManager.EmergencyType.GUEST_VISIT) { diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/KnockbackFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/KnockbackFailsafe.java index f85d17a1..19f0d2cf 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/KnockbackFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/KnockbackFailsafe.java @@ -73,7 +73,7 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) { } if (((S12PacketEntityVelocity) event.packet).getEntityID() != mc.thePlayer.getEntityId()) return; - if (((S12PacketEntityVelocity) event.packet).getMotionY() < FarmHelperConfig.knockbackCheckVerticalSensitivity) + if (((S12PacketEntityVelocity) event.packet).getMotionY() < FarmHelperConfig.verticalKnockbackThreshold) return; if (FlyPathFinderExecutor.getInstance().isRunning()) { diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/LowerAvgBpsFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/LowerAvgBpsFailsafe.java index a7ed9f96..5bfa24bb 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/LowerAvgBpsFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/LowerAvgBpsFailsafe.java @@ -19,6 +19,9 @@ public class LowerAvgBpsFailsafe extends Failsafe { private static LowerAvgBpsFailsafe instance; private float lastBPS; + private long lastStableBpsTime = 0; + private static final float BPS_DROP_TOLERANCE = 1f; + private static final long STABLE_BPS_RESET_TIME = 5000L; private final Clock clock = new Clock(); @@ -63,29 +66,50 @@ public boolean shouldAltTab() { public void onTickDetection(TickEvent.ClientTickEvent event) { if (FeatureManager.getInstance().shouldPauseMacroExecution() || BPSTracker.getInstance().dontCheckForBPS() - || !FarmHelperConfig.averageBPSDropCheck) { - if (clock.isScheduled()) - clock.reset(); + || !FarmHelperConfig.enableBpsCheck) { + resetStates(); return; } if (event.phase != TickEvent.Phase.START) return; - if (BPSTracker.getInstance().getBPSFloat() - lastBPS < 0) { - if (!clock.isScheduled()) - clock.schedule(FarmHelperConfig.BPSDropThreshold * 1000L); - } else if (BPSTracker.getInstance().getBPSFloat() - lastBPS > 0) { - clock.reset(); + float currentBPS = BPSTracker.getInstance().getBPSFloat(); + float bpsDrop = lastBPS - currentBPS; + + boolean shouldTrigger = false; + + // Check for BPS below threshold + if (currentBPS < FarmHelperConfig.minBpsThreshold) { + shouldTrigger = true; + LogUtils.sendDebug("BPS below threshold. Current: " + currentBPS + ", Threshold: " + FarmHelperConfig.minBpsThreshold); } - lastBPS = BPSTracker.getInstance().getBPSFloat(); - if (!clock.isScheduled()) - return; + // Check for significant BPS drop + if (bpsDrop > BPS_DROP_TOLERANCE) { + shouldTrigger = true; + lastStableBpsTime = System.currentTimeMillis(); + LogUtils.sendDebug("BPS drop detected. Current: " + currentBPS + ", Last: " + lastBPS); + } else if (bpsDrop < -BPS_DROP_TOLERANCE) { + resetStates(); + LogUtils.sendDebug("BPS increased. Clock reset."); + } else { + // BPS is stable + if (System.currentTimeMillis() - lastStableBpsTime > STABLE_BPS_RESET_TIME) { + resetStates(); + LogUtils.sendDebug("BPS stable for " + STABLE_BPS_RESET_TIME + "ms. Clock reset."); + } + } - if (clock.passed()) { - FailsafeManager.getInstance().possibleDetection(this); + if (shouldTrigger && !clock.isScheduled()) { + clock.schedule(5000L); } + lastBPS = currentBPS; + + if (clock.isScheduled() && clock.passed()) { + LogUtils.sendDebug("Failsafe triggered. Current BPS: " + currentBPS); + FailsafeManager.getInstance().possibleDetection(this); + } } @Override @@ -139,9 +163,10 @@ public void endOfFailsafeTrigger() { @Override public void resetStates() { - LogUtils.sendDebug("RESET"); + LogUtils.sendDebug("Resetting LowerAvgBpsFailsafe states"); clock.reset(); - lastBPS = 0; + lastBPS = BPSTracker.getInstance().getBPSFloat(); + lastStableBpsTime = System.currentTimeMillis(); lowerBPSState = LowerBPSState.NONE; } diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/RotationFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/RotationFailsafe.java index 865e7987..aeb0f647 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/RotationFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/RotationFailsafe.java @@ -109,7 +109,7 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) { if (shouldTriggerCheck(packetYaw, packetPitch)) if (rotationBeforeReacting == null) rotationBeforeReacting = new Rotation((float) playerYaw, (float) playerPitch); - triggerCheck.schedule(FarmHelperConfig.teleportRotationCheckTimeWindow); + triggerCheck.schedule(FarmHelperConfig.detectionTimeWindow); } private static final Clock triggerCheck = new Clock(); @@ -146,8 +146,8 @@ private void evaluateRotation() { private boolean shouldTriggerCheck(double newYaw, double newPitch) { double yawDiff = Math.abs(newYaw - mc.thePlayer.rotationYaw) % 360; double pitchDiff = Math.abs(newPitch - mc.thePlayer.rotationPitch) % 360; - double yawThreshold = FarmHelperConfig.rotationCheckYawSensitivity; - double pitchThreshold = FarmHelperConfig.rotationCheckPitchSensitivity; + double yawThreshold = FarmHelperConfig.pitchSensitivity; + double pitchThreshold = FarmHelperConfig.pitchSensitivity; if (yawDiff >= yawThreshold || pitchDiff >= pitchThreshold) { LogUtils.sendDebug("[Failsafe] Rotation detected! Yaw diff: " + yawDiff + ", Pitch diff: " + pitchDiff); return true; diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/TeleportFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/TeleportFailsafe.java index 53947ca2..2942e2e1 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/TeleportFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/TeleportFailsafe.java @@ -160,19 +160,19 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) { double distance = currentPlayerPos.distanceTo(packetPlayerPos); LogUtils.sendDebug("[Failsafe] Teleport packet received! Distance: " + distance); - if (distance >= FarmHelperConfig.teleportCheckSensitivity || (MacroHandler.getInstance().getCurrentMacro().isPresent() && Math.abs(packet.getY()) - Math.abs(MacroHandler.getInstance().getCurrentMacro().get().getLayerY()) > 0.8)) { + if (distance >= FarmHelperConfig.teleportDistanceThreshold || (MacroHandler.getInstance().getCurrentMacro().isPresent() && Math.abs(packet.getY()) - Math.abs(MacroHandler.getInstance().getCurrentMacro().get().getLayerY()) > 0.8)) { LogUtils.sendDebug("[Failsafe] Teleport detected! Distance: " + distance); final double lastReceivedPacketDistance = currentPlayerPos.distanceTo(LagDetector.getInstance().getLastPacketPosition()); // blocks per tick final double playerMovementSpeed = mc.thePlayer.getAttributeMap().getAttributeInstanceByName("generic.movementSpeed").getAttributeValue(); final int ticksSinceLastPacket = (int) Math.ceil(LagDetector.getInstance().getTimeSinceLastTick() / 50D); final double estimatedMovement = playerMovementSpeed * ticksSinceLastPacket; - if (lastReceivedPacketDistance > 7.5D && Math.abs(lastReceivedPacketDistance - estimatedMovement) < FarmHelperConfig.teleportCheckLagSensitivity) + if (lastReceivedPacketDistance > 7.5D && Math.abs(lastReceivedPacketDistance - estimatedMovement) < FarmHelperConfig.teleportLagTolerance) return; if (originalPosition == null) { originalPosition = mc.thePlayer.getPositionVector(); } - triggerCheck.schedule(FarmHelperConfig.teleportRotationCheckTimeWindow); + triggerCheck.schedule(FarmHelperConfig.detectionTimeWindow); } } @@ -206,7 +206,7 @@ private void evaluateDisplacement() { return; } double totalDisplacement = currentPosition.distanceTo(originalPosition); - if (totalDisplacement > FarmHelperConfig.teleportCheckSensitivity) { + if (totalDisplacement > FarmHelperConfig.teleportDistanceThreshold) { FailsafeManager.getInstance().possibleDetection(this); } else { FailsafeManager.getInstance().emergencyQueue.remove(this); diff --git a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/WorldChangeFailsafe.java b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/WorldChangeFailsafe.java index 7b2d944a..2e5f0384 100644 --- a/src/main/java/com/jelly/farmhelperv2/failsafe/impl/WorldChangeFailsafe.java +++ b/src/main/java/com/jelly/farmhelperv2/failsafe/impl/WorldChangeFailsafe.java @@ -109,7 +109,7 @@ public void chatTwo(ClientChatReceivedEvent event) { @Override public void duringFailsafeTrigger() { - if (!FarmHelperConfig.autoTPOnWorldChange) { + if (!FarmHelperConfig.autoWarpOnWorldChange) { LogUtils.sendDebug("[Failsafe] Auto TP on world change is disabled! Disabling macro and disconnecting..."); MacroHandler.getInstance().disableMacro(); Multithreading.schedule(() -> { diff --git a/src/main/java/com/jelly/farmhelperv2/feature/impl/BPSTracker.java b/src/main/java/com/jelly/farmhelperv2/feature/impl/BPSTracker.java index ae5649eb..65f61db0 100644 --- a/src/main/java/com/jelly/farmhelperv2/feature/impl/BPSTracker.java +++ b/src/main/java/com/jelly/farmhelperv2/feature/impl/BPSTracker.java @@ -9,7 +9,6 @@ import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockNetherWart; import net.minecraft.block.BlockReed; -import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; import net.minecraft.util.Tuple; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -64,15 +63,9 @@ private void adjustQueueTimestamps(long pauseDuration) { @Override public void resume() { if (isPaused && !isResumingScheduled) { - resumeScheduled(); - LogUtils.sendDebug("Scheduled resuming BPS tracker"); - } - } - - public void resumeScheduled() { - if (!isResumingScheduled) { isResumingScheduled = true; Multithreading.schedule(() -> { + isResumingScheduled = false; if (dontCheckForBPS()) { LogUtils.sendDebug("Canceled resuming BPS tracker"); return; @@ -82,8 +75,8 @@ public void resumeScheduled() { adjustQueueTimestamps(pauseDuration); isPaused = false; pauseStartTime = 0; - isResumingScheduled = false; }, 1000L, TimeUnit.MILLISECONDS); + LogUtils.sendDebug("Scheduled resuming BPS tracker"); } } @@ -100,9 +93,9 @@ public void onTickCheckBPS(TickEvent.ClientTickEvent event) { if (!MacroHandler.getInstance().isCurrentMacroEnabled()) return; if (event.phase != TickEvent.Phase.START) return; if (MacroHandler.getInstance().getMacro().checkForBPS()) - BPSTracker.getInstance().resume(); + resume(); else - BPSTracker.getInstance().pause(); + pause(); if (isPaused) return; long currentTime = System.currentTimeMillis();