Class WorldPoint


  • public final class WorldPoint
    extends Object
    A three-dimensional point representing the coordinate of a Tile.

    WorldPoints are immutable. Methods that modify the properties create a new instance.

    • 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​(Scene scene,
                                        int x,
                                        int y)
        Checks whether a tile is located in the current scene.
        Parameters:
        scene - the scene
        x - the tiles x coordinate
        y - the tiles y coordinate
        Returns:
        true if the tile is in the scene, false otherwise
      • 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​(Scene scene,
                                           int x,
                                           int y,
                                           int plane)
        Gets the coordinate of the tile that contains the passed local point.
        Parameters:
        scene - the scene
        x - the local x-axis coordinate
        y - the local x-axis coordinate
        plane - the plane
        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 the localpoint is on
        Returns:
        the tile coordinate containing the local point
      • fromLocalInstance

        public static WorldPoint fromLocalInstance​(Scene scene,
                                                   LocalPoint localPoint,
                                                   int plane)
        Gets the coordinate of the tile that contains the passed local point, accounting for instances.
        Parameters:
        scene - the scene
        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 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.
      • toLocalInstance

        public static Collection<WorldPoint> toLocalInstance​(Scene scene,
                                                             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.
      • 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
      • fromScene

        public static WorldPoint fromScene​(Scene scene,
                                           int x,
                                           int y,
                                           int plane)
      • 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()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object