Class WorldViewUtil
This class provides methods to convert coordinates between different world views, particularly useful when dealing with sailing mechanics where the player exists in a nested world view (on a boat) that needs to be projected back to the top-level world coordinates.
When a player is on a boat, their local coordinates are relative to the boat's world view. This utility helps translate those coordinates to the actual world map coordinates.
Example usage:
// Get the top-level world location of the local player
WorldPoint topWorldLocation = WorldViewUtil.getTopWorldLocation();
// Convert a specific world point to top-level coordinates
WorldPoint boatPoint = someEntity.getWorldLocation();
WorldPoint actualWorldPoint = WorldViewUtil.getTopWorldLocation(boatPoint);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.runelite.api.coords.WorldPointGets the top-level world location of the local player.static net.runelite.api.coords.WorldPointgetTopWorldLocation(net.runelite.api.coords.WorldPoint worldPoint) Converts a world point to its top-level world coordinates.
-
Constructor Details
-
WorldViewUtil
public WorldViewUtil()
-
-
Method Details
-
getTopWorldLocation
public static net.runelite.api.coords.WorldPoint getTopWorldLocation()Gets the top-level world location of the local player.This is a convenience method that retrieves the local player's current world location and converts it to top-level world coordinates.
- Returns:
- the top-level world location of the local player
- See Also:
-
getTopWorldLocation
public static net.runelite.api.coords.WorldPoint getTopWorldLocation(net.runelite.api.coords.WorldPoint worldPoint) Converts a world point to its top-level world coordinates.If the player is not on a boat (sailing), the original world point is returned unchanged. When on a boat, this method projects the coordinates from the boat's world view to the main world coordinates.
The conversion process:
- Check if on a boat; if not, return original point
- Find the world view containing the point
- Convert to local coordinates within that view
- Project through the main world projection
- Convert back to world coordinates in the top-level view
- Parameters:
worldPoint- the world point to convert, may benull- Returns:
- the corresponding top-level world point, or
nullif the input wasnull; returns the original point if not on a boat or if conversion fails at any step
-