Skip to content

API reference / @jsprismarine/prismarine / content/world/serverSource

content/world/serverSource ​

Interfaces ​

ServerWorldHandle ​

Defined in: packages/prismarine/src/content/world/serverSource.ts:347

The world source, plus the one member of it the interaction path reaches past the adapter for.

targetOf answers a question about an interaction in progress, so the code that runs the interaction has to be able to say what it landed on. That is the port rather than the adapter, and ServerWorldAdapter has nowhere to put it: the content packages must not be able to record a target for themselves.

Extends ​

Methods ​

actorsAt() ​

actorsAt(dimension, level?): ServerItemActorPort

Defined in: packages/prismarine/src/content/world/serverSource.ts:363

The item actor port of one world; see ServerItemActorPort.duringInteraction.

Parameters ​
dimension ​

string

The namespaced dimension identifier.

level? ​

string

The level's name, or undefined for the default level.

Returns ​

ServerItemActorPort

at() ​

at(dimension, level?): ServerWorldAdapter

Defined in: packages/prismarine/src/content/world/serverSource.ts:357

The adapter for one world.

The content packages call this with a dimension alone and so reach the default level. A world of another worlds.<name> entry passes its level, so its blocks, random stream and entity runtime are its own rather than the default level's.

Parameters ​
dimension ​

string

The namespaced dimension identifier, such as minecraft:overworld.

level? ​

string

The level's name, or undefined for the default level.

Returns ​

ServerWorldAdapter

Overrides ​

ServerWorldSource.at

closeLevel() ​

closeLevel(level): void

Defined in: packages/prismarine/src/content/world/serverSource.ts:377

Forgets the adapters and entity runtimes of a level that has unloaded, once its save is written, so the level loaded again under that name starts from what the save holds rather than from the entities and draws of the instance before it.

Parameters ​
level ​

string

The level's name.

Returns ​

void

entitiesAt() ​

entitiesAt(dimension, level?): LiveEntityRuntime | undefined

Defined in: packages/prismarine/src/content/world/serverSource.ts:370

The entity runtime of one world, or undefined when its adapter was not built yet or the source runs no data-driven entities. Builds nothing.

Parameters ​
dimension ​

string

The namespaced dimension identifier.

level? ​

string

The level's name, or undefined for the default level.

Returns ​

LiveEntityRuntime | undefined

goalWorld()? ​

optional goalWorld(entity): GoalWorld | undefined

Defined in: packages/prismarine/src/content/world/adapter.ts:609

Resolves a goal world from the runtime that owns this entity, when the source can see every dimension. This avoids binding entities in secondary dimensions to at()'s default adapter.

Parameters ​
entity ​

EntityInstance

Returns ​

GoalWorld | undefined

Inherited from ​

ServerWorldSource.goalWorld

restoreRandomStates() ​

restoreRandomStates(states): void

Defined in: packages/prismarine/src/content/world/serverSource.ts:384

Restores exactly the adapter streams represented by a replay state.

Parameters ​
states ​

unknown

Returns ​

void

saveRandomStates() ​

saveRandomStates(): readonly (readonly [string, SeededRandomState])[]

Defined in: packages/prismarine/src/content/world/serverSource.ts:382

Captures the seeded random stream of each content adapter already built, under its worldKeyOf key, which for the default level is the bare dimension.

Returns ​

readonly (readonly [string, SeededRandomState])[]


ServerWorldSourceOptions ​

Defined in: packages/prismarine/src/content/world/serverSource.ts:41

What serverWorldSource is built over.

Properties ​

content ​

readonly content: ContentLookup

Defined in: packages/prismarine/src/content/world/serverSource.ts:49

The built content, read at call time; see ContentLookup.

entityRuntimes? ​

readonly optional entityRuntimes?: EntityRuntimes

Defined in: packages/prismarine/src/content/world/serverSource.ts:75

The server's data-driven entity runtimes.

Supplied by a server that runs its entities through @jsprismarine/entities rather than through the written classes. One runtime is opened per world as that world's adapter is assembled, because the spawning and ai groups are projections of it. Left out, and those two groups stay absent and every member of them says which subsystem owes it.

random? ​

readonly optional random?: RandomSource

Defined in: packages/prismarine/src/content/world/serverSource.ts:64

Replaces the random draws, which is how a test drives a probabilistic rule either way.

seed ​

readonly seed: bigint

Defined in: packages/prismarine/src/content/world/serverSource.ts:54

The default level's world seed, which level.seed reports and which seeds the default random source.

Methods ​

defaultLevel()? ​

optional defaultLevel(): string | undefined

Defined in: packages/prismarine/src/content/world/serverSource.ts:83

The default level's name. A caller that names it reaches the same world as one that passes no level, which is how the content packages address it.

Left out, and the source serves one level: whatever level a caller names, it reaches the default level's worlds, so a test's world double and its level double are one world.

Returns ​

string | undefined

difficulty() ​

difficulty(): number

Defined in: packages/prismarine/src/content/world/serverSource.ts:62

The configured difficulty, as the protocol numbers it.

Returns ​

number

seedOf()? ​

optional seedOf(level): bigint

Defined in: packages/prismarine/src/content/world/serverSource.ts:60

The seed of a level other than the default, for its adapters' level.seed and random source. Left out, every level reports seed.

Parameters ​
level ​

string

The level's name.

Returns ​

bigint

worldFor() ​

worldFor(dimension, level?): World | undefined

Defined in: packages/prismarine/src/content/world/serverSource.ts:47

The live world of one dimension, or undefined when none of it is loaded.

Parameters ​
dimension ​

string

The namespaced dimension identifier.

level? ​

string

The level's name, or undefined for the default level.

Returns ​

World | undefined

Variables ​

BLOCK_SOUND_EVENTS ​

const BLOCK_SOUND_EVENTS: Readonly<Record<ContentBlockSound, LevelSoundEvent>>

Defined in: packages/prismarine/src/content/world/serverSource.ts:95

The level sound event each block sound is, which the client plays in the block's material.

Bds See ​

toggle-door

Bds See ​

toggle-trapdoor

Bds See ​

toggle-fence-gate

Bds See ​

press-button

Bds See ​

step-on-pressure-plate

Functions ​

serverWorldSource() ​

serverWorldSource(options): ServerWorldHandle

Defined in: packages/prismarine/src/content/world/serverSource.ts:394

The world the content packages act through on a running server.

Parameters ​

options ​

ServerWorldSourceOptions

Returns ​

ServerWorldHandle

A source that hands out one adapter per world, built on first use and kept, so the block group's neighbor-update budget and the item cooldowns of a world outlive the call that made them.