# DirectionHelper

`com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper`

**Since:** 1.8.4

A helper for one of Minecraft's six cardinal directions. Directions can be queried for their
axis and angles, converted to a one-block vector, or turned; the quarter-turn methods reject
vertical directions.  
```js
// whichever way the player is looking
const player = Player.getPlayer();  
const facing = player.getFacingDirection();  
Chat.log(`${facing.getName()} is on the ${facing.getAxis()} axis at yaw ${facing.getYaw()}`);  

// turning a direction gives a new one, never a change to the old
const behind = facing.getOpposite();  
Chat.log(`${facing.getName()} is ahead, ${behind.getName()} is behind`);  

// and a direction is also the one block step it stands for
const step = facing.getVector();  
Chat.log(`one block that way is ${step.getX()}, ${step.getY()}, ${step.getZ()}`);  
```

## Constructors

### new DirectionHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_constructor-Direction-}

```js
new DirectionHelper(Direction base)
```

Wraps the supplied direction for helper access.

**Parameters:**
- `base`: the direction to wrap

## Methods

### getAxis {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getAxis-}

```js
getAxis(): String
```

Returns the axis name (`x`, `y`, or `z`) of this direction.

**Returns:** the name of the axis this direction is aligned to.

**Since:** 1.8.4

### getLeft {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getLeft-}

```js
getLeft(): DirectionHelper
```

Returns the horizontal direction one quarter turn anticlockwise from this one. Vertical
directions cannot be turned and cause an [IllegalStateException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html).

**Returns:** the direction to the left.

**Since:** 1.8.4

### getName {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getName-}

```js
getName(): String
```

Returns the lowercase serialized name of this direction, such as `north`.

**Returns:** the name of this direction.

**Since:** 1.8.4

### getOpposite {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getOpposite-}

```js
getOpposite(): DirectionHelper
```

Returns the direction opposite this one, including for vertical directions.

**Returns:** the opposite direction.

**Since:** 1.8.4

### getPitch {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getPitch-}

```js
getPitch(): float
```

Returns this direction's pitch in degrees: zero for horizontal directions and `-90`
or `90` for vertical directions.

**Returns:** the pitch of this direction.

**Since:** 1.8.4

### getRight {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getRight-}

```js
getRight(): DirectionHelper
```

Returns the horizontal direction one quarter turn clockwise from this one. Vertical
directions cannot be turned and cause an [IllegalStateException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html).

**Returns:** the direction to the right.

**Since:** 1.8.4

### getVector {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getVector-}

```js
getVector(): Pos3D
```

Returns this direction's one-block offset: one coordinate is `1` or `-1`, and
the other two are zero.

**Returns:** the direction as a directional vector.

**Since:** 1.8.4

### getYaw {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_getYaw-}

```js
getYaw(): float
```

Returns this direction's yaw in degrees. Vertical directions share a yaw value, so it is
meaningful as a heading only for horizontal directions.

**Returns:** the yaw of this direction.

**Since:** 1.8.4

### isHorizontal {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_isHorizontal-}

```js
isHorizontal(): boolean
```

Returns whether this direction is horizontal (aligned with the `x` or `z` axis).

**Returns:** `true` if this direction is horizontal, `false` otherwise.

**Since:** 1.8.4

### isTowardsPositive {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_isTowardsPositive-}

```js
isTowardsPositive(): boolean
```

Returns whether this direction points toward increasing coordinates on its axis.

**Returns:** `true` if this direction is pointing in a positive direction, `false`
otherwise.

**Since:** 1.8.4

### isVertical {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_isVertical-}

```js
isVertical(): boolean
```

Returns whether this direction is vertical (aligned with the `y` axis).

**Returns:** `true` if this direction is vertical, `false` otherwise.

**Since:** 1.8.4

### pointsTo {#com.jsmacrosce.jsmacros.client.api.helper.world.DirectionHelper_pointsTo-double-}

```js
pointsTo(double yaw): boolean
```

Tests whether `yaw` points into this direction's horizontal half-plane. Vertical
directions always return `false`; an exact boundary between directions also returns
`false`.

**Parameters:**
- `yaw`: the yaw to check

**Returns:** `true` when the yaw points into this direction's horizontal half-plane;  
        `false` otherwise.

**Since:** 1.8.4

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

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

Returns a diagnostic representation of the wrapped direction.

**Returns:** a diagnostic representation containing the direction's name, yaw, and pitch
