SDK Widgets Reference
Widget facades, step-based handler builders, and equipment/inventory loadouts — the write side of n3Client interface interaction.
Interface interaction: one static facade per game interface (widgets), step-based handler builders that walk-and-act (handlers), and equipment/inventory loadouts (loadouts). Reads belong to SDK Queries Reference (WidgetQuery, InventoryQuery); this page is the write side plus its orchestration layer. Source of truth: docs/sdk-widgets-reference.md in the n3Client repository.
Invariants
- Every packet-sending facade method wraps its send in
Static.invoke— verified pattern:WidgetAPI.interact(int, int, int, int)atapi/src/main/java/dev/n3u/api/widgets/WidgetAPI.java:76-84andNpcAPI.interactatapi/src/main/java/dev/n3u/api/entities/NpcAPI.java:66-73. They are callable fromNPlugin.loop()or any worker thread. - Interactions fire a synthetic click through
ClickManager.click(ClickType.WIDGET)before the widget packet; the click strategy (STATIC/RANDOM/CONTROLLED/NONE) governs what that click packet contains — seedocs/CLICKMANAGER.mdin the repository. - Game-state guards are per-facade, not blanket: of the 20 classes in
api/src/main/java/dev/n3u/api/widgets/, onlyTabsAPIchecksGameState(TabsAPI.openreturns unless the client isLOGGED_INorLOADING,api/src/main/java/dev/n3u/api/widgets/TabsAPI.java:25-33).WidgetAPI.interact,InventoryAPI.interact,EquipmentAPI.equip,BankAPI.withdraw,NpcAPI.interactand the other send facades dispatch without a state check — verifyGameStateyourself where it matters.
Widget facades (api/src/main/java/dev/n3u/api/widgets/)
Method names below were extracted from source on 2026-11-06 (public static members; counts drift with edits, so none are given — the line-cited signatures were individually verified).
| Facade | Methods (names) | Key verified signatures |
|---|---|---|
WidgetAPI | search() → WidgetQuery, interact, dragWidget, onTileObject/onGroundItem/onNpc/onPlayer/onWidget, getText, get, isVisible, closeInterface | WidgetAPI.get(int interfaceId) WidgetAPI.java:525; get(WidgetInfo) :490; get(int groupId, int childId) :514; interact(Widget, String... actions) :39; interact(Widget, String menu, String action) :107; interact(int action, int widgetId, int childId, int itemId) :76 |
BankAPI | search() → InventoryQuery, getX/setX, withdraw/deposit family, withdrawAction, depositAction, depositAllContainers, depositAll, depositEquipment, isOpen, close, contains, count, getSlot, use, bankUse, useGuessNextSlot, dragItem, dragItemToTab, isWithdrawNote, setWithdrawMode | withdraw(int id, int amount, boolean noted) BankAPI.java:280; withdraw(String name, int amount, boolean noted) :296; withdraw(ItemEx, int, boolean) :314; withdraw(InventoryLoadout) :82 |
DialogueAPI | getDialogueHeader, getDialogueText, dialoguePresent, continueDialogue, selectOption, resumeObjectDialogue, resumeNumericDialogue, resumePause, makeX, getOptions, isViewingOptions, optionPresent, continueQuestHelper, continueMuseumQuiz | selectOption(String option) DialogueAPI.java:220 returns boolean; selectOption(int) :210; optionPresent(String) :361 |
InventoryAPI | search(), getItems, getItem, interact, interactSubOp, itemAction, dragItem, dropAll, isFull/isEmpty, getEmptySlots, contains/containsAny, count/canonicalCount, useOn, getCount | interact(ItemEx, String) InventoryAPI.java:71; interact(int itemId, int action) :114; itemAction(int slot, int id, int action) :201 |
EquipmentAPI | search(), isEquipped, getItem, unEquip/equip, interact, itemAction, fromSlot, getAll, unequipAll, getCount | isEquipped(String) EquipmentAPI.java:43; equip(String itemName) :154; equip(EquipmentLoadout) :113; equip(int itemId) :145 |
PrayerAPI | anyActive, quick-prayer block (isQuickPrayerEnabled, toggleQuickPrayer, turnOn/OffQuickPrayers), getActiveOverhead, getActivePrayers, flick, per-style getters, disableAll, toggle; hasLevelFor is an instance method on the enum — call it on a constant (e.g. PrayerAPI.THICK_SKIN.hasLevelFor()), not on the type (PrayerAPI.java:180) | — |
MagicAPI | isAutoCasting, isAutoCastUsable, isDefensiveCasting, home-teleport cooldown, setBestAutoCast, cast, Spell comparator | — |
ShopAPI | isOpen, close, buy1/5/10/50/X, sell1/5/10/50/X, getShopItem, getStockQuantity, shopContains, buyAction, sellAction | — |
GrandExchangeAPI | close, canCollect, getOffers, abortOffer, bypassHighOfferWarning, cancel, collectAs, freeSlot, startBuyOffer, startBuyOfferPercentage, startSellOffer, startSellOfferPercentage, collectFromSlot, isOpen, collectAll | — |
TradeAPI | isOpen, isOnMainScreen, isOnConfirmationScreen, getOfferingItems, getReceivingItems, offer, remove, isAcceptedByPlayer/Other, accept, decline | — |
MakeXAPI | isOpen, getAmount, setAmount, confirm, confirmIndex | — |
TabsAPI | open(Tab), isOpen(Tab) | gameState guard TabsAPI.java:25-33 |
DepositBoxAPI | isOpen, close, depositAll, depositWornItems, depositLootingBag, deposit, depositAllExcept, depositWorn | — |
EmoteAPI / SlayerRewardsAPI / SmithingAPI / TanningAPI | perform / isOpen, getPoints / hammer-and-bars checks incl. smith / cost math (calculateCost, getMaxAffordableAmount, canTan) | — |
MiniMapAPI / WorldMapAPI | path drawing and render helpers / coordinate conversion and map drawing | WorldMapAPI.convertMapClickToWorldPoint, path/marker drawing |
BankQuantityResolver (no public static methods) is the quantity-decision helper covered by the package's one unit test (see Tests).
Handler builders (api/src/main/java/dev/n3u/api/handlers/)
All builders extend dev.n3u.util.handler.AbstractHandlerBuilder and compile to a StepHandler — the same engine the Script DSL targets (see docs/SCRIPT-DSL.md in the repository). Acquire with XBuilder.get(), chain steps, then build() (inherited) or let StrategicPathing embed them (WalkerPath references no builders; only StrategicPathing composes GenericHandlerBuilder steps).
| Builder | Steps (verified names) |
|---|---|
BankBuilder | open(0/1), depositInventory(), depositEquipment(), withdraw(2), deposit(1), use(1), useGuessNextSlot(1); static of(1) → BankItem[] |
DialogueBuilder | processDialogues(1), waitForDialogue(), continueAllDialogue() |
InventoryBuilder | interact(2/3), drop(1), useOnItem(3), useOnTileItem(3), useOnObject(3), useOnNpc(3), useOnPlayer(3) |
NpcBuilder | interact(2), visit(2), talkTo(1/2), attack(1), trade(1) |
PlayerBuilder | interact(2), follow(1), attack(1), trade(1) |
TileItemBuilder | interact(2), pickUp(2) |
TileObjectBuilder | visit(3/4), interact(2/3) |
GrandExchangeHandler | open(), collectAll(), buy(4), sell(3), buyOffer(3), sellOffer(3) |
TradeBuilder | tradePlayer(3); static of(1) → TradeItem[] |
GenericHandlerBuilder | raw step container used by StrategicPathing |
Inherited step vocabulary from AbstractHandlerBuilder (api/src/main/java/dev/n3u/util/handler/AbstractHandlerBuilder.java; overload counts omitted — the members exist in multiple forms): add (plain, labelled, and supplier forms — add(Function) at :26, add(String, Function) at :38), addDelay, addDelayUntil, append, walkTo, walkToWorldAreaSupplier, walkToWorldPointSupplier.
Invariants: builder steps interleave ClickManager.clearClickBox() so a stale controlled-click shape does not leak into later steps (BankBuilder.java:69-221); BankBuilder.open(BankLocations) walks via walkToWorldAreaSupplier to the nearest bank when none is given (BankBuilder.java:88, dev.n3u.data.locatables.BankLocations).
Loadouts (api/src/main/java/dev/n3u/api/loadouts/)
InventoryLoadout and EquipmentLoadout declare item sets consumed by BankAPI.withdraw(InventoryLoadout) (BankAPI.java:82); items are LoadoutItem implementations (IdLoadoutItem, NamedLoadoutItem); LoadoutException is thrown only while constructing or populating a loadout (IdLoadoutItem.java:158, NamedLoadoutItem.java:169, InventoryLoadout.java:49,72, EquipmentLoadout.java:48-58) — the withdraw path throws nothing; dev.n3u.api.loadouts.item.restock.RestockConfig + PriceSetupType configure re-supply; ItemDepletionListener observes usage. Withdraw returns boolean without throwing, but true does not guarantee the full loadout was withdrawn: it is also returned when the per-tick action budget (default 10, BankAPI.java:82-87) is exhausted with items still unprocessed (BankAPI.java:113-128), and unbanked or insufficient non-optional items are silently skipped after ItemDepletionListener fires (BankAPI.java:146-165). A false return (bank closed, or over-carrying an item the loadout must shed) is the clear failure signal — verify the resulting inventory when completeness matters.
Worked example — bank, withdraw and equip
import dev.n3u.api.handlers.BankBuilder;
import dev.n3u.api.widgets.BankAPI;
import dev.n3u.api.widgets.EquipmentAPI;
public void prepareSupplies()
{
// 1. Step-handler route: walk, open, deposit, withdraw — executes on the calling worker thread
BankBuilder.get()
.open() // walks to nearest bank when no location is passed
.depositInventory()
.withdraw(false, BankBuilder.of(995, 1000)) // withdraw(noted, BankItem...), BankBuilder.java:162; of(int... idQtyPairs) :238
.build()
.execute();
// 2. Direct facade use once the bank is open
if (!BankAPI.isOpen()) {
return; // expected failure path: bank never opened
}
if (!EquipmentAPI.isEquipped("Dragon axe")) { // isEquipped(String), EquipmentAPI.java:43
EquipmentAPI.equip("Dragon axe"); // equip(String), EquipmentAPI.java:154
}
}Expected result: inventory deposited, 1000 of item 995 withdrawn unnoted, the named axe equipped. Failure handling: BankBuilder.open() ends with the labelled no-timeout delay addDelayUntil("end", BankAPI::isOpen) (BankBuilder.java:123, resolving to the no-timeout HandlerBuilder.addDelayUntil(int, Predicate) at HandlerBuilder.java:181-193) — until the condition holds, that step returns itself forever, so a handler whose bank never opens loops that step indefinitely instead of ending. Prefer the timeout overloads (HandlerBuilder.java:138-156, :165-172) for open-like waits: they run an onTimeout callback and then return END_EXECUTION. Guard with BankAPI.isOpen() before direct facade calls. Cleanup: StepHandler.execute() has no try/finally (StepHandler.java:115-121), and the builder walk steps park their WalkerPath in the step context without shutting it down (HandlerBuilder.java:242-328). WalkerPath cleans up after itself only on natural completion or cancel (WalkerPath.java:178-234; see SDK Pathfinder Reference) — an exception mid-walk bypasses that (only Walker's own loop shuts its path down in finally, Walker.java:201-206). After an aborted run, call StepHandler.reset() to shut down any path left in the context (StepHandler.java:81-94).
Thread affinity
Facades and builders are safe from worker threads: packet sends hop to the client thread via Static.invoke, and handler/walker execution sleeps with Delays.tick() (which refuses the client thread). Do not call facades from within a Static.invoke block that already holds the client thread if the call can block (builder execute()); pure queries (isOpen, count, search()...collect()) are cheap and safe inline there.
Tests
api/src/test/java/dev/n3u/api/widgets/BankQuantityResolverTest.javacoversBankQuantityResolver(the focused run documented inAGENTS.md:.\gradlew.bat :api:test --tests dev.n3u.api.widgets.BankQuantityResolverTest).- No other facade or builder has an automated test (verified by
git ls-files "api/src/test/java", 2026-11-06). The repository tracks a follow-up for fixture-based tests of at least one facade interaction chain (interact → packet args) and one builder's compiled step graph.
Known limits
- Facade method names track current game interfaces; a client update can shift widget ids behind
WidgetAPI.get(int)before these pages change. GrandExchangeAPIpercentage offers andTradeAPIacceptance flows are verified only as call surfaces; offer economics (pricing rules) are not documented here and were not exercised live (open question).- Handler builders execute step graphs; they are not coroutine scripts. For branching/looping logic use the Script DSL (
docs/SCRIPT-DSL.mdin the repository).
SDK Queries Reference
The dev.n3u.queries package — AbstractQuery shaping and terminals, actor queries, all concrete query classes, thread affinity, and a looting example.
SDK Game Reference
The game, entities, and threaded packages — world-state facades, actor/tile interaction, sailing, and tick-blocking helpers for worker-thread automation.