Skip to content

API reference / @jsprismarine/prismarine / world/portal/gateway

world/portal/gateway ​

Interfaces ​

ExitPlan ​

Defined in: packages/prismarine/src/world/portal/gateway.ts:281

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

Properties ​

island ​

readonly island: BlockPosition | undefined

Defined in: packages/prismarine/src/world/portal/gateway.ts:283

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

spawn ​

readonly spawn: BlockPosition

Defined in: packages/prismarine/src/world/portal/gateway.ts:285

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

A block as the search reads one.

Properties ​

fullBlock ​

readonly fullBlock: boolean

Defined in: packages/prismarine/src/world/portal/gateway.ts:79

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


GatewayTerrain ​

Defined in: packages/prismarine/src/world/portal/gateway.ts:83

The End as the search reads it.

Properties ​

maxY ​

readonly maxY: number

Defined in: packages/prismarine/src/world/portal/gateway.ts:91

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

The lowest y of the dimension.

Methods ​

blockAt() ​

blockAt(x, y, z): GatewayBlock | undefined

Defined in: packages/prismarine/src/world/portal/gateway.ts:93

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

Parameters ​
x ​

number

y ​

number

z ​

number

Returns ​

GatewayBlock | undefined

chunkTopY() ​

chunkTopY(x, z): number | undefined

Defined in: packages/prismarine/src/world/portal/gateway.ts:110

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

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

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

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

z ​

readonly z: number

Defined in: packages/prismarine/src/world/portal/gateway.ts:72


MissingChunk ​

Defined in: packages/prismarine/src/world/portal/gateway.ts:114

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

Properties ​

missing ​

readonly missing: ChunkCoordinate

Defined in: packages/prismarine/src/world/portal/gateway.ts:115

Variables ​

EXIT_POSITION_RADIUS ​

const EXIT_POSITION_RADIUS: 5 = 5

Defined in: packages/prismarine/src/world/portal/gateway.ts:61

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

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

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

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

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

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

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

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

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

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

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

Returns ​

bigint

Java Source ​

BlockPos.asLong(III)J


chunkOfPoint() ​

chunkOfPoint(__namedParameters): ChunkCoordinate

Defined in: packages/prismarine/src/world/portal/gateway.ts:119

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

Parameters ​

__namedParameters ​

HorizontalPoint

Returns ​

ChunkCoordinate


exitSearchChunks() ​

exitSearchChunks(gateway): ChunkCoordinate[]

Defined in: packages/prismarine/src/world/portal/gateway.ts:145

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

Returns ​

ChunkCoordinate[]


findExitPortalXZPosTentative() ​

findExitPortalXZPosTentative(terrain, gateway): HorizontalPoint | MissingChunk

Defined in: packages/prismarine/src/world/portal/gateway.ts:174

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, "isChunkEmpty">

gateway ​

BlockPosition

Returns ​

HorizontalPoint | 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

Defined in: packages/prismarine/src/world/portal/gateway.ts:275

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

exit ​

BlockPosition

Returns ​

BlockPosition

Java Source ​

TheEndGatewayBlockEntity.findExitPosition


findTallestBlock() ​

findTallestBlock(terrain, around, radius, allowBedrock): BlockPosition

Defined in: packages/prismarine/src/world/portal/gateway.ts:242

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

around ​

BlockPosition

radius ​

number

allowBedrock ​

boolean

Whether bedrock counts, and with it the center column.

Returns ​

BlockPosition

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

Java Source ​

TheEndGatewayBlockEntity.findTallestBlock


findValidSpawnInChunk() ​

findValidSpawnInChunk(terrain, chunk): BlockPosition | undefined

Defined in: packages/prismarine/src/world/portal/gateway.ts:211

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 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

chunk ​

ChunkCoordinate

The chunk to search, which must be loaded.

Returns ​

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 | ExitPlan

Defined in: packages/prismarine/src/world/portal/gateway.ts:295

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

gateway ​

BlockPosition

Returns ​

MissingChunk | ExitPlan

The plan, or the chunk the walk needs next.

Java Source ​

TheEndGatewayBlockEntity.findOrCreateValidTeleportPos


returnGatewayOf() ​

returnGatewayOf(terrain, plan): BlockPosition

Defined in: packages/prismarine/src/world/portal/gateway.ts:322

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

plan ​

ExitPlan

Returns ​

BlockPosition

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

Java Source ​

TheEndGatewayBlockEntity.getPortalPosition