Skip to content

Commit

Permalink
Update GoldorWaypointsManager
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Nov 24, 2024
1 parent 3a75b3d commit d276f87
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.waypoint.NamedWaypoint;
import de.hysky.skyblocker.utils.waypoint.Waypoint;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
Expand Down Expand Up @@ -110,20 +111,15 @@ private static boolean shouldProcessMsgs() {
* @param waypoints The list of waypoints to operate on
* @param playerName The name of the player to check against
*/
private static void removeNearestWaypoint(ObjectArrayList<GoldorWaypoint> waypoints, String playerName) {
private static void removeNearestWaypoint(List<GoldorWaypoint> waypoints, String playerName) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.world == null) return;

// Get the position of the player with the given name
Optional<Vec3d> posOptional = client.world.getPlayers().stream().filter(player -> player.getGameProfile().getName().equals(playerName)).findAny().map(Entity::getPos);

if (posOptional.isPresent()) {
Vec3d pos = posOptional.get();

waypoints.stream().filter(GoldorWaypoint::shouldRender).min(Comparator.comparingDouble(waypoint -> waypoint.centerPos.squaredDistanceTo(pos))).map(waypoint -> {
waypoint.setShouldRender(false);
return null;
});
}
// Find the nearest waypoint to the player and hide it
posOptional.flatMap(pos -> waypoints.stream().filter(GoldorWaypoint::shouldRender).min(Comparator.comparingDouble(waypoint -> waypoint.centerPos.squaredDistanceTo(pos)))).ifPresent(Waypoint::setFound);
}

/**
Expand All @@ -143,7 +139,7 @@ private static void reset() {
* @param waypoints The set of waypoints to enable rendering for
*/
private static void enableAll(ObjectArrayList<GoldorWaypoint> waypoints) {
waypoints.forEach(waypoint -> waypoint.setShouldRender(true));
waypoints.forEach(Waypoint::setMissing);
}

/**
Expand Down

0 comments on commit d276f87

Please sign in to comment.