Class WorldViewUtil

java.lang.Object
net.storm.api.commons.WorldViewUtil

public class WorldViewUtil extends Object
Utility class for handling world view coordinate transformations.

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:
  • WorldView
  • WorldPoint
  • Projection
  • 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:

      1. Check if on a boat; if not, return original point
      2. Find the world view containing the point
      3. Convert to local coordinates within that view
      4. Project through the main world projection
      5. Convert back to world coordinates in the top-level view
      Parameters:
      worldPoint - the world point to convert, may be null
      Returns:
      the corresponding top-level world point, or null if the input was null; returns the original point if not on a boat or if conversion fails at any step