From e5b5292267b3240f7320c05f4c232e4d66b0142b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 22 Nov 2020 18:25:44 -0500 Subject: [PATCH] objectindicators: fix not marking objects when loaded on other planes fromLocalInstance() was returning a world point using the clients plane, however the object may not be on that, causing the plane check in checkObjectPoints() to fail. --- .../net/runelite/api/coords/WorldPoint.java | 20 ++++++++++++++++--- .../ObjectIndicatorsPlugin.java | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java b/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java index e2b57bdbc5..780c7c4494 100644 --- a/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java +++ b/runelite-api/src/main/java/net/runelite/api/coords/WorldPoint.java @@ -163,6 +163,20 @@ public class WorldPoint * @return the tile coordinate containing the local point */ public static WorldPoint fromLocalInstance(Client client, LocalPoint localPoint) + { + return fromLocalInstance(client, localPoint, client.getPlane()); + } + + /** + * Gets the coordinate of the tile that contains the passed local point, + * accounting for instances. + * + * @param client the client + * @param localPoint the local coordinate + * @param plane the plane for the returned point, if it is not an instance + * @return the tile coordinate containing the local point + */ + public static WorldPoint fromLocalInstance(Client client, LocalPoint localPoint, int plane) { if (client.isInInstancedRegion()) { @@ -181,18 +195,18 @@ public class WorldPoint int rotation = templateChunk >> 1 & 0x3; int templateChunkY = (templateChunk >> 3 & 0x7FF) * CHUNK_SIZE; int templateChunkX = (templateChunk >> 14 & 0x3FF) * CHUNK_SIZE; - int plane = templateChunk >> 24 & 0x3; + int templateChunkPlane = templateChunk >> 24 & 0x3; // calculate world point of the template int x = templateChunkX + (sceneX & (CHUNK_SIZE - 1)); int y = templateChunkY + (sceneY & (CHUNK_SIZE - 1)); // create and rotate point back to 0, to match with template - return rotate(new WorldPoint(x, y, plane), 4 - rotation); + return rotate(new WorldPoint(x, y, templateChunkPlane), 4 - rotation); } else { - return fromLocal(client, localPoint); + return fromLocal(client, localPoint.getX(), localPoint.getY(), plane); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java index 29a39edf98..46a4a0924d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java @@ -278,7 +278,7 @@ public class ObjectIndicatorsPlugin extends Plugin private void checkObjectPoints(TileObject object) { - final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, object.getLocalLocation()); + final WorldPoint worldPoint = WorldPoint.fromLocalInstance(client, object.getLocalLocation(), object.getPlane()); final Set objectPoints = points.get(worldPoint.getRegionID()); if (objectPoints == null)