Skip to content

API reference Obsidian.API.World.Generator.RandomSources

IRandomSource interface

Port of vanilla's RandomSource. Implementations produce exactly the same sequence as Minecraft for the same seed, so world generation can match vanilla bit-for-bit. Implementations are not thread-safe.

public interface IRandomSource

In Obsidian.API.

Methods

ConsumeCount(int)

void ConsumeCount(int count);

Advances the source as if count values had been drawn.

Fork()

IRandomSource Fork();

Creates an independent random seeded from this one. Advances this source.

ForkPositional()

IPositionalRandomFactory ForkPositional();

Creates a factory for deriving randoms from positions, names or seeds. Advances this source.

bool NextBoolean();

NextDouble()

double NextDouble();

Returns a value in [0, 1) with 53 bits of precision.

NextFloat()

float NextFloat();

Returns a value in [0, 1) with 24 bits of precision.

NextGaussian()

double NextGaussian();

Returns a normally distributed value (mean 0, deviation 1) using Marsaglia's polar method.

NextInt()

int NextInt();

Returns a uniformly distributed 32-bit value.

NextInt(int)

int NextInt(int bound);

Returns a value in [0, bound). bound must be positive.

NextInt(int, int)

int NextInt(int origin, int bound);

Returns a value in [origin, bound) (vanilla nextInt(int, int)).

NextIntBetweenInclusive(int, int)

int NextIntBetweenInclusive(int min, int max);

Returns a value in [min, max] (vanilla nextIntBetweenInclusive).

long NextLong();

SetSeed(long)

void SetSeed(long seed);

Resets this source to the state produced by seed.

Triangle(double, double)

double Triangle(double mode, double deviation);

Returns mode + deviation * (NextDouble() - NextDouble()).

Triangle(float, float)

float Triangle(float mode, float deviation);

Returns mode + deviation * (NextFloat() - NextFloat()), computed in single precision.

On this page