Class GroundItemPackets


  • public class GroundItemPackets
    extends java.lang.Object
    A utility class for sending packets related to TileItem (ground item) interactions to the game server.

    This class primarily handles picking up ground items (actions) and using items/widgets directly on a ground item. It abstracts the low-level packet construction and world coordinate handling.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void queueGroundItemAction​(int actionFieldNo, int objectId, int worldPointX, int worldPointY, boolean ctrlDown)
      Queues the low-level packet to perform a generic action click on a ground item.
      void queueGroundItemAction​(net.runelite.api.TileItem item, net.runelite.api.coords.WorldPoint location, boolean ctrlDown)
      Queues the packet to perform the default "Take" action (Action 3) on a ground item.
      void queueWidgetOnGroundItem​(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 ground item.
      void queueWidgetOnGroundItem​(net.runelite.api.TileItem item, net.runelite.api.coords.WorldPoint location, net.runelite.api.widgets.Widget w, boolean ctrlDown)
      Queues the packet for using a specific Widget (or item it represents) on a target TileItem.
      • Methods inherited from class java.lang.Object

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

      • GroundItemPackets

        public GroundItemPackets()
    • Method Detail

      • queueGroundItemAction

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

        This method sends one of the OPOBJ packets (e.g., OPOBJ1 through OPOBJ5, depending on the packet factory implementation). These packets are used for actions like "Take," "Examine," or other option clicks on a ground item.

        Parameters:
        actionFieldNo - The 1-based index of the action to execute (typically 1-5 for ground items).
        objectId - The Item ID of the ground item.
        worldPointX - The X coordinate of the item's location in the world.
        worldPointY - The Y coordinate of the item's location in the world.
        ctrlDown - If true, indicates the control key was held down.
      • queueWidgetOnGroundItem

        public void queueWidgetOnGroundItem​(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 ground item.

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

        Parameters:
        objectId - The Item ID of the ground item.
        worldPointX - The X coordinate of the item's location in the world.
        worldPointY - The Y coordinate of the item'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.
      • queueGroundItemAction

        public void queueGroundItemAction​(net.runelite.api.TileItem item,
                                          net.runelite.api.coords.WorldPoint location,
                                          boolean ctrlDown)
        Queues the packet to perform the default "Take" action (Action 3) on a ground item.

        This is a convenience method for the most common interaction with a ground item. It uses action index 3, which is conventionally the "Take" option for items.

        Parameters:
        item - The target TileItem object.
        location - The WorldPoint location of the item on the map.
        ctrlDown - If true, indicates the control key was held down.
      • queueWidgetOnGroundItem

        public void queueWidgetOnGroundItem​(net.runelite.api.TileItem item,
                                            net.runelite.api.coords.WorldPoint location,
                                            net.runelite.api.widgets.Widget w,
                                            boolean ctrlDown)
        Queues the packet for using a specific Widget (or item it represents) on a target TileItem.

        This is a convenience method that simplifies sending the OPOBJT packet by extracting necessary details from the provided TileItem and source Widget.

        Parameters:
        item - The target TileItem object on the ground.
        location - The WorldPoint location of the item on the map.
        w - The source Widget containing the item or action to be used on the ground item.
        ctrlDown - If true, indicates the control key was held down.