fishing plugin: don't render the same fishing spot twice
This commit is contained in:
@@ -430,7 +430,21 @@ public class FishingPlugin extends Plugin
|
||||
|
||||
private void inverseSortSpotDistanceFromPlayer()
|
||||
{
|
||||
if (fishingSpots.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY());
|
||||
fishingSpots.sort(Comparator.comparing(npc -> -1 * npc.getLocalLocation().distanceTo(cameraPoint)));
|
||||
fishingSpots.sort(
|
||||
Comparator.comparing(
|
||||
// Negate to have the furthest first
|
||||
(NPC npc) -> -npc.getLocalLocation().distanceTo(cameraPoint))
|
||||
// Order by position
|
||||
.thenComparing(NPC::getLocalLocation, Comparator.comparing(LocalPoint::getX)
|
||||
.thenComparing(LocalPoint::getY))
|
||||
// And then by id
|
||||
.thenComparing(NPC::getId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.runelite.api.NPC;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||
@@ -81,6 +82,8 @@ class FishingSpotOverlay extends Overlay
|
||||
return null;
|
||||
}
|
||||
|
||||
FishingSpot previousSpot = null;
|
||||
WorldPoint previousLocation = null;
|
||||
for (NPC npc : plugin.getFishingSpots())
|
||||
{
|
||||
FishingSpot spot = FishingSpot.getSPOTS().get(npc.getId());
|
||||
@@ -95,6 +98,12 @@ class FishingSpotOverlay extends Overlay
|
||||
continue;
|
||||
}
|
||||
|
||||
// This relies on the sort order to keep identical npcs on the same tile adjacent to each other
|
||||
if (previousSpot == spot && previousLocation.equals(npc.getWorldLocation()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Color color;
|
||||
if (npc.getGraphic() == GraphicID.FLYING_FISH)
|
||||
{
|
||||
@@ -175,6 +184,9 @@ class FishingSpotOverlay extends Overlay
|
||||
OverlayUtil.renderTextLocation(graphics, textLocation, text, color.darker());
|
||||
}
|
||||
}
|
||||
|
||||
previousSpot = spot;
|
||||
previousLocation = npc.getWorldLocation();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user