# LivingEntityHelper

`com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper`

Adds living-entity state, such as health, equipment, and status effects, to an entity
 helper.  
 
 Values reflect the client's current entity state; this helper does not modify it.  
 
 `asLiving()` on an entity helper is a cast, not a type check; it throws if the
 helper does not wrap a living entity. Use `instanceof EntityHelpers.Living`, or a
 type-filtered entity query, when narrowing from an unfiltered entity list.  
 ```js
// the living things within twenty blocks, and their health
const mobs = World.getEntities(20, "zombie", "skeleton", "creeper", "cow");  
if (mobs !== null) {
  for (const entity of mobs) {
    if (!(entity instanceof EntityHelpers.Living)) continue;  
    Chat.log(`${entity.getType()}: ${entity.getHealth()} of ${entity.getMaxHealth()}`);  
  }
}
 ```

Available in scripts as `EntityHelpers.Living`.

## Type Parameters

- `T`: the living entity wrapped by this helper

## Constructors

### new LivingEntityHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_constructor-T-}

```js
new LivingEntityHelper(T extends LivingEntity e)
```

Wraps the supplied living entity, retaining the same entity reference.

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

## Methods

### canBreatheInWater {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canBreatheInWater-}

```js
canBreatheInWater(): boolean
```

whether the entity can breathe underwater according to its entity behavior; this
 does not account for breathing equipment.

**Returns:** if the entity can breathe in water

**Since:** 1.8.4

### canHaveStatusEffect {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canHaveStatusEffect-StatusEffectHelper-}

```js
canHaveStatusEffect(StatusEffectHelper effect): boolean
```

Checks whether Minecraft considers this entity eligible for the given effect;  
 this does not check whether the effect is currently active.

**Parameters:**
- `effect`: the status effect

**Returns:** `true` if the entity can be affected by the effect

**Since:** 1.8.4

### canSeeEntity {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canSeeEntity-EntityHelper-}

```js
canSeeEntity(EntityHelper<?> entity): boolean
```

Checks line of sight using only the three-point raycast; it does not perform the extended search available through [canSeeEntity(EntityHelper, boolean)](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canSeeEntity-EntityHelper-boolean-).

**Parameters:**
- `entity`: the entity to check line of sight to

**Returns:** `true` if the player has line of sight to the specified entity, `false`
 otherwise.

**Since:** 1.8.4

### canSeeEntity {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canSeeEntity-EntityHelper-boolean-}

```js
canSeeEntity(EntityHelper<?> entity, boolean simpleCast): boolean
```

Checks three target points first. If `simpleCast` is false and those fail, also raycasts to four side positions at 0.1-block vertical intervals, starting at the target's base; the upper remainder may be unsampled. These checks use visual-block raycasts and ignore fluids.

**Parameters:**
- `entity`: the entity to check line of sight to
- `simpleCast`: whether to use a simple raycast or a more complex one

**Returns:** `true` if a tested ray misses visual-block collisions

**Since:** 1.8.4

### canTakeDamage {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canTakeDamage-}

```js
canTakeDamage(): boolean
```

whether the entity passes the game's enemy-visibility check: it must not be
 invulnerable, must not be a spectator, and must be alive. This is not a guarantee
 that every damage source can hurt it.

**Returns:** if the entity can take damage

**Since:** 1.8.4

### canTarget {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canTarget-LivingEntityHelper-}

```js
canTarget(LivingEntityHelper<?> target): boolean
```

whether the game permits this entity to attack the target. This is an eligibility
 check, not an indication that the entity wants to attack; players are not attackable
 in peaceful difficulty.

**Parameters:**
- `target`: the target entity

**Returns:** if the entity can target a target entity

**Since:** 1.8.4

### getAbsorptionHealth {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getAbsorptionHealth-}

```js
getAbsorptionHealth(): float
```

the entity's absorption amount, which absorbs damage before health.

**Returns:** the entity's absorption amount.

**Since:** 1.8.4

### getArmor {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getArmor-}

```js
getArmor(): int
```

the entity's armor value as used by the game's damage calculation.

**Returns:** the entity's armor value.

**Since:** 1.8.4

### getArmorToughness {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getArmorToughness-}

```js
getArmorToughness(): double
```

the entity's armor-toughness attribute value.

**Returns:** the entity's armor toughness.

**Since:** 2.1.0

### getBowPullProgress {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getBowPullProgress-}

```js
getBowPullProgress(): double
```

Returns the bow draw power for the item in the entity's main hand, or `0` if it is not a bow.

**Returns:** the bow pull progress of the entity, `0` by default.

**Since:** 1.8.4

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

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

Returns the stack in the chest armor slot; an empty slot is represented by an
 empty stack.

**Returns:** the item in the entity's chest armor slot.

**Since:** 1.2.7

### getDefaultHealth {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getDefaultHealth-}

```js
getDefaultHealth(): float
```

Returns a version-dependent value under this legacy method name: in Minecraft
 1.21.8, the entity's invulnerability duration; from 1.21.11, its maximum health.

**Returns:** the version-dependent value described above

**Since:** 1.8.4

**Note:** returns float since 2.0.0

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

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

the item in the entity's boots slot, or an empty stack if the slot is empty.

**Returns:** the item in the entity's foot armor slot.

**Since:** 1.2.7

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

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

Returns the stack in the head armor slot; an empty slot is represented by an
 empty stack.

**Returns:** the item in the entity's head armor slot.

**Since:** 1.2.7

### getHealth {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getHealth-}

```js
getHealth(): float
```

the entity's current health, on the same scale as [getMaxHealth()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getMaxHealth-). For
 entities observed by the client, this is the latest value synchronized to it.

**Returns:** entity's health

**Since:** 1.3.1

### getItemUseTimeLeft {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getItemUseTimeLeft-}

```js
getItemUseTimeLeft(): int
```

Returns the remaining use duration of the entity's currently used item, in ticks; zero when not using an item.

**Returns:** the ticks left of using the held item

**Since:** 1.9.0

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

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

the item in the entity's leggings slot, or an empty stack if the slot is empty.

**Returns:** the item in the entity's leg armor slot.

**Since:** 1.2.7

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

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

Returns the main-hand stack; an empty hand is represented by an empty stack,  
 not `null`.

**Returns:** the item in the entity's main hand.

**Since:** 1.2.7

### getMaxHealth {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getMaxHealth-}

```js
getMaxHealth(): float
```

the entity's maximum health, which sets the upper bound for [getHealth()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getHealth-).

**Returns:** entity's max health

**Since:** 1.6.5

### getMobTags {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getMobTags-}

```js
getMobTags(): List<String>
```

the tags on this kind of entity rather than on this one entity, which is what the
 game's own entity type registry carries. A tag is a group the entity type is in,  
 such as the one the game uses to find the undead, so two entities of the same type
 give the same list whatever has happened to them.  
 
 The entries are tag ids as strings with the namespace on the front. This is the
 list [isUndead()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isUndead-) is answered from, rather than a check run here.

**Returns:** the tags on this entity's type

**Since:** 1.9.1

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

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

Returns the off-hand stack; an empty slot is represented by an empty stack.

**Returns:** the item in the entity's off hand.

**Since:** 1.2.7

### getStatusEffects {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_getStatusEffects-}

```js
getStatusEffects(): List<StatusEffectHelper>
```

Returns a new list of the entity's active status effects.

**Returns:** the entity's active status effects

**Since:** 1.2.7

### hasNoDrag {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_hasNoDrag-}

```js
hasNoDrag(): boolean
```

whether the entity is configured to discard friction; this reports a flag, not its
 current motion.

**Returns:** if the entity has no drag

**Since:** 1.8.4

### hasNoGravity {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_hasNoGravity-}

```js
hasNoGravity(): boolean
```

whether the entity is configured to ignore gravity; this reports a flag, not
 whether it is currently falling.

**Returns:** if the entity has no gravity

**Since:** 1.8.4

### hasStatusEffect {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_hasStatusEffect-String-}

```js
hasStatusEffect(String id): boolean
```

Checks the client's active-effect list for the given effect ID. For remote
 entities, this reflects only effects present in the client-side state.

**Parameters:**
- `id`: the id of the status effect to look for

**Returns:** `true` if an active effect has this ID; `false` otherwise

**Since:** 1.8.4

### isBaby {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isBaby-}

```js
isBaby(): boolean
```

Returns the entity's baby state as reported by Minecraft.

**Returns:** `true` if the entity is a baby, `false` otherwise.

**Since:** 1.8.4

### isFallFlying {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isFallFlying-}

```js
isFallFlying(): boolean
```

whether the entity is currently fall-flying; this reports flight state, not merely
 whether it has an elytra equipped.

**Returns:** if the entity has elytra deployed

**Since:** 1.5.0

### isHolding {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isHolding-String-}

```js
isHolding(String item): boolean
```

Checks whether either hand holds the item with this ID. The namespace may be
 omitted and defaults to `minecraft`; the air ID checks for an empty hand.

**Parameters:**
- `item`: the id of the item to look for

**Returns:** `true` if either hand holds the item; `false` otherwise

**Since:** 1.9.0

### isOnGround {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isOnGround-}

```js
isOnGround(): boolean
```

whether the entity's on-ground flag is set; this is not a direct check of the block
 beneath it.

**Returns:** if the entity is on the ground

**Since:** 1.8.4

### isPartOfGame {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isPartOfGame-}

```js
isPartOfGame(): boolean
```

whether the entity is alive and not a spectator. Unlike [canTakeDamage()](#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_canTakeDamage-),  
 this does not also check invulnerability.

**Returns:** if the entity is part of the game (is alive and not spectator)

**Since:** 1.8.4

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

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

whether the entity has a sleeping position. This indicates sleeping state, not
 how long it has been asleep.

**Returns:** if the entity is in a bed.

**Since:** 1.2.7

### isSpectator {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isSpectator-}

```js
isSpectator(): boolean
```

whether the entity is in spectator mode.

**Returns:** if the entity is in spectator

**Since:** 1.8.4

### isUndead {#com.jsmacrosce.jsmacros.client.api.helper.world.entity.LivingEntityHelper_isUndead-}

```js
isUndead(): boolean
```

Returns whether this entity's type belongs to the game's undead entity-type tag.

**Returns:** if the entity is undead

**Since:** 1.8.4
