Class LocalPlayer

java.lang.Object
privbot.hooks.LocalPlayer

public final class LocalPlayer extends Object
The local player, read through the plugin's own adapter: ctx.player.

Replaces the raw client.getLocalPlayer() reads (the most common raw call in catalog plugins). Every read is an Observed, so "could not read" never looks like "idle", "not moving" or "0 HP".

Threading: each method marshals itself through GameThread.ensure(java.util.function.Supplier<T>, T) like the other facades; inside ctx.read(...) or a TaskNode's shouldExecute it runs inline. A decision that needs several of these should batch them in one ctx.read(() -> ...).

On Impact, Elorin and SpawnPK a raw Player getter answers 0 for a value this client cannot read; these reads answer UNREADABLE instead.

  • Method Details

    • get

      public Observed<net.runelite.api.Player> get()
      The local Player. UNREADABLE when there is none (not logged in, or the read failed). Do not keep the returned object across ticks: on Impact, Elorin and SpawnPK it is a new object on every read.
      Returns:
      the local player
    • name

      public Observed<String> name()
      Returns:
      the local player's display name; UNREADABLE when there is no player or no name yet
    • tile

      public Observed<net.runelite.api.coords.WorldPoint> tile()
      Where the player is drawn (the client's player location). On Impact, Elorin and SpawnPK this is the fine position, which trails the server's tile by up to a tick while walking; use serverTile() to plan walks or detect a failed step.
      Returns:
      the drawn world tile
    • serverTile

      public Observed<net.runelite.api.coords.WorldPoint> serverTile()
      Where the SERVER has put the player: the first tile of its path, which leads the drawn tile() while walking. On RuneLite-API servers this is Player.getWorldLocation(). UNREADABLE when this client's path cannot be read.
      Returns:
      the server tile
    • animation

      public Observed<Integer> animation()
      The player's current animation id in this server's numbering; -1 is a real answer (no animation). Server ids differ from OSRS ids on some servers (Elorin player animations are OSRS + 19000).
      Returns:
      the animation id
    • isAnimating

      public Observed<Boolean> isAnimating()
      Returns:
      whether an animation is playing; UNREADABLE when the animation cannot be read
    • isMoving

      public Observed<Boolean> isMoving()
      Whether the player is moving: the pose animation differs from the idle pose (the same test as ctx.user.isMoving(), which answers false when it cannot tell). On a client whose pose animation cannot be read, the answer comes from the tiles instead: the drawn tile trails the server tile while the player walks, so the two differ exactly while a step is in progress.
      Returns:
      whether the player is moving
    • healthRatio

      public Observed<Integer> healthRatio()
      The health bar's filled amount (out of healthScale()); -1 means no health bar is drawn, which is a real answer, not "dead". Prefer hitpoints() for your own HP.
      Returns:
      the health ratio
    • healthScale

      public Observed<Integer> healthScale()
      Returns:
      the health bar's scale (the denominator of healthRatio())
    • hitpoints

      public Observed<Integer> hitpoints()
      Current (boosted) hitpoints (Skills.observedLevel(net.runelite.api.Skill, boolean)). UNREADABLE when this client's skill levels cannot be read or have not arrived from the server yet; a placeholder level (99) is never returned.
      Returns:
      current hitpoints
    • maxHitpoints

      public Observed<Integer> maxHitpoints()
      Returns:
      base (real) hitpoints level; UNREADABLE as for hitpoints()
    • interacting

      public Observed<net.runelite.api.Actor> interacting()
      Who the player is interacting with. ABSENT when the client says nobody. Unlike Player.getInteracting(), which answers null alike for "nobody", "unreadable" and the first NPC on Impact, Elorin and SpawnPK, this tells them apart: a target that does not resolve to an actor is UNREADABLE.
      Returns:
      the interacting actor