API reference / @jsprismarine/worldgen / LegacyRandomSource
Class: LegacyRandomSource
Defined in: random/LegacyRandomSource.ts:23
Java Edition's LegacyRandomSource, the 48-bit linear congruential generator inherited from java.util.Random.
The nether, the end, the caves and floating islands presets still select it through legacy_random_source: true, and structure placement uses it in every dimension.
Implements
Constructors
Constructor
new LegacyRandomSource(
seed):LegacyRandomSource
Defined in: random/LegacyRandomSource.ts:28
Parameters
seed
bigint
Returns
LegacyRandomSource
Methods
consumeCount()
consumeCount(
rounds):void
Defined in: random/LegacyRandomSource.ts:138
Advances the stream by rounds draws without returning them.
Parameters
rounds
number
Returns
void
Implementation of
fork()
fork():
RandomSource
Defined in: random/LegacyRandomSource.ts:143
Returns an independent stream seeded from this one, advancing this one.
Returns
Implementation of
forkPositional()
forkPositional():
PositionalRandomFactory
Defined in: random/LegacyRandomSource.ts:148
Returns a positional factory seeded from this stream, advancing it.
Returns
Implementation of
next()
next(
bits):number
Defined in: random/LegacyRandomSource.ts:71
Advances the state and returns the top bits bits, as Java's next(int) does.
Parameters
bits
number
Returns
number
nextBoolean()
nextBoolean():
boolean
Defined in: random/LegacyRandomSource.ts:115
Returns the next boolean, taken from one bit of the stream.
Returns
boolean
Implementation of
nextDouble()
nextDouble():
number
Defined in: random/LegacyRandomSource.ts:125
Returns the next value in [0, 1) with 53 bits of precision.
Returns
number
Implementation of
nextFloat()
nextFloat():
number
Defined in: random/LegacyRandomSource.ts:120
Returns the next value in [0, 1) with 24 bits of precision.
Returns
number
Implementation of
nextGaussian()
nextGaussian():
number
Defined in: random/LegacyRandomSource.ts:133
Returns the next normally distributed value with mean 0 and standard deviation 1.
Returns
number
Implementation of
nextInt()
nextInt():
number
Defined in: random/LegacyRandomSource.ts:87
Returns the next 32-bit signed integer, with every value equally likely.
Returns
number
Implementation of
nextIntBounded()
nextIntBounded(
bound):number
Defined in: random/LegacyRandomSource.ts:92
Returns the next integer in [0, bound).
Parameters
bound
number
Returns
number
Throws
When bound is not positive, as Java does.
Implementation of
nextLong()
nextLong():
bigint
Defined in: random/LegacyRandomSource.ts:108
Returns the next 64-bit signed integer.
Returns
bigint
Implementation of
restoreState()
restoreState(
state):void
Defined in: random/LegacyRandomSource.ts:45
Restores this source from a JSON-parsed state, rejecting unknown algorithms or versions.
Parameters
state
unknown
Returns
void
saveState()
saveState():
LegacyRandomSourceState
Defined in: random/LegacyRandomSource.ts:35
Returns the 48-bit LCG state and cached Gaussian value for replay.