# 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](LivingEntityHelper.md); 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 {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_constructor-T-}

```js
new PlayerEntityHelper(T extends Player e)
```

Wraps the supplied player entity and retains that reference.

**Parameters:**
- `e`: the player entity to wrap

## Methods

### getAbilities {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getAbilities-}

```js
getAbilities(): PlayerAbilitiesHelper
```

Returns a helper wrapping this player's abilities object; setter calls modify that object.

**Returns:** a wrapper on this player's abilities

**Since:** 1.0.3

### getAttackCooldownProgress {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getAttackCooldownProgress-}

```js
getAttackCooldownProgress(): float
```

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

**Since:** 1.8.4

### getAttackCooldownProgressPerTick {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getAttackCooldownProgressPerTick-}

```js
getAttackCooldownProgressPerTick(): float
```

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

**Since:** 1.8.4

### getChestArmor {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getChestArmor-}

```js
getChestArmor(): ItemStackHelper
```

Returns the player's chest-armor-slot stack.

**Returns:** the player's chest-armor-slot item stack, empty when the slot is empty

**Since:** 1.2.0

### getFishingBobber {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getFishingBobber-}

```js
getFishingBobber(): FishingBobberEntityHelper
```

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.

**Since:** 1.8.4

### getFootArmor {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getFootArmor-}

```js
getFootArmor(): ItemStackHelper
```

Returns the player's boots-slot stack.

**Returns:** the player's boots-slot item stack, empty when the slot is empty

**Since:** 1.2.0

### getHeadArmor {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getHeadArmor-}

```js
getHeadArmor(): ItemStackHelper
```

Returns the player's helmet-slot stack.

**Returns:** the player's helmet-slot item stack, empty when the slot is empty

**Since:** 1.2.0

### getLegArmor {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getLegArmor-}

```js
getLegArmor(): ItemStackHelper
```

Returns the player's leggings-slot stack.

**Returns:** the player's leggings-slot item stack, empty when the slot is empty

**Since:** 1.2.0

### getMainHand {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getMainHand-}

```js
getMainHand(): ItemStackHelper
```

Returns the player's main-hand stack.

**Returns:** the player's main-hand item stack, empty when the hand is empty

**Since:** 1.2.0

### getOffHand {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getOffHand-}

```js
getOffHand(): ItemStackHelper
```

Returns the player's off-hand stack.

**Returns:** the player's off-hand item stack, empty when the hand is empty

**Since:** 1.2.0

### getPlayerName {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getPlayerName-}

```js
getPlayerName(): String
```

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

**Since:** 1.8.4

### getScore {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getScore-}

```js
getScore(): int
```

the integer score stored on the player entity.

**Returns:** the player's score

**Since:** 1.8.4

### getXP {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getXP-}

```js
getXP(): int
```

Returns the player's accumulated total experience points, distinct from current-level progress.

**Returns:** the total experience the player has collected

**Since:** 1.2.5

### getXPLevel {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getXPLevel-}

```js
getXPLevel(): int
```

the player's current experience level.

**Returns:** the player's experience level

**Since:** 1.6.5

### getXPProgress {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getXPProgress-}

```js
getXPProgress(): float
```

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

**Since:** 1.6.5

### getXPToLevelUp {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_getXPToLevelUp-}

```js
getXPToLevelUp(): int
```

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

**Since:** 1.6.5

### isSleeping {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_isSleeping-}

```js
isSleeping(): boolean
```

whether the player is currently sleeping.

**Returns:** `true` if the player is asleep, `false` otherwise.

**Since:** 1.2.6

### isSleepingLongEnough {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.PlayerEntityHelper_isSleepingLongEnough-}

```js
isSleepingLongEnough(): boolean
```

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.

**Since:** 1.2.6
