# BlockPosHelper

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

**Since:** 1.2.6

A block position with integer world coordinates. Movement methods return new positions and leave
this position unchanged; directional methods correspond to [offset(String, int)](#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_offset-String-int-).  
```js
const pos = PositionCommon.createBlockPos(10, 64, -3);  
Chat.log(`start ${pos.getX()}, ${pos.getY()}, ${pos.getZ()}`);  

const up = pos.up();  
const upThree = pos.up(3);  
Chat.log(`${up} and ${upThree}, while pos is still ${pos}`);  

Chat.log(`${pos.north(2)} equals ${pos.offset("north", 2)}`);   // true

Chat.log(pos.toPos3D());  
```

## Constructors

### new BlockPosHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_constructor-BlockPos-}

```js
new BlockPosHelper(BlockPos b)
```

Wraps the supplied block position, retaining it as the wrapped value.

**Parameters:**
- `b`: position to wrap

### new BlockPosHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_constructor-int-int-int-}

```js
new BlockPosHelper(int x, int y, int z)
```

Wraps a newly constructed block position from the supplied block coordinates.

**Parameters:**
- `x`: block x coordinate
- `y`: block y coordinate
- `z`: block z coordinate

## Methods

### distanceTo {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_distanceTo-EntityHelper-}

```js
distanceTo(EntityHelper<?> entity): double
```

Returns the Euclidean distance from this block's center to the entity's position.

**Parameters:**
- `entity`: the entity to get the distance to

**Returns:** the distance in blocks.

**Since:** 1.8.4

### distanceTo {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_distanceTo-BlockPosHelper-}

```js
distanceTo(BlockPosHelper pos): double
```

Returns the Euclidean distance between the two block positions, using their integer
coordinates without centering either block.

**Parameters:**
- `pos`: the position to get the distance to

**Returns:** the distance in blocks.

**Since:** 1.8.4

### distanceTo {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_distanceTo-Pos3D-}

```js
distanceTo(Pos3D pos): double
```

Returns the Euclidean distance from this block position's low corner to a point.

**Parameters:**
- `pos`: the point to measure to

**Returns:** the distance in blocks.

**Since:** 1.8.4

### distanceTo {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_distanceTo-double-double-double-}

```js
distanceTo(double x, double y, double z): double
```

Returns the Euclidean distance from this block position's low corner to the given point.

**Parameters:**
- `x`: the point's x coordinate
- `y`: the point's y coordinate
- `z`: the point's z coordinate

**Returns:** the distance in blocks.

**Since:** 1.8.4

### down {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_down-}

```js
down(): BlockPosHelper
```

Returns the position one block below this one, equivalent to `offset("down")`.

**Returns:** the position below this one.

**Since:** 1.6.5

### down {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_down-int-}

```js
down(int distance): BlockPosHelper
```

Returns a position moved by `distance` blocks downward; negative values move upward.

**Parameters:**
- `distance`: the signed distance to move

**Returns:** the resulting position.

**Since:** 1.6.5

### east {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_east-}

```js
east(): BlockPosHelper
```

Returns the adjacent block to the east (increasing `x`); equivalent to
`offset("east")`.

**Returns:** the block to the east.

**Since:** 1.6.5

### east {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_east-int-}

```js
east(int distance): BlockPosHelper
```

Returns a position moved by `distance` blocks to the east (increasing `x`).

**Parameters:**
- `distance`: the distance to move east

**Returns:** the position at the requested signed distance east of this one.

**Since:** 1.6.5

### equals {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_equals-Object-}

```js
equals(Object obj): boolean
```

Compares this helper with another helper by their wrapped positions; other object types,  
including `null`, are unequal.

**Parameters:**
- `obj`: object to compare

**Returns:** `true` if `obj` is a helper whose wrapped position compares equal

### getX {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_getX-}

```js
getX(): int
```

Returns the `x` coordinate in blocks.

**Returns:** the `x` coordinate.

**Since:** 1.2.6

### getY {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_getY-}

```js
getY(): int
```

Returns the `y` coordinate in blocks.

**Returns:** the `y` coordinate.

**Since:** 1.2.6

### getZ {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_getZ-}

```js
getZ(): int
```

Returns the `z` coordinate in blocks.

**Returns:** the `z` coordinate.

**Since:** 1.2.6

### hashCode {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_hashCode-}

```js
hashCode(): int
```

Returns the hash code delegated from the wrapped position.

**Returns:** the wrapped position's hash code

### north {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_north-}

```js
north(): BlockPosHelper
```

Returns the position one block north, equivalent to `offset("north")`. North is toward
decreasing `z`.

**Returns:** the position to the north.

**Since:** 1.6.5

### north {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_north-int-}

```js
north(int distance): BlockPosHelper
```

Returns a position moved `distance` blocks north (toward decreasing `z`).

**Parameters:**
- `distance`: the distance to move north

**Returns:** the resulting position.

**Since:** 1.6.5

### offset {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_offset-String-}

```js
offset(String direction): BlockPosHelper
```

Returns the adjacent position in the named direction. The name must be one of
`down`, `up`, `north`, `south`, `west`, or `east`.

**Parameters:**
- `direction`: one of `down`, `up`, `north`, `south`, `west`
                 or `east`.

**Returns:** the block offset by the given direction.

**Since:** 1.6.5

### offset {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_offset-String-int-}

```js
offset(String direction, int distance): BlockPosHelper
```

Returns a position moved `distance` blocks in the named direction; negative distances
move in the opposite direction. Direction names are the same as for [offset(String)](#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_offset-String-).

**Parameters:**
- `direction`: one of `down`, `up`, `north`, `south`, `west`
                 or `east`.
- `distance`: the distance to move in the given direction

**Returns:** the position at the requested signed distance in the given direction.

**Since:** 1.6.5

### offset {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_offset-int-int-int-}

```js
offset(int x, int y, int z): BlockPosHelper
```

Returns the position formed by adding the given coordinate offsets to this position.

**Parameters:**
- `x`: the x offset
- `y`: the y offset
- `z`: the z offset

**Returns:** the block offset by the given values.

**Since:** 1.8.4

### south {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_south-}

```js
south(): BlockPosHelper
```

Returns the adjacent block to the south (increasing `z`); equivalent to
`offset("south")`.

**Returns:** the block to the south.

**Since:** 1.6.5

### south {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_south-int-}

```js
south(int distance): BlockPosHelper
```

Returns a position moved by `distance` blocks to the south (increasing `z`).

**Parameters:**
- `distance`: the distance to move south

**Returns:** the position at the requested signed distance south of this one.

**Since:** 1.6.5

### toNetherCoords {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_toNetherCoords-}

```js
toNetherCoords(): BlockPosHelper
```

Converts coordinates by integer-dividing `x` and `z` by eight and leaving
`y` unchanged. Negative coordinates therefore truncate toward zero; this does not
locate or verify a portal.

**Returns:** the block position converted to the respective nether coordinates.

**Since:** 1.8.4

### toOverworldCoords {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_toOverworldCoords-}

```js
toOverworldCoords(): BlockPosHelper
```

Converts this position from Nether to Overworld coordinates by multiplying `x` and
`z` by eight and leaving `y` unchanged.

**Returns:** the converted Overworld position.

**Since:** 1.8.4

### toPos3D {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_toPos3D-}

```js
toPos3D(): Pos3D
```

Returns this position's integer coordinates as a point at the block's low corner.

**Returns:** this position represented as a [Pos3D](../../../../api/math/Pos3D.md).

**Since:** 1.8.4

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

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

Returns a diagnostic string in the format `BlockPosHelper:{"x": %d, "y": %d, "z": %d}`,  
with the coordinate getters' values substituted in x/y/z order.

**Returns:** the formatted diagnostic string

### up {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_up-}

```js
up(): BlockPosHelper
```

Returns the position one block above this one, equivalent to `offset("up")`.

**Returns:** the position above this one.

**Since:** 1.6.5

### up {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_up-int-}

```js
up(int distance): BlockPosHelper
```

Returns a position moved by `distance` blocks upward; negative values move downward.

**Parameters:**
- `distance`: the signed distance to move

**Returns:** the resulting position.

**Since:** 1.6.5

### west {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_west-}

```js
west(): BlockPosHelper
```

Returns the adjacent block to the west (decreasing `x`); equivalent to
`offset("west")`.

**Returns:** the block to the west.

**Since:** 1.6.5

### west {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper_west-int-}

```js
west(int distance): BlockPosHelper
```

Returns a position moved by `distance` blocks to the west (decreasing `x`).

**Parameters:**
- `distance`: the distance to move west

**Returns:** the position at the requested signed distance west of this one.

**Since:** 1.6.5
