Class ComponentNode

java.lang.Object
com.botwithus.bot.api.component.ComponentNode

public final class ComponentNode extends Object
Rich wrapper around a Component record plus its position in a materialized ComponentTree. Mirrors the entity wrappers (e.g. Npc): cheap field access delegating to the record, in-memory tree navigation, and a thin interaction hook.

Obtained via Components.in(int) / Components.under(int, int) (attached — full navigation, no extra RPC) or Components.get(int, int) (detached — parent() is null and children() triggers a one-shot subtree fetch).

  • Method Details

    • interfaceId

      public int interfaceId()
    • componentId

      public int componentId()
    • subId

      public int subId()
    • type

      public ComponentType type()
      Stable semantic category (decoded from the wire category code).
    • rawType

      public int rawType()
      Build-specific raw type byte. Prefer type() for queries.
    • text

      public String text()
    • spriteId

      public int spriteId()
    • itemId

      public int itemId()
    • itemAmount

      public int itemAmount()
    • isHidden

      public boolean isHidden()
    • x

      public int x()
    • y

      public int y()
    • width

      public int width()
    • height

      public int height()
    • data

      public Component data()
      The underlying raw record.
    • parent

      public ComponentNode parent()
      Parent node, or null at the root / for a detached node.
    • children

      public List<ComponentNode> children()
      Direct children. For an attached node this is in-memory; for a detached node (from Components.get(int, int)) it triggers one get_interface_tree fetch rooted here.
    • descendants

      public List<ComponentNode> descendants()
      All descendants, depth-first. One fetch total for a detached node.
    • isRoot

      public boolean isRoot()
      True when this node has no parent in its view.
    • interact

      public void interact(int optionIndex)
      Queue a click on this component with the given 1-based right-click option index. Builds a GameAction with ActionTypes.COMPONENT, the option in param1, -1 (no sub-slot) in param2, and the packed (iface<<16)|comp in param3 — the same shape inventory slot clicks use, minus the slot. For inventory grids use the Backpack/Bank facades, which supply the slot.
    • selectDialogOption

      public void selectDialogOption()
      Queue selection of this component as a multi-choice dialogue option.

      Dialogue options are driven by the ActionTypes.DIALOGUE action (type 30) — the engine's resume / pausebutton path — not the ActionTypes.COMPONENT action interact(int) sends. A COMPONENT click on an option row dispatches but the server ignores it (the dialogue doesn't advance); the DIALOGUE action is what a manual option pick emits. Shape: param1 = 0, no sub-slot, packed (iface<<16)|comp in param3. Verified live against interface 1188.

    • dragOnto

      public void dragOnto(ComponentNode target)
      Queue a drag of this component onto target, reproducing a manual drag-and-release so the client sends its component-drag packet. Builds a GameAction with ActionTypes.COMPONENT_DRAG: this node's (iface<<16)|comp hash in param1, the target's in param2, and the two nodes' sub-slot ids packed into param3 as (fromSub<<16)|(toSub&0xFFFF) — each -1 when the node is a top-level component.

      Because each node carries its own wire subId, dragging one inventory slot onto another — two sub-components of the same grid that differ only by sub-slot — works: obtain both slot nodes from the component tree, then from.dragOnto(to).

    • toString

      public String toString()
      Overrides:
      toString in class Object