diff --git a/src/api/java/baritone/api/pathing/goals/GoalNear.java b/src/api/java/baritone/api/pathing/goals/GoalNear.java index 7f87e8b9..1897d774 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalNear.java +++ b/src/api/java/baritone/api/pathing/goals/GoalNear.java @@ -19,11 +19,10 @@ package baritone.api.pathing.goals; import baritone.api.utils.SettingsUtil; import baritone.api.utils.interfaces.IGoalRenderPos; +import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet; +import it.unimi.dsi.fastutil.doubles.DoubleIterator; import net.minecraft.util.math.BlockPos; -import java.util.Collections; -import java.util.HashSet; - public class GoalNear implements Goal, IGoalRenderPos { private final int x; @@ -57,7 +56,7 @@ public class GoalNear implements Goal, IGoalRenderPos { @Override public double heuristic() {// TODO less hacky solution int range = (int) Math.ceil(Math.sqrt(rangeSq)); - HashSet maybeAlwaysInside = new HashSet<>(); + DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); double minOutside = Double.POSITIVE_INFINITY; for (int dx = -range; dx <= range; dx++) { for (int dy = -range; dy <= range; dy++) { @@ -72,7 +71,9 @@ public class GoalNear implements Goal, IGoalRenderPos { } } double maxInside = Double.NEGATIVE_INFINITY; - for (double inside : maybeAlwaysInside) { + DoubleIterator it = maybeAlwaysInside.iterator(); + while(it.hasNext()) { + double inside = it.nextDouble(); if (inside < minOutside) { maxInside = Math.max(maxInside, inside); } diff --git a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java index b9c41aea..b85cb23e 100644 --- a/src/api/java/baritone/api/pathing/goals/GoalRunAway.java +++ b/src/api/java/baritone/api/pathing/goals/GoalRunAway.java @@ -18,11 +18,11 @@ package baritone.api.pathing.goals; import baritone.api.utils.SettingsUtil; +import it.unimi.dsi.fastutil.doubles.DoubleOpenHashSet; +import it.unimi.dsi.fastutil.doubles.DoubleIterator; import net.minecraft.util.math.BlockPos; import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; /** * Useful for automated combat (retreating specifically) @@ -99,7 +99,7 @@ public class GoalRunAway implements Goal { maxY = Math.max(minY, p.getY() + distance); maxZ = Math.max(minZ, p.getZ() + distance); } - HashSet maybeAlwaysInside = new HashSet<>(); + DoubleOpenHashSet maybeAlwaysInside = new DoubleOpenHashSet(); double minOutside = Double.POSITIVE_INFINITY; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { @@ -114,7 +114,9 @@ public class GoalRunAway implements Goal { } } double maxInside = Double.NEGATIVE_INFINITY; - for (double inside : maybeAlwaysInside) { + DoubleIterator it = maybeAlwaysInside.iterator(); + while(it.hasNext()) { + double inside = it.nextDouble(); if (inside < minOutside) { maxInside = Math.max(maxInside, inside); }