[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/portal/gateway

# world/portal/gateway

## Interfaces

### ExitPlan

Defined in: [packages/prismarine/src/world/portal/gateway.ts:281](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L281)

What the search decided for a gateway with no exit yet.

#### Properties

##### island

> `readonly` **island**: [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition) \| `undefined`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:283](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L283)

Where an island has to be built first, when the chunk held no end stone to land on.

##### spawn

> `readonly` **spawn**: [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:285](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L285)

The block the return gateway is measured from: the end stone found, or the island's center.

***

### GatewayBlock

Defined in: [packages/prismarine/src/world/portal/gateway.ts:76](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L76)

A block as the search reads one.

#### Properties

##### fullBlock

> `readonly` **fullBlock**: `boolean`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:79](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L79)

Java's `isCollisionShapeFullBlock`: whether the block's collision fills its cell.

##### name

> `readonly` **name**: `string`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:77](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L77)

***

### GatewayTerrain

Defined in: [packages/prismarine/src/world/portal/gateway.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L83)

The End as the search reads it.

#### Properties

##### maxY

> `readonly` **maxY**: `number`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:91](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L91)

The highest y of the dimension, inclusive: Java's `LevelHeightAccessor.getMaxY`.

###### Java See

LevelHeightAccessor.getMaxY

##### minY

> `readonly` **minY**: `number`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:85](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L85)

The lowest y of the dimension.

#### Methods

##### blockAt()

> **blockAt**(`x`, `y`, `z`): [`GatewayBlock`](#gatewayblock) \| `undefined`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:93](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L93)

The block at a position, or undefined where the chunk is not loaded.

###### Parameters

###### x

`number`

###### y

`number`

###### z

`number`

###### Returns

[`GatewayBlock`](#gatewayblock) \| `undefined`

##### chunkTopY()

> **chunkTopY**(`x`, `z`): `number` \| `undefined`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:110](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L110)

The top y of a loaded chunk's highest section that holds a block, Java's
`getHighestSectionPosition() + 16 - 1`, or undefined for a chunk that is not loaded. An
empty chunk answers the top of its lowest section, since Java's highest section position is
then the chunk's minimum y.

###### Parameters

###### x

`number`

###### z

`number`

###### Returns

`number` \| `undefined`

##### columnTop()

> **columnTop**(`x`, `z`): `number` \| `undefined`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:98](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L98)

One past the highest y a loaded column can hold a block at, which lets the scan for the
tallest block skip the air above it. Undefined where the chunk is not loaded.

###### Parameters

###### x

`number`

###### z

`number`

###### Returns

`number` \| `undefined`

##### isChunkEmpty()

> **isChunkEmpty**(`x`, `z`): `boolean` \| `undefined`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:103](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L103)

Whether a loaded chunk holds nothing but air, Java's `getHighestFilledSectionIndex() == -1`,
or undefined for a chunk that is not loaded.

###### Parameters

###### x

`number`

###### z

`number`

###### Returns

`boolean` \| `undefined`

***

### HorizontalPoint

Defined in: [packages/prismarine/src/world/portal/gateway.ts:70](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L70)

A horizontal point, the walk's `Vec3` with its y left at 0.

#### Properties

##### x

> `readonly` **x**: `number`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:71](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L71)

##### z

> `readonly` **z**: `number`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:72](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L72)

***

### MissingChunk

Defined in: [packages/prismarine/src/world/portal/gateway.ts:114](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L114)

What a step of the search lacks: a chunk that has to be loaded before it can go on.

#### Properties

##### missing

> `readonly` **missing**: [`ChunkCoordinate`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/ChunkTickets/index.md#chunkcoordinate)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:115](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L115)

## Variables

### EXIT\_POSITION\_RADIUS

> `const` **EXIT\_POSITION\_RADIUS**: `5` = `5`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:61](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L61)

`findExitPosition`'s `iconst_5`: the radius around a known exit a traveler is set down in.

***

### EXIT\_SEARCH\_DISTANCE

> `const` **EXIT\_SEARCH\_DISTANCE**: `1024` = `1024`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L43)

`findExitPortalXZPosTentative`'s `sipush 1024`: how far out the walk starts.

***

### EXIT\_SEARCH\_STEPS

> `const` **EXIT\_SEARCH\_STEPS**: `16` = `16`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:49](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L49)

How many steps each half of the walk may take (`bipush 16`).

***

### GATEWAY\_BEAM\_EVENT

> `const` **GATEWAY\_BEAM\_EVENT**: `object`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:40](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L40)

The block event a gateway raises when it is used, which a client draws as the beam: event 1,
value 0.

#### Type Declaration

##### type

> `readonly` **type**: `1` = `1`

##### value

> `readonly` **value**: `0` = `0`

#### Java See

TheEndGatewayBlockEntity.triggerCooldown

***

### GATEWAY\_COOLDOWN\_TICKS

> `const` **GATEWAY\_COOLDOWN\_TICKS**: `40` = `40`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L25)

How long a gateway's beam shows after a use, and how long it refuses the next traveler.

#### Java Source

TheEndGatewayBlockEntity.COOLDOWN_TIME

***

### GATEWAY\_HEIGHT\_ABOVE\_SURFACE

> `const` **GATEWAY\_HEIGHT\_ABOVE\_SURFACE**: `10` = `10`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:32](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L32)

How far above the tallest block near the exit the return gateway stands.

#### Java Source

TheEndGatewayBlockEntity.GATEWAY_HEIGHT_ABOVE_SURFACE

***

### ISLAND\_Y

> `const` **ISLAND\_Y**: `75` = `75`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:55](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L55)

`findOrCreateValidTeleportPos`'s `ldc2_w double 75`: the height of an island it has to build.

***

### MIN\_SPAWN\_Y

> `const` **MIN\_SPAWN\_Y**: `30` = `30`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L52)

`findValidSpawnInChunk`'s `bipush 30`: the lowest end stone it lands on.

***

### PLAN\_RADIUS

> `const` **PLAN\_RADIUS**: `number`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:310](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L310)

The radius around a plan's spawn that the rest of the exit search reads and writes.

***

### SPAWN\_SEARCH\_RADIUS

> `const` **SPAWN\_SEARCH\_RADIUS**: `16` = `16`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:58](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L58)

`findOrCreateValidTeleportPos`'s `bipush 16`: the radius it looks for a taller block in.

## Functions

### blockPosAsLong()

> **blockPosAsLong**(`__namedParameters`): `bigint`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:333](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L333)

Java's `BlockPos.asLong`: 26 bits of x from bit 38, 26 bits of z from bit 12 and 12 bits of y,
which Java seeds the island's random with.

#### Parameters

##### \_\_namedParameters

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

#### Returns

`bigint`

#### Java Source

BlockPos.asLong(III)J

***

### chunkOfPoint()

> **chunkOfPoint**(`__namedParameters`): [`ChunkCoordinate`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/ChunkTickets/index.md#chunkcoordinate)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:119](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L119)

The chunk a walk position is in, Java's `getChunk(level, vec)`: `Mth.floor(x / 16)`.

#### Parameters

##### \_\_namedParameters

[`HorizontalPoint`](#horizontalpoint)

#### Returns

[`ChunkCoordinate`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/ChunkTickets/index.md#chunkcoordinate)

***

### exitSearchChunks()

> **exitSearchChunks**(`gateway`): [`ChunkCoordinate`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/ChunkTickets/index.md#chunkcoordinate)[]

Defined in: [packages/prismarine/src/world/portal/gateway.ts:145](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L145)

Every chunk the walk out from a gateway can read, whatever the chunks hold.

The walk goes back up to sixteen steps from 1024 blocks out, then forward up to sixteen from
wherever it stopped, so these are the chunks of each of those positions, summed the way the
walk sums them. Asking for all of them at once lets the walk run in one step once they are in,
rather than load one chunk per step.

#### Parameters

##### gateway

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

#### Returns

[`ChunkCoordinate`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/ChunkTickets/index.md#chunkcoordinate)[]

***

### findExitPortalXZPosTentative()

> **findExitPortalXZPosTentative**(`terrain`, `gateway`): [`HorizontalPoint`](#horizontalpoint) \| [`MissingChunk`](#missingchunk)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:174](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L174)

Java's `findExitPortalXZPosTentative`: from 1024 blocks out along the gateway's direction,
steps back a chunk at a time while the chunk holds blocks, then forward while it holds none,
at most sixteen steps each way.

#### Parameters

##### terrain

`Pick`\<[`GatewayTerrain`](#gatewayterrain), `"isChunkEmpty"`\>

##### gateway

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

#### Returns

[`HorizontalPoint`](#horizontalpoint) \| [`MissingChunk`](#missingchunk)

The point the walk stopped at, or the chunk it needs next when that chunk is not loaded.

#### Java Source

TheEndGatewayBlockEntity.findExitPortalXZPosTentative

***

### findExitPosition()

> **findExitPosition**(`terrain`, `exit`): [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:275](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L275)

Java's `findExitPosition`: where a traveler through a gateway with a known exit stands, on the
tallest block within five columns of it that is not bedrock, which keeps them off the return
gateway's own frame.

#### Parameters

##### terrain

[`GatewayTerrain`](#gatewayterrain)

##### exit

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

#### Returns

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

#### Java Source

TheEndGatewayBlockEntity.findExitPosition

***

### findTallestBlock()

> **findTallestBlock**(`terrain`, `around`, `radius`, `allowBedrock`): [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:242](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L242)

Java's `findTallestBlock`: the highest full block in the square of columns around a position,
the first one found winning a tie. The center column counts only when bedrock does.

#### Parameters

##### terrain

[`GatewayTerrain`](#gatewayterrain)

##### around

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

##### radius

`number`

##### allowBedrock

`boolean`

Whether bedrock counts, and with it the center column.

#### Returns

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

The block, or the position itself when no column holds a full block.

#### Java Source

TheEndGatewayBlockEntity.findTallestBlock

***

### findValidSpawnInChunk()

> **findValidSpawnInChunk**(`terrain`, `chunk`): [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition) \| `undefined`

Defined in: [packages/prismarine/src/world/portal/gateway.ts:211](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L211)

Java's `findValidSpawnInChunk`: the end stone block from y 30 up to the chunk's highest
section with two blocks of room above it that is nearest the origin. Ties go to the first in
`BlockPos.betweenClosed` order, which [betweenClosed](https://jsprismarine.dev/api/@jsprismarine/features/index.md#betweenclosed) walks. `betweenClosed` takes the
smaller and the larger of each pair of corners, so a chunk whose blocks all lie below y 30 is
searched from its top section up to 30 instead.

#### Parameters

##### terrain

[`GatewayTerrain`](#gatewayterrain)

##### chunk

[`ChunkCoordinate`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/ChunkTickets/index.md#chunkcoordinate)

The chunk to search, which must be loaded.

#### Returns

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition) \| `undefined`

The block, or undefined when the chunk has none, as for a chunk of the void.

#### Java Source

TheEndGatewayBlockEntity.findValidSpawnInChunk

***

### planExit()

> **planExit**(`terrain`, `gateway`): [`MissingChunk`](#missingchunk) \| [`ExitPlan`](#exitplan)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:295](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L295)

The first half of Java's `findOrCreateValidTeleportPos`: the walk, then the spawn in the chunk
it stopped in, or the island it has to build at y 75 when there is none.

#### Parameters

##### terrain

[`GatewayTerrain`](#gatewayterrain)

##### gateway

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

#### Returns

[`MissingChunk`](#missingchunk) \| [`ExitPlan`](#exitplan)

The plan, or the chunk the walk needs next.

#### Java Source

TheEndGatewayBlockEntity.findOrCreateValidTeleportPos

***

### returnGatewayOf()

> **returnGatewayOf**(`terrain`, `plan`): [`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

Defined in: [packages/prismarine/src/world/portal/gateway.ts:322](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/gateway.ts#L322)

The second half of `findOrCreateValidTeleportPos` and the rest of `getPortalPosition`: the
tallest block within sixteen columns of the spawn, bedrock and the center column counted, and
the return gateway ten blocks above it.

Read after the island is built, since the island is what the scan finds.

#### Parameters

##### terrain

[`GatewayTerrain`](#gatewayterrain)

##### plan

[`ExitPlan`](#exitplan)

#### Returns

[`BlockPosition`](https://jsprismarine.dev/api/@jsprismarine/blocks/index.md#blockposition)

Where the return gateway stands, which is the source gateway's new exit.

#### Java Source

TheEndGatewayBlockEntity.getPortalPosition
