Skip to content

Packets Guide

Packets are short for "network packets" and define how data is packaged and sent over the network from the OSRS client to the server where it is processed. There are a huge number of packets on both the client and server side (250+ I think), but most people are interested in the client -> server packets for creating automation scripts and other tools of that nature.

This guide will walk you through:

  • The creation of a packet
  • How a packet is processed
  • Example code
  • Table of different packet types

The Packet Creation Pipeline

When you click on an NPC, Object, Widget, Interface, or Dialogue (or most things in the game), a packet will ultimately be created to process the click on the server side. The following section details an example sequence of events the client executes for orchestrating the creation of a network packet.

Identify the Action

The client determines you are trying to "Attack NPC" (MenuAction.NPC_FIRST_OPTION). This particular click gets routed to the doAction function, a single function which handles menu action clicks for players, NPC's, game objects, interfaces, and chat dialogues in the game. It finally grabs the specific ClientPacket for the action you performed (OPNPC1) and stores it in an object.

Initialize the Node

The client creates a new PacketBufferNode. This class is used as a container to store the data that will be sent over the network. It includes references to the PacketWriter used to write to the TCP connection and the PacketBuffer used to write the data.

Encrypt the Opcode

The client takes the opcode (a numerical value representing an enum for actions you can take in game) from the ClientPacket, encrypts it using the IsaacCipher, and writes that encrypted opcode as the very first byte(s) of the PacketBuffer. This essentially encodes the "type" of the packet being sent so that the server knows how to process it. Opcodes coninside with the MenuAction enum in RuneLite and are an effective way to identify the type of packet being sent from the obfuscated source code.

I believe the packet's payload length is also encrypted into the PacketBuffer (however, I have not verified this).

Write the Payload

The client uses the PacketBuffer to write the specific details (params) of the action. Each packet will contain a different set of params. This makes sense since each packet is different and requires different data to be sent. i.e. You don't need to send the ID of a nearby tree if you are withdrawing an item from your bank, but you would need to send the ID of the nearby tree if you are clicking on it to examine or chop it down.

For example, the OPNPC1 packet for clicking the first menu action on a Goblin ("Attack") includes the:

  • NPC Index
  • CtrlDown (1 if you are holding down control to invert walk/run)
  • Subop (extra parameter for highlighting the index of a submenu if OSRS chooses to include submenus for NPC's). A sub-menu example would be something like the additional teleport options that pop out when you hover over "Rub" on a ring of dueling.

Queue

The client finally calls the addNode() method to put the packet in the outgoing queue where it will be sent on the next game tick by the PacketWriter.

Example Code

java
// 1. Grab the specific ClientPacket we want to send (e.g., Object Click)
ClientPacket objectClickPacket = client.getObjectClickPacket();

// 2. Create the PacketBufferNode. 
// The client automatically uses the IsaacCipher to encrypt the opcode during this step.
PacketBufferNode packetNode = client.preparePacket(objectClickPacket, client.getIsaacCipher());

// 3. Get the buffer so we can write our payload data
PacketBuffer buffer = packetNode.getPacketBuffer();

// 4. Write the payload data into the buffer.
// The order AND data types (Int, Short, Byte) MUST perfectly match what the server expects.
buffer.writeInt(9730);      // Example: The ID of the object (e.g., a tree)
buffer.writeShort(3200);    // Example: The X coordinate
buffer.writeShort(3200);    // Example: The Y coordinate
buffer.writeByte(0);        // Example: Control/Shift click status

// 5. Add the finished node to the outgoing queue to be sent to Jagex
client.addNode(packetNode);

Packet Types

Packet TypeParamsExampleDescription
EVENT_MOUSE_CLICKmouseX, mouseY, 0, mouseInfoClicking anywhere on the game canvasSent to notify the server that the mouse was clicked. It includes information about the x/y coordinate that was clicked and which mouse button (left/right) was clicked.
IF_BUTTONTsourceSlot, sourceItemId, sourceWidgetId, destinationItemId, destinationWidgetId, destinationSlotUsing high level alchemy on an item in your inventory WIDGET_ON_WIDGETInterface button target, This packet is sent when an interface element is used on another interface element.
IF_BUTTONXwidgetId, slot, itemId, opCodeClicking "eat" on a shark in your inventoryA standard interface button click. Equipping gear, eating food, withdrawing items all use this packet.
IF_SUBOPwidgetId, slot, itemId, menuIndex, subActionIndexClicking "Ferox Enclave" in the pop out menu of the ring of dueling's "Rub" optionSent when a sub menu is clicked. Sub menus include things like max/skill cape teleports, jewelry teleports, etc... Anything that an additional menu pops up when you hover your mouse
MOVE_GAMECLICK5, ctrlDown, worldPointX, worldPointYMoving to a new tileSent when your player moves, simple as that.
OPLOC1-5worldPointX, worldPointY, subop, objectId, ctrlDownMining a rock or examining a treeGame object clicks. There are 5 of these 1 for each menu action on a game object. i.e. Mine, Walk Here, Cancel, Examine etc...
OPLOCTobjectId, ctrlDown, worldPointX, worldPointY, slot, itemId, widgetIdFilling up a bucket from a fountainOperaction location target. Sent when using a widget in your inventory on a game object.
OPNPC1-5npcIndex, ctrlDown, subopAttacking a GoblinSent when you click on a menu action for an NPC. There are 5 of these for 5 potential options on NPC's like Attack, Talk-To, Bank, Examine, etc...
OPNPCTnpcIndex, itemId, widgetId, slot, ctrlDownUsing fire strike on a Varrock guardSent when you use a widget on an NPC like casting a spell on an NPC or giving a quest NPC food.
OPOBJ1-5subop ctrlDown, worldPointX, worldPointY, objectIdPicking up a twisted bow from the groundSent when you interact with an item on the ground e.g. TileItem.
OPOBJTslot, objectId, worldPointY, widgetId, worldPointX, itemId, ctrlDownUsing telekenetic grab on an item on the ground.Sent when using a widget targeting a ground item.
OPPLAYER1-8ctrlDown, playerIndexFollowing or trading with a playerSent when you perform 1 of 8 menu actions on another player.
OPPLAYERTitemId, slot, ctrlDown, widgetId, playerIndexUsing neutralizing potion on a player in ToA's monkey room.Sent when using a widget targeting another player. i.e. using an item on another player
RESUME_COUNTDIALOGvar0Withdrawing X items from the bank and the bank asking what to set X's value toSent when the game needs a numerical input from you like withdrawing x items.
RESUME_OBJDIALOGvar0Selecting searched item in the G.E.Sent when the game needs an item selection from you. This is most commonly used with the grand exchange when players click on an item they searched for to buy or sell.
RESUME_NAMEDIALOGlength, stringAdding a friend or joining a chatSent when the game needs a string input from your chatbox.
RESUME_PAUSEBUTTONvar1, var0Continuing dialogue with an NPCSent when the game pauses the conversation dialogue between you and an NPC. You must "Click here to continue" to send this packet and continue to the next dialogue node in the tree
OPHELDdestChildIndex, selectedChildIndex, selectedId, destId, selectedItemId, destItemIdDoing that humpty dumpty quest puzzleSent when a drag and drop action occurs in the client. I don't have many great examples of this packet.
SET_HEADINGorientationChanging your sailing boat's headingSent when you change the direction your sailboat is facing