# HitResultHelper.Entity

`com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Entity`

**Since:** 1.9.1

A target that carries the entity and the hit location recorded by the hit result.  
```js
const interactions = Player.interactions();  
const target = interactions === null ? null : interactions.getTarget();  
if (target instanceof HitResults.Entity) {
  Chat.log(`the crosshair is on ${target.getEntity().getName()}`);  
}
```

Available in scripts as `HitResults.Entity`.

Nested type declared in [HitResultHelper](HitResultHelper.md).

## Constructors

### new HitResultHelper.Entity {#com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Entity_constructor-EntityHitResult-}

```js
new HitResultHelper.Entity(EntityHitResult base)
```

Wraps the supplied entity hit result.

**Parameters:**
- `base`: entity hit result to wrap

## Methods

### asEntity {#com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Entity_asEntity-}

```js
asEntity(): HitResultHelper.Entity
```

Returns this entity-hit helper.

**Returns:** this entity-hit helper

### getEntity {#com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Entity_getEntity-}

```js
getEntity(): EntityHelper<?>
```

The hit entity wrapped in its matching [EntityHelper](entity/EntityHelper.md) subtype.

**Returns:** the hit entity wrapped in its matching helper subtype.

**Since:** 1.9.1

### toString {#com.jsmacrosce.jsmacros.client.api.helper.world.HitResultHelper.Entity_toString-}

```js
toString(): String
```

Returns a diagnostic containing the hit position and entity type identifier.

**Returns:** a diagnostic with the position and the value from `EntityHelper.getType()`
