Package net.runelite.api.coords
Class WorldPoint
- java.lang.Object
-
- net.runelite.api.coords.WorldPoint
-
public final class WorldPoint extends java.lang.Object
A three-dimensional point representing the coordinate of a Tile.WorldPoints are immutable. Methods that modify the properties create a new instance.
-
-
Constructor Summary
Constructors Constructor Description WorldPoint(int x, int y, int plane)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
distanceTo(WorldArea other)
Gets the shortest distance from this point to a WorldArea.int
distanceTo(WorldPoint other)
Gets the distance between this point and another.int
distanceTo2D(WorldPoint other)
Find the distance from this point to another point.WorldPoint
dx(int dx)
Offsets the x-axis coordinate by the passed value.WorldPoint
dy(int dy)
Offsets the y-axis coordinate by the passed value.WorldPoint
dz(int dz)
Offsets the plane by the passed value.boolean
equals(java.lang.Object o)
static WorldPoint
fromLocal(Client client, int x, int y, int plane)
Gets the coordinate of the tile that contains the passed local point.static WorldPoint
fromLocal(Client client, LocalPoint local)
Gets the coordinate of the tile that contains the passed local point.static WorldPoint
fromLocalInstance(Client client, LocalPoint localPoint)
Gets the coordinate of the tile that contains the passed local point, accounting for instances.static WorldPoint
fromLocalInstance(Client client, LocalPoint localPoint, int plane)
Gets the coordinate of the tile that contains the passed local point, accounting for instances.static WorldPoint
fromRegion(int regionId, int regionX, int regionY, int plane)
Converts the passed region ID and coordinates to a world coordinatestatic WorldPoint
fromScene(Client client, int x, int y, int plane)
Converts the passed scene coordinates to a world spacestatic WorldPoint
getMirrorPoint(WorldPoint worldPoint, boolean toOverworld)
Translate a coordinate either between overworld and real, or real and overworldint
getPlane()
The plane level of the Tile, also referred as z-axis coordinate.int
getRegionID()
Gets the ID of the region containing this tile.int
getRegionX()
Gets the X-axis coordinate of the region coordinateint
getRegionY()
Gets the Y-axis coordinate of the region coordinateint
getX()
X-axis coordinate.int
getY()
Y-axis coordinate.int
hashCode()
boolean
isInArea(WorldArea... worldAreas)
Checks whether this tile is located within any of the given areas.boolean
isInArea2D(WorldArea... worldAreas)
Checks whether this tile is located within any of the given areas, disregarding any plane differences.boolean
isInScene(Client client)
Checks whether this tile is located in the current scene.static boolean
isInScene(Client client, int x, int y)
Checks whether a tile is located in the current scene.static java.util.Collection<WorldPoint>
toLocalInstance(Client client, WorldPoint worldPoint)
Get occurrences of a tile on the scene, accounting for instances.java.lang.String
toString()
WorldArea
toWorldArea()
Retrieves an area consisting of only this point.
-
-
-
Method Detail
-
dx
public WorldPoint dx(int dx)
Offsets the x-axis coordinate by the passed value.- Parameters:
dx
- the offset- Returns:
- new instance
-
dy
public WorldPoint dy(int dy)
Offsets the y-axis coordinate by the passed value.- Parameters:
dy
- the offset- Returns:
- new instance
-
dz
public WorldPoint dz(int dz)
Offsets the plane by the passed value.- Parameters:
dz
- the offset- Returns:
- new instance
-
isInScene
public static boolean isInScene(Client client, int x, int y)
Checks whether a tile is located in the current scene.- Parameters:
client
- the clientx
- the tiles x coordinatey
- the tiles y coordinate- Returns:
- true if the tile is in the scene, false otherwise
-
isInScene
public boolean isInScene(Client client)
Checks whether this tile is located in the current scene.- Parameters:
client
- the client- Returns:
- true if this tile is in the scene, false otherwise
-
fromLocal
public static WorldPoint fromLocal(Client client, LocalPoint local)
Gets the coordinate of the tile that contains the passed local point.- Parameters:
client
- the clientlocal
- the local coordinate- Returns:
- the tile coordinate containing the local point
-
fromLocal
public static WorldPoint fromLocal(Client client, int x, int y, int plane)
Gets the coordinate of the tile that contains the passed local point.- Parameters:
client
- the clientx
- the local x-axis coordinatey
- the local x-axis coordinateplane
- the plane- Returns:
- the tile coordinate containing the local point
-
fromLocalInstance
public static WorldPoint fromLocalInstance(Client client, LocalPoint localPoint)
Gets the coordinate of the tile that contains the passed local point, accounting for instances.- Parameters:
client
- the clientlocalPoint
- the local coordinate- Returns:
- the tile coordinate containing the local point
-
fromLocalInstance
public static WorldPoint fromLocalInstance(Client client, LocalPoint localPoint, int plane)
Gets the coordinate of the tile that contains the passed local point, accounting for instances.- Parameters:
client
- the clientlocalPoint
- the local coordinateplane
- the plane for the returned point, if it is not an instance- Returns:
- the tile coordinate containing the local point
-
toLocalInstance
public static java.util.Collection<WorldPoint> toLocalInstance(Client client, WorldPoint worldPoint)
Get occurrences of a tile on the scene, accounting for instances. There may be more than one if the same template chunk occurs more than once on the scene.- Parameters:
client
-worldPoint
-- Returns:
-
distanceTo
public int distanceTo(WorldArea other)
Gets the shortest distance from this point to a WorldArea.- Parameters:
other
- the world area- Returns:
- the shortest distance
-
distanceTo
public int distanceTo(WorldPoint other)
Gets the distance between this point and another.If the other point is not on the same plane, this method will return
Integer.MAX_VALUE
. If ignoring the plane is wanted, use thedistanceTo2D(WorldPoint)
method.- Parameters:
other
- other point- Returns:
- the distance
-
distanceTo2D
public int distanceTo2D(WorldPoint other)
Find the distance from this point to another point.This method disregards the plane value of the two tiles and returns the simple distance between the X-Z coordinate pairs.
- Parameters:
other
- other point- Returns:
- the distance
-
fromScene
public static WorldPoint fromScene(Client client, int x, int y, int plane)
Converts the passed scene coordinates to a world space
-
getRegionID
public int getRegionID()
Gets the ID of the region containing this tile.- Returns:
- the region ID
-
fromRegion
public static WorldPoint fromRegion(int regionId, int regionX, int regionY, int plane)
Converts the passed region ID and coordinates to a world coordinate
-
getRegionX
public int getRegionX()
Gets the X-axis coordinate of the region coordinate
-
getRegionY
public int getRegionY()
Gets the Y-axis coordinate of the region coordinate
-
getMirrorPoint
public static WorldPoint getMirrorPoint(WorldPoint worldPoint, boolean toOverworld)
Translate a coordinate either between overworld and real, or real and overworld- Parameters:
worldPoint
-toOverworld
- whether to convert to overworld coordinates, or to real coordinates- Returns:
-
isInArea
public boolean isInArea(WorldArea... worldAreas)
Checks whether this tile is located within any of the given areas.- Parameters:
worldAreas
- areas to check within- Returns:
true
if any area contains this point,false
otherwise.
-
isInArea2D
public boolean isInArea2D(WorldArea... worldAreas)
Checks whether this tile is located within any of the given areas, disregarding any plane differences.- Parameters:
worldAreas
- areas to check within- Returns:
true
if any area contains this point,false
otherwise.
-
toWorldArea
public WorldArea toWorldArea()
Retrieves an area consisting of only this point.- Returns:
- A
WorldArea
of width and height 1, encompassing only this point.
-
getX
public int getX()
X-axis coordinate.
-
getY
public int getY()
Y-axis coordinate.
-
getPlane
public int getPlane()
The plane level of the Tile, also referred as z-axis coordinate.- See Also:
Client.getPlane()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-