Class GameObjectPackets


  • public class GameObjectPackets
    extends java.lang.Object
    A high-level utility class for sending packets related to TileObject (Game Object) interactions to the game server.

    This class handles actions like clicking on doors, trees, or banks, as well as "use-on" actions (e.g., using an item on an object). It abstracts the low-level packet construction and world coordinate calculations.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void queueObjectAction​(int actionFieldNo, int objectId, int worldPointX, int worldPointY, boolean ctrlDown)
      Queues the low-level packet to perform a generic action click on a tile object.
      void queueObjectAction​(net.runelite.api.TileObject object, boolean ctrlDown, java.lang.String... actionlist)
      Queues a tile object action by matching a human-readable action string (e.g., "Chop", "Open", "Bank").
      void queueWidgetOnTileObject​(int objectId, int worldPointX, int worldPointY, int sourceSlot, int sourceItemId, int sourceWidgetId, boolean ctrlDown)
      Queues the raw packet for using a widget (typically an item) on a tile object.
      void queueWidgetOnTileObject​(net.runelite.api.widgets.Widget widget, net.runelite.api.TileObject object)
      Queues the packet for using a specific Widget (or item it represents) on a target TileObject.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GameObjectPackets

        public GameObjectPackets()
    • Method Detail

      • queueObjectAction

        public void queueObjectAction​(int actionFieldNo,
                                      int objectId,
                                      int worldPointX,
                                      int worldPointY,
                                      boolean ctrlDown)
        Queues the low-level packet to perform a generic action click on a tile object.

        This method sends one of the OPLOC packets (e.g., OPLOC1 through OPLOC10), where the action is determined by the actionFieldNo.

        Parameters:
        actionFieldNo - The 1-based index of the action to execute (1-10).
        objectId - The ID of the target object.
        worldPointX - The X coordinate of the object's location in the world.
        worldPointY - The Y coordinate of the object's location in the world.
        ctrlDown - If true, indicates the control key was held down.
      • queueObjectAction

        public void queueObjectAction​(net.runelite.api.TileObject object,
                                      boolean ctrlDown,
                                      java.lang.String... actionlist)
        Queues a tile object action by matching a human-readable action string (e.g., "Chop", "Open", "Bank").

        This is a high-level convenience method that determines the target object's world coordinates, checks the object's available actions, finds a match for actionlist, and sends the correct low-level OPLOC packet.

        Parameters:
        object - The target TileObject (e.g., GameObject, WallObject).
        ctrlDown - If true, indicates the control key was held down.
        actionlist - A varargs list of action strings to search for (case-insensitive).
      • queueWidgetOnTileObject

        public void queueWidgetOnTileObject​(int objectId,
                                            int worldPointX,
                                            int worldPointY,
                                            int sourceSlot,
                                            int sourceItemId,
                                            int sourceWidgetId,
                                            boolean ctrlDown)
        Queues the raw packet for using a widget (typically an item) on a tile object.

        This method sends the OPLOCT (Use Widget on Location/Object) packet, which includes the coordinates of the target object and the details of the source item/widget.

        Parameters:
        objectId - The ID of the target object.
        worldPointX - The X coordinate of the object's location in the world.
        worldPointY - The Y coordinate of the object's location in the world.
        sourceSlot - The slot index of the item being used (e.g., inventory slot).
        sourceItemId - The ID of the item being used.
        sourceWidgetId - The ID of the parent widget containing the item (e.g., inventory widget ID).
        ctrlDown - If true, indicates the control key was held down.
      • queueWidgetOnTileObject

        public void queueWidgetOnTileObject​(net.runelite.api.widgets.Widget widget,
                                            net.runelite.api.TileObject object)
        Queues the packet for using a specific Widget (or item it represents) on a target TileObject.

        This is a convenience method that first calculates the target object's world coordinates and then calls the raw queueWidgetOnTileObject method with the source widget's details.

        Parameters:
        widget - The source Widget containing the item or action to be used on the object.
        object - The target TileObject.