Package com.kraken.api.service.ui
Class UIService
- java.lang.Object
-
- com.kraken.api.service.ui.UIService
-
@Singleton public class UIService extends java.lang.ObjectService for handling UI interactions and clickbox calculations. Provides methods to retrieve clickboxes for various game objects and calculate click points.
-
-
Constructor Summary
Constructors Constructor Description UIService()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.RectanglegetActorClickbox(net.runelite.api.Actor actor)Gets the clickbox for an Actor (NPC or Player).static net.runelite.api.PointgetClickbox(ContainerItem item)Gets the clickbox for an inventory item.static net.runelite.api.PointgetClickbox(ContainerItem item, boolean randomize)Gets the clickbox for an inventory item with optional randomizationstatic net.runelite.api.PointgetClickbox(net.runelite.api.Actor actor)Gets the clickbox for an Actor with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.Actor actor, boolean randomize)Gets the clickbox for an Actor with optional randomization.static net.runelite.api.PointgetClickbox(net.runelite.api.coords.LocalPoint localPoint)Gets the clickbox for a LocalPoint with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.coords.LocalPoint localPoint, boolean randomize)Gets the clickbox for a LocalPoint with optional randomization.static net.runelite.api.PointgetClickbox(net.runelite.api.coords.LocalPoint localPoint, int plane)Gets the clickbox for a LocalPoint at a specific plane with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.coords.LocalPoint localPoint, int plane, boolean randomize)Gets the clickbox for a LocalPoint at a specific plane with optional randomization.static net.runelite.api.PointgetClickbox(net.runelite.api.coords.WorldPoint worldPoint)Gets the clickbox for a WorldPoint with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.coords.WorldPoint worldPoint, boolean randomize)Gets the clickbox for a WorldPoint with optional randomization.static net.runelite.api.PointgetClickbox(net.runelite.api.Tile tile)Gets the clickbox for a Tile with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.TileObject object)Gets the clickbox for a TileObject with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.TileObject object, boolean randomize)Gets the clickbox for a TileObject with optional randomization.static net.runelite.api.PointgetClickbox(net.runelite.api.Tile tile, boolean randomize)Gets the clickbox for a Tile with optional randomization.static net.runelite.api.PointgetClickbox(net.runelite.api.widgets.Widget widget)Gets the clickbox for a Widget with randomization enabled by default.static net.runelite.api.PointgetClickbox(net.runelite.api.widgets.Widget widget, boolean randomize)Gets the clickbox for a Widget with optional randomization.static net.runelite.api.PointgetClickingPoint(java.awt.Rectangle rectangle, boolean randomize)Calculates a click point from a rectangle with optional randomization.static java.awt.RectanglegetDefaultRectangle()Returns a default rectangle representing the entire game canvas with a slight random offset.static java.awt.RectanglegetLocalPointClickbox(net.runelite.api.coords.LocalPoint localPoint)Gets the clickbox for a LocalPoint by converting it to screen coordinates.static java.awt.RectanglegetLocalPointClickbox(net.runelite.api.coords.LocalPoint localPoint, int plane)Gets the clickbox for a LocalPoint at a specific plane by converting it to screen coordinates.static java.awt.RectanglegetObjectClickbox(net.runelite.api.TileObject object)Gets the clickbox for a TileObject (GameObject, WallObject, GroundObject, or DecorativeObject).static java.awt.RectanglegetTileClickbox(net.runelite.api.Tile tile)Gets the clickbox for a Tile.static java.awt.RectanglegetWidgetClickbox(net.runelite.api.widgets.Widget widget)Gets the clickbox for a Widget.static java.awt.RectanglegetWorldPointClickbox(net.runelite.api.coords.WorldPoint worldPoint)Gets the clickbox for a WorldPoint by converting it to screen coordinates.static intpack(int groupId, int childId)Combines a group ID and a child ID into a single packed integer.static inttoChildId(int packedId)Converts a given integer ID to a child ID by masking higher-order bits.static inttoGroupId(int packedId)Converts the given packed widget integer ID to a group ID by performing a bitwise right shift.
-
-
-
Method Detail
-
toGroupId
public static int toGroupId(int packedId)
Converts the given packed widget integer ID to a group ID by performing a bitwise right shift.This method shifts the bits of the input ID 16 positions to the right, effectively dividing by 2^16 and discarding the lower 16 bits.
- Parameters:
packedId- the integer ID to be converted.- Returns:
- the resulting group ID after the bitwise shift.
-
toChildId
public static int toChildId(int packedId)
Converts a given integer ID to a child ID by masking higher-order bits.This method extracts the lower 16 bits of the provided integer.
- Parameters:
packedId- the input integer ID to be converted.- Returns:
- the child ID represented as the lower 16 bits of the input ID.
-
pack
public static int pack(int groupId, int childId)Combines a group ID and a child ID into a single packed integer.The group ID is shifted 16 bits to the left and combined with the child ID using a bitwise OR operation.
- Parameters:
groupId- the identifier for the groupchildId- the identifier for the child- Returns:
- the packed integer containing the group ID and child ID
-
getDefaultRectangle
public static java.awt.Rectangle getDefaultRectangle()
Returns a default rectangle representing the entire game canvas with a slight random offset.- Returns:
- Rectangle covering the canvas area
-
getActorClickbox
public static java.awt.Rectangle getActorClickbox(net.runelite.api.Actor actor)
Gets the clickbox for an Actor (NPC or Player).- Parameters:
actor- the actor to get the clickbox for- Returns:
- the actor's clickbox, or default rectangle if unavailable
-
getObjectClickbox
public static java.awt.Rectangle getObjectClickbox(net.runelite.api.TileObject object)
Gets the clickbox for a TileObject (GameObject, WallObject, GroundObject, or DecorativeObject).- Parameters:
object- the tile object to get the clickbox for- Returns:
- the object's clickbox, or default rectangle if unavailable
-
getTileClickbox
public static java.awt.Rectangle getTileClickbox(net.runelite.api.Tile tile)
Gets the clickbox for a Tile.- Parameters:
tile- the tile to get the clickbox for- Returns:
- the tile's clickbox, or default rectangle if unavailable
-
getWorldPointClickbox
public static java.awt.Rectangle getWorldPointClickbox(net.runelite.api.coords.WorldPoint worldPoint)
Gets the clickbox for a WorldPoint by converting it to screen coordinates. Creates a small rectangle around the point to allow for clicking.- Parameters:
worldPoint- the world point to get the clickbox for- Returns:
- a small clickbox around the world point's screen location, or default rectangle if unavailable
-
getLocalPointClickbox
public static java.awt.Rectangle getLocalPointClickbox(net.runelite.api.coords.LocalPoint localPoint)
Gets the clickbox for a LocalPoint by converting it to screen coordinates. Creates a small rectangle around the point to allow for clicking.- Parameters:
localPoint- the local point to get the clickbox for- Returns:
- a small clickbox around the local point's screen location, or default rectangle if unavailable
-
getLocalPointClickbox
public static java.awt.Rectangle getLocalPointClickbox(net.runelite.api.coords.LocalPoint localPoint, int plane)Gets the clickbox for a LocalPoint at a specific plane by converting it to screen coordinates. Creates a small rectangle around the point to allow for clicking.- Parameters:
localPoint- the local point to get the clickbox forplane- the plane/height level- Returns:
- a small clickbox around the local point's screen location, or default rectangle if unavailable
-
getWidgetClickbox
public static java.awt.Rectangle getWidgetClickbox(net.runelite.api.widgets.Widget widget)
Gets the clickbox for a Widget.- Parameters:
widget- the widget to get the clickbox for- Returns:
- the widget's bounds, or default rectangle if unavailable
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.Actor actor)
Gets the clickbox for an Actor with randomization enabled by default.- Parameters:
actor- the actor to get the clickbox for- Returns:
- a randomized point within the actor's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(ContainerItem item)
Gets the clickbox for an inventory item.- Parameters:
item- The inventory item- Returns:
- The canvas point for the inventory items clickbox (randomizes the point).
-
getClickbox
public static net.runelite.api.Point getClickbox(ContainerItem item, boolean randomize)
Gets the clickbox for an inventory item with optional randomization- Parameters:
item- The item to get the clickbox forrandomize- True if the point should be randomized. If false it will return the center point.- Returns:
- Center point or random point within the bounds of the inventory item.
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.Actor actor, boolean randomize)Gets the clickbox for an Actor with optional randomization.- Parameters:
actor- the actor to get the clickbox forrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the actor's clickbox (randomized or centered)
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.TileObject object)
Gets the clickbox for a TileObject with randomization enabled by default.- Parameters:
object- the tile object to get the clickbox for- Returns:
- a randomized point within the object's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.TileObject object, boolean randomize)Gets the clickbox for a TileObject with optional randomization.- Parameters:
object- the tile object to get the clickbox forrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the object's clickbox (randomized or centered)
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.Tile tile)
Gets the clickbox for a Tile with randomization enabled by default.- Parameters:
tile- the tile to get the clickbox for- Returns:
- a randomized point within the tile's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.Tile tile, boolean randomize)Gets the clickbox for a Tile with optional randomization.- Parameters:
tile- the tile to get the clickbox forrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the tile's clickbox (randomized or centered)
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.widgets.Widget widget)
Gets the clickbox for a Widget with randomization enabled by default.- Parameters:
widget- the widget to get the clickbox for- Returns:
- a randomized point within the widget's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.widgets.Widget widget, boolean randomize)Gets the clickbox for a Widget with optional randomization.- Parameters:
widget- the widget to get the clickbox forrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the widget's clickbox (randomized or centered)
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.coords.WorldPoint worldPoint)
Gets the clickbox for a WorldPoint with randomization enabled by default.- Parameters:
worldPoint- the world point to get the clickbox for- Returns:
- a randomized point within the world point's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.coords.WorldPoint worldPoint, boolean randomize)Gets the clickbox for a WorldPoint with optional randomization.- Parameters:
worldPoint- the world point to get the clickbox forrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the world point's clickbox (randomized or centered)
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.coords.LocalPoint localPoint)
Gets the clickbox for a LocalPoint with randomization enabled by default.- Parameters:
localPoint- the local point to get the clickbox for- Returns:
- a randomized point within the local point's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.coords.LocalPoint localPoint, boolean randomize)Gets the clickbox for a LocalPoint with optional randomization.- Parameters:
localPoint- the local point to get the clickbox forrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the local point's clickbox (randomized or centered)
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.coords.LocalPoint localPoint, int plane)Gets the clickbox for a LocalPoint at a specific plane with randomization enabled by default.- Parameters:
localPoint- the local point to get the clickbox forplane- the plane/height level- Returns:
- a randomized point within the local point's clickbox
-
getClickbox
public static net.runelite.api.Point getClickbox(net.runelite.api.coords.LocalPoint localPoint, int plane, boolean randomize)Gets the clickbox for a LocalPoint at a specific plane with optional randomization.- Parameters:
localPoint- the local point to get the clickbox forplane- the plane/height levelrandomize- whether to randomize the point within the clickbox- Returns:
- a point within the local point's clickbox (randomized or centered)
-
getClickingPoint
public static net.runelite.api.Point getClickingPoint(java.awt.Rectangle rectangle, boolean randomize)Calculates a click point from a rectangle with optional randomization. When randomized, uses RandomService.randomPointEx with a distribution factor of 0.78.- Parameters:
rectangle- the rectangle to calculate the point fromrandomize- whether to randomize the point within the rectangle- Returns:
- a point within the rectangle (randomized or centered)
-
-