package net.minecraft.client.waypoints; import com.mojang.datafixers.util.Either; import java.util.Comparator; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.world.entity.Entity; import net.minecraft.world.waypoints.TrackedWaypoint; import net.minecraft.world.waypoints.TrackedWaypointManager; @Environment(EnvType.CLIENT) public class ClientWaypointManager implements TrackedWaypointManager { private final Map, TrackedWaypoint> waypoints = new ConcurrentHashMap(); public void trackWaypoint(TrackedWaypoint waypoint) { this.waypoints.put(waypoint.id(), waypoint); } public void updateWaypoint(TrackedWaypoint waypoint) { ((TrackedWaypoint)this.waypoints.get(waypoint.id())).update(waypoint); } public void untrackWaypoint(TrackedWaypoint waypoint) { this.waypoints.remove(waypoint.id()); } public boolean hasWaypoints() { return !this.waypoints.isEmpty(); } public void forEachWaypoint(Entity entity, Consumer action) { this.waypoints .values() .stream() .sorted(Comparator.comparingDouble(trackedWaypoint -> trackedWaypoint.distanceSquared(entity)).reversed()) .forEachOrdered(action); } }