Skip to content

FeatureRandom 5.46.0 ​

final class · pocketmine\world\generator\vanilla\feature\FeatureRandom · source

Vanilla's WorldgenRandom over a Xoroshiro128++ source, as used for biome decoration (ChunkGenerator .applyBiomeDecoration): every value comes from next(bits) = (int) (xoroshiro.nextLong() >>> (64 - bits)), and the int/float/double/long/gaussian helpers are the java.util.Random style ones of BitRandomSource / LegacyRandomSource.

Note: the gaussian cache is NOT reset by setSeed() (WorldgenRandom overrides setSeed and only reseeds the source), so it carries over between features of the same chunk, like in vanilla.

Methods ​

__construct() ​

php
public function __construct(int $seed = 0)

consumeCount() ​

php
public function consumeCount(int $count) : void

fork() ​

php
public function fork() : \pocketmine\world\generator\vanilla\random\XoroshiroRandom

WorldgenRandom.fork(): a plain Xoroshiro source (with its own nextInt(bound) semantics).

getGaussianState() ​

php
public function getGaussianState() : array

Pending second value of nextGaussian() (the native decoration continues the same sequence).

mthNextInt() ​

php
public function mthNextInt(int $min, int $max) : int

Mth.nextInt(random, min, max): min if min >= max

next() ​

php
public function next(int $bits) : int

(int) (nextLong() >>> (64 - bits)), for 1 <= bits <= 32.

nextBoolean() ​

php
public function nextBoolean() : bool

nextBoundedInt() ​

php
public function nextBoundedInt(int $bound) : int

Uniform int in [0, bound) (java.util.Random algorithm).

nextDouble() ​

php
public function nextDouble() : float

nextFloat() ​

php
public function nextFloat() : float

float32 in [0, 1)

nextGaussian() ​

php
public function nextGaussian() : float

nextInt() ​

php
public function nextInt() : int

nextIntBetweenInclusive() ​

php
public function nextIntBetweenInclusive(int $min, int $max) : int

RandomSource.nextIntBetweenInclusive / Mth.randomBetweenInclusive

nextIntRange() ​

php
public function nextIntRange(int $origin, int $bound) : int

RandomSource.nextInt(origin, bound)

nextLong() ​

php
public function nextLong() : int

rawLong() ​

php
public function rawLong() : int

Raw Xoroshiro128++ output.

setDecorationSeed() ​

php
public function setDecorationSeed(int $levelSeed, int $x, int $z) : int

WorldgenRandom.setDecorationSeed(levelSeed, minBlockX, minBlockZ): returns the decoration seed.

setFeatureSeed() ​

php
public function setFeatureSeed(int $decorationSeed, int $index, int $step) : void

WorldgenRandom.setFeatureSeed(decorationSeed, index, step).

setGaussianState() ​

php
public function setGaussianState(bool $have, float $value) : void

setSeed() ​

php
public function setSeed(int $seed) : void

triangle() ​

php
public function triangle(float $mean, float $spread) : float

RandomSource.triangle(mean, spread) for doubles

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.