Record Class LocalPlayer

java.lang.Object
java.lang.Record
com.botwithus.bot.api.snapshot.LocalPlayer
Record Components:
serverIndex - server-side player slot
combatLevel - combat level, or 0 if not computed
tileX - absolute world tile X
tileY - absolute world tile Y
plane - 0..3
flags - bitset; bit 0 = moving
followingIndex - server index of the follow target, or -1
animationId - current animation id, or -1
stanceId - current stance id
targetIndex - server index of the current target, or -1
targetType - target type discriminator, or 0 for none
isMember - member-status flag from the producer
spotAnimId - first active spot anim (graphic) id, or -1 if none
currentHealth - current life points, or HEALTH_UNKNOWN when unfilled
maxHealth - maximum life points, or HEALTH_UNKNOWN when unfilled
skills - live skills array; defensive copy taken on construction
orientation - rendered facing (wire v21); Orientation.unknown() when not read

public record LocalPlayer(int serverIndex, int combatLevel, int tileX, int tileY, int plane, int flags, int followingIndex, int animationId, int stanceId, int targetIndex, int targetType, boolean isMember, int spotAnimId, int currentHealth, int maxHealth, List<Skill> skills, Orientation orientation) extends Record
Snapshot of the local (logged-in) player at the producer's current tick. Returned by GameSnapshot.self(); null when the client is not in-game.

Every field except the two health ones is read straight out of shared memory. Health is not published on the wire — it lives in two varps, which cost a pipe round-trip — so GameSnapshot.self() leaves it at HEALTH_UNKNOWN and GameAPI.getLocalPlayer() is the accessor that fills it in. See hasHealth().

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Value currentHealth() and maxHealth() carry when no one has read the backing varps — the sentinel the variable reads use for "unset" as well, so a caller needs only one "no value" check.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LocalPlayer(int serverIndex, int combatLevel, int tileX, int tileY, int plane, int flags, int followingIndex, int animationId, int stanceId, int targetIndex, int targetType, boolean isMember, int spotAnimId, int currentHealth, int maxHealth, List<Skill> skills)
    Builds a record with an unknown facing; kept so pre-v21 callers compile unchanged.
    LocalPlayer(int serverIndex, int combatLevel, int tileX, int tileY, int plane, int flags, int followingIndex, int animationId, int stanceId, int targetIndex, int targetType, boolean isMember, int spotAnimId, int currentHealth, int maxHealth, List<Skill> skills, Orientation orientation)
    Creates an instance of a LocalPlayer record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the animationId record component.
    int
    Returns the value of the combatLevel record component.
    int
    Returns the value of the currentHealth record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns the value of the flags record component.
    int
    Returns the value of the followingIndex record component.
    final int
    Returns a hash code value for this object.
    boolean
    True when both health fields carry a real reading.
    boolean
    Returns the value of the isMember record component.
    boolean
     
    int
    Returns the value of the maxHealth record component.
    Returns the value of the orientation record component.
    int
    Returns the value of the plane record component.
    int
    Returns the value of the serverIndex record component.
    Returns the value of the skills record component.
    int
    Returns the value of the spotAnimId record component.
    int
    Returns the value of the stanceId record component.
    int
    Returns the value of the targetIndex record component.
    int
    Returns the value of the targetType record component.
    int
    Returns the value of the tileX record component.
    int
    Returns the value of the tileY record component.
    final String
    Returns a string representation of this record class.
    withHealth(int currentHealth, int maxHealth)
    Copy of this record carrying the supplied health reading.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • HEALTH_UNKNOWN

      public static final int HEALTH_UNKNOWN
      Value currentHealth() and maxHealth() carry when no one has read the backing varps — the sentinel the variable reads use for "unset" as well, so a caller needs only one "no value" check.
      See Also:
  • Constructor Details

    • LocalPlayer

      public LocalPlayer(int serverIndex, int combatLevel, int tileX, int tileY, int plane, int flags, int followingIndex, int animationId, int stanceId, int targetIndex, int targetType, boolean isMember, int spotAnimId, int currentHealth, int maxHealth, List<Skill> skills, Orientation orientation)
      Creates an instance of a LocalPlayer record class.
      Parameters:
      serverIndex - the value for the serverIndex record component
      combatLevel - the value for the combatLevel record component
      tileX - the value for the tileX record component
      tileY - the value for the tileY record component
      plane - the value for the plane record component
      flags - the value for the flags record component
      followingIndex - the value for the followingIndex record component
      animationId - the value for the animationId record component
      stanceId - the value for the stanceId record component
      targetIndex - the value for the targetIndex record component
      targetType - the value for the targetType record component
      isMember - the value for the isMember record component
      spotAnimId - the value for the spotAnimId record component
      currentHealth - the value for the currentHealth record component
      maxHealth - the value for the maxHealth record component
      skills - the value for the skills record component
      orientation - the value for the orientation record component
    • LocalPlayer

      public LocalPlayer(int serverIndex, int combatLevel, int tileX, int tileY, int plane, int flags, int followingIndex, int animationId, int stanceId, int targetIndex, int targetType, boolean isMember, int spotAnimId, int currentHealth, int maxHealth, List<Skill> skills)
      Builds a record with an unknown facing; kept so pre-v21 callers compile unchanged.
  • Method Details

    • isMoving

      public boolean isMoving()
    • hasHealth

      public boolean hasHealth()
      True when both health fields carry a real reading. False on a record taken straight from the snapshot, which never pays the varp read.
    • withHealth

      public LocalPlayer withHealth(int currentHealth, int maxHealth)
      Copy of this record carrying the supplied health reading. The seam the varp-reading accessor uses to enrich a snapshot-built record without every caller restating the other thirteen fields.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • serverIndex

      public int serverIndex()
      Returns the value of the serverIndex record component.
      Returns:
      the value of the serverIndex record component
    • combatLevel

      public int combatLevel()
      Returns the value of the combatLevel record component.
      Returns:
      the value of the combatLevel record component
    • tileX

      public int tileX()
      Returns the value of the tileX record component.
      Returns:
      the value of the tileX record component
    • tileY

      public int tileY()
      Returns the value of the tileY record component.
      Returns:
      the value of the tileY record component
    • plane

      public int plane()
      Returns the value of the plane record component.
      Returns:
      the value of the plane record component
    • flags

      public int flags()
      Returns the value of the flags record component.
      Returns:
      the value of the flags record component
    • followingIndex

      public int followingIndex()
      Returns the value of the followingIndex record component.
      Returns:
      the value of the followingIndex record component
    • animationId

      public int animationId()
      Returns the value of the animationId record component.
      Returns:
      the value of the animationId record component
    • stanceId

      public int stanceId()
      Returns the value of the stanceId record component.
      Returns:
      the value of the stanceId record component
    • targetIndex

      public int targetIndex()
      Returns the value of the targetIndex record component.
      Returns:
      the value of the targetIndex record component
    • targetType

      public int targetType()
      Returns the value of the targetType record component.
      Returns:
      the value of the targetType record component
    • isMember

      public boolean isMember()
      Returns the value of the isMember record component.
      Returns:
      the value of the isMember record component
    • spotAnimId

      public int spotAnimId()
      Returns the value of the spotAnimId record component.
      Returns:
      the value of the spotAnimId record component
    • currentHealth

      public int currentHealth()
      Returns the value of the currentHealth record component.
      Returns:
      the value of the currentHealth record component
    • maxHealth

      public int maxHealth()
      Returns the value of the maxHealth record component.
      Returns:
      the value of the maxHealth record component
    • skills

      public List<Skill> skills()
      Returns the value of the skills record component.
      Returns:
      the value of the skills record component
    • orientation

      public Orientation orientation()
      Returns the value of the orientation record component.
      Returns:
      the value of the orientation record component