Record Class LocalPlayer
java.lang.Object
java.lang.Record
com.botwithus.bot.api.snapshot.LocalPlayer
- Record Components:
serverIndex- server-side player slotcombatLevel- combat level, or0if not computedtileX- absolute world tile XtileY- absolute world tile Yplane-0..3flags- bitset; bit 0 = movingfollowingIndex- server index of the follow target, or-1animationId- current animation id, or-1stanceId- current stance idtargetIndex- server index of the current target, or-1targetType- target type discriminator, or0for noneisMember- member-status flag from the producerspotAnimId- first active spot anim (graphic) id, or-1if nonecurrentHealth- current life points, orHEALTH_UNKNOWNwhen unfilledmaxHealth- maximum life points, orHEALTH_UNKNOWNwhen unfilledskills- live skills array; defensive copy taken on constructionorientation- 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
FieldsModifier and TypeFieldDescriptionstatic final intValuecurrentHealth()andmaxHealth()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
ConstructorsConstructorDescriptionLocalPlayer(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 aLocalPlayerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theanimationIdrecord component.intReturns the value of thecombatLevelrecord component.intReturns the value of thecurrentHealthrecord component.final booleanIndicates whether some other object is "equal to" this one.intflags()Returns the value of theflagsrecord component.intReturns the value of thefollowingIndexrecord component.final inthashCode()Returns a hash code value for this object.booleanTrue when both health fields carry a real reading.booleanisMember()Returns the value of theisMemberrecord component.booleanisMoving()intReturns the value of themaxHealthrecord component.Returns the value of theorientationrecord component.intplane()Returns the value of theplanerecord component.intReturns the value of theserverIndexrecord component.skills()Returns the value of theskillsrecord component.intReturns the value of thespotAnimIdrecord component.intstanceId()Returns the value of thestanceIdrecord component.intReturns the value of thetargetIndexrecord component.intReturns the value of thetargetTyperecord component.inttileX()Returns the value of thetileXrecord component.inttileY()Returns the value of thetileYrecord component.final StringtoString()Returns a string representation of this record class.withHealth(int currentHealth, int maxHealth) Copy of this record carrying the supplied health reading.
-
Field Details
-
HEALTH_UNKNOWN
public static final int HEALTH_UNKNOWNValuecurrentHealth()andmaxHealth()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 aLocalPlayerrecord class.- Parameters:
serverIndex- the value for theserverIndexrecord componentcombatLevel- the value for thecombatLevelrecord componenttileX- the value for thetileXrecord componenttileY- the value for thetileYrecord componentplane- the value for theplanerecord componentflags- the value for theflagsrecord componentfollowingIndex- the value for thefollowingIndexrecord componentanimationId- the value for theanimationIdrecord componentstanceId- the value for thestanceIdrecord componenttargetIndex- the value for thetargetIndexrecord componenttargetType- the value for thetargetTyperecord componentisMember- the value for theisMemberrecord componentspotAnimId- the value for thespotAnimIdrecord componentcurrentHealth- the value for thecurrentHealthrecord componentmaxHealth- the value for themaxHealthrecord componentskills- the value for theskillsrecord componentorientation- the value for theorientationrecord 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
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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
serverIndex
public int serverIndex()Returns the value of theserverIndexrecord component.- Returns:
- the value of the
serverIndexrecord component
-
combatLevel
public int combatLevel()Returns the value of thecombatLevelrecord component.- Returns:
- the value of the
combatLevelrecord component
-
tileX
-
tileY
-
plane
-
flags
-
followingIndex
public int followingIndex()Returns the value of thefollowingIndexrecord component.- Returns:
- the value of the
followingIndexrecord component
-
animationId
public int animationId()Returns the value of theanimationIdrecord component.- Returns:
- the value of the
animationIdrecord component
-
stanceId
-
targetIndex
public int targetIndex()Returns the value of thetargetIndexrecord component.- Returns:
- the value of the
targetIndexrecord component
-
targetType
public int targetType()Returns the value of thetargetTyperecord component.- Returns:
- the value of the
targetTyperecord component
-
isMember
-
spotAnimId
public int spotAnimId()Returns the value of thespotAnimIdrecord component.- Returns:
- the value of the
spotAnimIdrecord component
-
currentHealth
public int currentHealth()Returns the value of thecurrentHealthrecord component.- Returns:
- the value of the
currentHealthrecord component
-
maxHealth
-
skills
-
orientation
Returns the value of theorientationrecord component.- Returns:
- the value of the
orientationrecord component
-