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

# world/portal/rules

## Interfaces

### DimensionTravelRule

Defined in: [packages/prismarine/src/world/portal/rules.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L37)

What one dimension type allows a traveler to do.

#### Properties

##### allowsNetherPortal

> `readonly` **allowsNetherPortal**: `boolean`

Defined in: [packages/prismarine/src/world/portal/rules.ts:47](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L47)

Whether a nether portal can exist here: Java's `BaseFireBlock.inPortalDimension`, which
is true for the Overworld and the Nether only. Nothing creates a portal where this is
false.

###### Java See

BaseFireBlock.inPortalDimension

##### portalSearchRadius

> `readonly` **portalSearchRadius**: `number`

Defined in: [packages/prismarine/src/world/portal/rules.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L39)

Radius of the search for an existing portal around the scaled target, in blocks.

***

### PortalRule

Defined in: [packages/prismarine/src/world/portal/rules.ts:84](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L84)

What a portal block does to whoever stands in it.

#### Properties

##### delayTicks

> `readonly` **delayTicks**: `object`

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

Ticks a player stands in the portal before the trip, by game mode. Java's
`players_nether_portal_default_delay` (80) and `players_nether_portal_creative_delay`
(0) game rules; `EndPortalBlock` keeps `Portal.getPortalTransitionTime`'s default of 0.
Everything that is not a player goes through on the first tick either way.

###### creative

> `readonly` **creative**: `number`

###### survival

> `readonly` **survival**: `number`

##### frame

> `readonly` **frame**: readonly `string`[]

Defined in: [packages/prismarine/src/world/portal/rules.ts:92](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L92)

The blocks the portal's frame is made of.

##### kind

> `readonly` **kind**: `"end"` \| `"nether"` \| `"gateway"`

Defined in: [packages/prismarine/src/world/portal/rules.ts:90](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L90)

A nether portal links two dimensions by scaled position and an end portal has fixed ends.
An end gateway moves its traveler within its own dimension, to the exit its block entity
records, so it links nothing.

##### links

> `readonly` **links**: `Readonly`\<`Record`\<`string`, `string`\>\>

Defined in: [packages/prismarine/src/world/portal/rules.ts:96](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L96)

The Java dimension type id a trip from each dimension type arrives in.

##### portal

> `readonly` **portal**: readonly `string`[]

Defined in: [packages/prismarine/src/world/portal/rules.ts:94](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L94)

Every block identifier that reads as this portal.

## Variables

### DIMENSION\_TRAVEL

> `const` **DIMENSION\_TRAVEL**: `Readonly`\<`Record`\<`string`, [`DimensionTravelRule`](#dimensiontravelrule)\>\>

Defined in: [packages/prismarine/src/world/portal/rules.ts:57](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L57)

The travel rule of each vanilla dimension type, keyed by Java `dimension_type` id.

The coordinate scale is not here: it is `DimensionType.java.coordinateScale`, read from
the dimension's own document. Nor is which block holds a spawn: `RespawnPoint.ts` reads
Java's `bed_works` and `respawn_anchor_works` attributes off the same document.

***

### END\_GATEWAY

> `const` **END\_GATEWAY**: `string`

Defined in: [packages/prismarine/src/world/portal/rules.ts:81](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L81)

The end gateway block Bedrock writes, which is the first name in the shared list.

***

### END\_GATEWAY\_BLOCKS

> `const` **END\_GATEWAY\_BLOCKS**: readonly `string`[]

Defined in: [packages/prismarine/src/world/portal/rules.ts:78](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L78)

Every identifier that reads as an end gateway block.

***

### PORTALS

> `const` **PORTALS**: `Readonly`\<`Record`\<`string`, [`PortalRule`](#portalrule)\>\>

Defined in: [packages/prismarine/src/world/portal/rules.ts:116](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L116)

The rule of each portal block, keyed by the Bedrock identifier of its first spelling.

The links are Java's `NetherPortalBlock.getPortalDestination` (Overworld and Nether swap)
and `EndPortalBlock.getPortalDestination` (into the End from anywhere else, out of it to the
Overworld). A nether portal in the End cannot be lit, but one a command placed leads to the
Overworld, which is the Bedrock behavior and the only sensible one.

#### Java Source

NetherPortalBlock.getPortalDestination

***

### PORTAL\_SEARCH\_RADIUS

> `const` **PORTAL\_SEARCH\_RADIUS**: `128` = `128`

Defined in: [packages/prismarine/src/world/portal/rules.ts:34](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L34)

How far from the scaled target an existing portal is looked for, in blocks.

Java's `PortalForcer.findClosestPortalPosition` uses `sipush 128` in the Nether and
`bipush 16` in the Overworld. Bedrock searches a 128 block radius in both (wiki, "the point
of interest can be within a 256x256 square block area (128-block radius) in both the
Overworld and Nether"), and that is the number this server uses.

#### Java Source

PortalForcer.findClosestPortalPosition

## Functions

### isPortalBlock()

> **isPortalBlock**(`block`): `boolean`

Defined in: [packages/prismarine/src/world/portal/rules.ts:159](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L159)

Whether a block identifier is one of the portal blocks in [PORTALS](#portals).

#### Parameters

##### block

`string`

#### Returns

`boolean`

***

### portalRuleOf()

> **portalRuleOf**(`block`): [`PortalRule`](#portalrule) \| `undefined`

Defined in: [packages/prismarine/src/world/portal/rules.ts:152](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L152)

The rule of a portal block by any of its identifiers, or undefined for a block that is no portal.

#### Parameters

##### block

`string`

#### Returns

[`PortalRule`](#portalrule) \| `undefined`

***

### travelRuleOf()

> **travelRuleOf**(`dimension`): [`DimensionTravelRule`](#dimensiontravelrule) \| `undefined`

Defined in: [packages/prismarine/src/world/portal/rules.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/portal/rules.ts#L74)

The travel rule of a dimension, or undefined for a type the table does not know.

#### Parameters

##### dimension

[`DimensionType`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/DimensionType/index.md#dimensiontype)

#### Returns

[`DimensionTravelRule`](#dimensiontravelrule) \| `undefined`
