API reference / @jsprismarine/prismarine / command/host/randomSequences / RandomSequences
Class: RandomSequences
Defined in: packages/prismarine/src/command/host/randomSequences.ts:35
One stream per sequence id, plus the unkeyed one a draw without an id uses.
Constructors
Constructor
new RandomSequences(
worldSeed):RandomSequences
Defined in: packages/prismarine/src/command/host/randomSequences.ts:44
Parameters
worldSeed
() => bigint
Read rather than held, because the default world is loaded after the host is built.
Returns
RandomSequences
Methods
draw()
draw(
min,max,sequence?):number
Defined in: packages/prismarine/src/command/host/randomSequences.ts:52
Draws one value, inclusive of both ends.
Parameters
min
number
max
number
sequence?
string
Returns
number
A value in [min, max], or min when the range is empty, which is how /random value 5..1 answers rather than throwing.
reset()
reset(
sequence,seed?):boolean
Defined in: packages/prismarine/src/command/host/randomSequences.ts:68
Drops a sequence so its next draw starts over.
Parameters
sequence
string
One id, or * for every sequence at once.
seed?
number
Replaces the world seed the stream is keyed from, which is what makes a draw reproducible across worlds.
Returns
boolean
Whether anything was reset. Resetting a sequence nobody has drawn from yet still counts, because the next draw does start over.
restoreState()
restoreState(
state):void
Defined in: packages/prismarine/src/command/host/randomSequences.ts:99
Restores command streams only when they belong to the same default world seed.
Parameters
state
unknown
Returns
void
saveState()
saveState():
RandomSequencesState
Defined in: packages/prismarine/src/command/host/randomSequences.ts:86
Captures the streams that have advanced, along with any explicit reset seeds.