From ae9d6aa3227dd9a35d87ebfbe99a949aae8bbfc2 Mon Sep 17 00:00:00 2001 From: appable Date: Sun, 30 Apr 2023 10:54:28 -0700 Subject: Metal detector solution speed improvements (#690) --- .../miscfeatures/CrystalMetalDetectorSolver.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java index 23115c36..76f56fac 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java @@ -148,14 +148,8 @@ public class CrystalMetalDetectorSolver { // Delay to keep old chest location from being treated as the new chest location if (chestRecentlyFound) { long currentTimeMillis = System.currentTimeMillis(); - if (chestLastFoundMillis == 0) { - chestLastFoundMillis = currentTimeMillis; - return; - } else if (currentTimeMillis - chestLastFoundMillis < 1000 && distToTreasure < 5.0) { - return; - } - - chestLastFoundMillis = 0; + if (currentTimeMillis - chestLastFoundMillis < 1000 && distToTreasure < 5.0) return; + chestLastFoundMillis = currentTimeMillis; chestRecentlyFound = false; } @@ -204,7 +198,8 @@ public class CrystalMetalDetectorSolver { } static void findPossibleSolutions(double distToTreasure, Vec3Comparable playerPos, boolean centerNewlyDiscovered) { - if (prevDistToTreasure == distToTreasure && prevPlayerPos.equals(playerPos) && + if (Math.abs(prevDistToTreasure - distToTreasure) < 0.2 && + prevPlayerPos.distanceTo(playerPos) <= 0.1 && !evaluatedPlayerPositions.containsKey(playerPos)) { evaluatedPlayerPositions.put(playerPos, distToTreasure); if (possibleBlocks.size() == 0) { -- cgit