Class 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 coordinate
      static WorldPoint fromScene​(Client client, int x, int y, int plane)
      Converts the passed scene coordinates to a world space
      static WorldPoint getMirrorPoint​(WorldPoint worldPoint, boolean toOverworld)
      Translate a coordinate either between overworld and real, or real and overworld
      int 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 coordinate
      int getRegionY()
      Gets the Y-axis coordinate of the region coordinate
      int 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()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WorldPoint

        public WorldPoint​(int x,
                          int y,
                          int plane)
    • 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 client
        x - the tiles x coordinate
        y - 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 client
        local - 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 client
        x - the local x-axis coordinate
        y - the local x-axis coordinate
        plane - 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 client
        localPoint - 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 client
        localPoint - the local coordinate
        plane - 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 the distanceTo2D(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.
      • 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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object