Skip to content

PlayerEntityHelper ​

com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper

Provides player-specific entity data, including experience, score, and sleep state.
Equipment accessors are inherited in behavior from LivingEntityHelper; the player overrides return those same six hand and armor slots, not additional slots.

A player helper from an entity list is an EntityHelpers.Player; the local player is also an EntityHelpers.ClientPlayer.

js
// the local player, which is the only one a client has any business with
const player = Player.getPlayer();  
if (player !== null) {
 Chat.log(`${player.getPlayerName()} on ${player.getXPLevel()} `
   + `(${player.getXP()} xp total), score ${player.getScore()}`);  
}

Available in scripts as EntityHelpers.Player.

Type Parameters ​

  • T: the player entity type wrapped by this helper

Constructors ​

new PlayerEntityHelper ​

new PlayerEntityHelper(T extends Player e)#
Wraps the supplied player entity and retains that reference.

Parameters:

  • e: the player entity to wrap

Methods ​

getAbilities ​

getAbilities(): PlayerAbilitiesHelperSince1.0.3#
Returns a helper wrapping this player's abilities object; setter calls modify that object.
Returns: a wrapper on this player's abilities

getAttackCooldownProgress ​

getAttackCooldownProgress(): floatSince1.8.4#
the player's attack cooldown progress, clamped to the range 0.0 to 1.0.
Returns: the attack charge as a fraction from zero to one

getAttackCooldownProgressPerTick ​

getAttackCooldownProgressPerTick(): floatSince1.8.4#
the number of ticks in a full attack cooldown, calculated from the player's attack speed attribute.
Returns: the number of ticks a full attack charge takes

getChestArmor ​

getChestArmor(): ItemStackHelperSince1.2.0#
Returns the player's chest-armor-slot stack.
Returns: the player's chest-armor-slot item stack, empty when the slot is empty

getFishingBobber ​

getFishingBobber(): FishingBobberEntityHelperSince1.8.4#
this player's fishing bobber, or null when none is attached. The returned wrapper refers to that bobber entity; this works for local and other players.
Returns: the fishing bobber of the player, or null if the player is not fishing.

getFootArmor ​

getFootArmor(): ItemStackHelperSince1.2.0#
Returns the player's boots-slot stack.
Returns: the player's boots-slot item stack, empty when the slot is empty

getHeadArmor ​

getHeadArmor(): ItemStackHelperSince1.2.0#
Returns the player's helmet-slot stack.
Returns: the player's helmet-slot item stack, empty when the slot is empty

getLegArmor ​

getLegArmor(): ItemStackHelperSince1.2.0#
Returns the player's leggings-slot stack.
Returns: the player's leggings-slot item stack, empty when the slot is empty

getMainHand ​

getMainHand(): ItemStackHelperSince1.2.0#
Returns the player's main-hand stack.
Returns: the player's main-hand item stack, empty when the hand is empty

getOffHand ​

getOffHand(): ItemStackHelperSince1.2.0#
Returns the player's off-hand stack.
Returns: the player's off-hand item stack, empty when the hand is empty

getPlayerName ​

getPlayerName(): StringSince1.8.4#
Returns the account name from the player's game profile, rather than the entity's display name.
Returns: the player's account name, not its display name

getScore ​

getScore(): intSince1.8.4#
the integer score stored on the player entity.
Returns: the player's score

getXP ​

getXP(): intSince1.2.5#
Returns the player's accumulated total experience points, distinct from current-level progress.
Returns: the total experience the player has collected

getXPLevel ​

getXPLevel(): intSince1.6.5#
the player's current experience level.
Returns: the player's experience level

getXPProgress ​

getXPProgress(): floatSince1.6.5#
the player's progress through the current experience level, as a fraction of the level's total cost.
Returns: the fraction of the current level the player has filled

getXPToLevelUp ​

getXPToLevelUp(): intSince1.6.5#
the total experience-point cost of the next level, determined by the player's current level, not the points remaining in it.
Returns: the experience needed to reach the next level

isSleeping ​

isSleeping(): booleanSince1.2.6#
whether the player is currently sleeping.
Returns: true if the player is asleep, false otherwise.

isSleepingLongEnough ​

isSleepingLongEnough(): booleanSince1.2.6#
whether the player is sleeping and has met the game's 100-tick sleep threshold.
Returns: if the player has slept the minimum amount of time to pass the night.