Class LocalPlayer
java.lang.Object
privbot.hooks.LocalPlayer
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 Summary
Modifier and TypeMethodDescriptionThe player's current animation id in this server's numbering;-1is a real answer (no animation).Observed<net.runelite.api.Player> get()The localPlayer.The health bar's filled amount (out ofhealthScale());-1means no health bar is drawn, which is a real answer, not "dead".Current (boosted) hitpoints (Skills.observedLevel(net.runelite.api.Skill, boolean)).Observed<net.runelite.api.Actor> Who the player is interacting with.isMoving()Whether the player is moving: the pose animation differs from the idle pose (the same test asctx.user.isMoving(), which answers false when it cannot tell).name()Observed<net.runelite.api.coords.WorldPoint> Where the SERVER has put the player: the first tile of its path, which leads the drawntile()while walking.Observed<net.runelite.api.coords.WorldPoint> tile()Where the player is drawn (the client's player location).
-
Method Details
-
get
The localPlayer. 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
-
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; useserverTile()to plan walks or detect a failed step.- Returns:
- the drawn world tile
-
serverTile
Where the SERVER has put the player: the first tile of its path, which leads the drawntile()while walking. On RuneLite-API servers this isPlayer.getWorldLocation(). UNREADABLE when this client's path cannot be read.- Returns:
- the server tile
-
animation
-
isAnimating
-
isMoving
Whether the player is moving: the pose animation differs from the idle pose (the same test asctx.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
The health bar's filled amount (out ofhealthScale());-1means no health bar is drawn, which is a real answer, not "dead". Preferhitpoints()for your own HP.- Returns:
- the health ratio
-
healthScale
- Returns:
- the health bar's scale (the denominator of
healthRatio())
-
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
- Returns:
- base (real) hitpoints level; UNREADABLE as for
hitpoints()
-
interacting
Who the player is interacting with. ABSENT when the client says nobody. UnlikePlayer.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
-