Merge remote-tracking branch 'runelite/master'

This commit is contained in:
Owain van Brakel
2021-09-21 04:41:13 +02:00
8 changed files with 114 additions and 68 deletions

View File

@@ -45,6 +45,14 @@ import net.runelite.api.Tile;
@Value
public class WorldPoint
{
private static final int[] REGION_MIRRORS = {
// Prifddinas
12894, 8755,
12895, 8756,
13150, 9011,
13151, 9012
};
/**
* X-axis coordinate.
*/
@@ -524,4 +532,29 @@ public class WorldPoint
}
return distance;
}
/**
* Translate a coordinate either between overworld and real, or real and overworld
*
* @param worldPoint
* @param toOverworld whether to convert to overworld coordinates, or to real coordinates
* @return
*/
public static WorldPoint getMirrorPoint(WorldPoint worldPoint, boolean toOverworld)
{
int region = worldPoint.getRegionID();
for (int i = 0; i < REGION_MIRRORS.length; i += 2)
{
int real = REGION_MIRRORS[i];
int overworld = REGION_MIRRORS[i + 1];
// Test against what we are converting from
if (region == (toOverworld ? real : overworld))
{
return fromRegion(toOverworld ? overworld : real,
worldPoint.getRegionX(), worldPoint.getRegionY(), worldPoint.getPlane());
}
}
return worldPoint;
}
}