public class ChunkRandom extends Random
Modifier and Type | Field and Description |
---|---|
private int |
sampleCount |
Constructor and Description |
---|
ChunkRandom() |
ChunkRandom(long seed) |
Modifier and Type | Method and Description |
---|---|
void |
consume(int count)
Skips the provided number of calls to the randomizer.
|
static Random |
getSlimeRandom(int chunkX,
int chunkZ,
long worldSeed,
long scrambler) |
protected int |
next(int bound) |
long |
setCarverSeed(long worldSeed,
int chunkX,
int chunkZ)
Seeds the randomizer to generate larger features such as caves, ravines, mineshafts
and strongholds.
|
long |
setDecoratorSeed(long populationSeed,
int index,
int step)
Seeds the randomizer to generate a given feature.
|
long |
setPopulationSeed(long worldSeed,
int blockX,
int blockZ)
Seeds the randomizer to create population features such as decorators and animals.
|
long |
setRegionSeed(long worldSeed,
int regionX,
int regionZ,
int salt)
Seeds the randomizer to determine the start position of structure features such as
temples, monuments and buried treasures within a region.
|
long |
setTerrainSeed(int chunkX,
int chunkZ)
Seeds the randomizer to generate the surface terrain blocks (such as grass, sand, etc.)
and the bedrock patterns.
|
public void consume(int count)
The skips give the effect of "scrambling" the randomizer but the output is still linearly dependent. Note that since multiple calls to a linear congruential generator is equivalent to another linear congruence, this method could be optimized to combine the calls into one.
public long setTerrainSeed(int chunkX, int chunkZ)
Note that the terrain seed does not depend on the world seed and only gets affected by chunk coordinates.
public long setPopulationSeed(long worldSeed, int blockX, int blockZ)
This method takes in the world seed and the negative-most block coordinates of the chunk. The coordinate pair provided is equivalent to (chunkX * 16, chunkZ * 16). The three values are mixed together through some layers of hashing to produce the population seed.
This function has been proved to be reversible through some exploitation of the underlying nextLong() weaknesses. It is also important to remember that since setSeed() truncates the 16 upper bits of world seed, only the 48 lowest bits affect the population seed output.
public long setDecoratorSeed(long populationSeed, int index, int step)
index + 10000 * step
assures that each feature is seeded
differently, making the decoration feel more random. Even though it does a good job
at doing so, many entropy issues arise from the salt being so small and result in
weird alignments between features that have an index close apart.populationSeed
- The population seed computed in setPopulationSeed().index
- The index of the feature in the feature list.step
- The generation step's ordinal for this feature.public long setCarverSeed(long worldSeed, int chunkX, int chunkZ)
Similar to the population seed, only the 48 lowest bits of the world seed affect the output since it the upper 16 bits are truncated in the setSeed() call.
public long setRegionSeed(long worldSeed, int regionX, int regionZ, int salt)
The region coordinates pair corresponds to the coordinates of the region the seeded chunk lies in. For example, a swamp hut region is 32 by 32 chunks meaning that all chunks that lie within that region get seeded the same way.
Similarly, the upper 16 bits of world seed also do not affect the region seed because they get truncated in the setSeed() call.
public static Random getSlimeRandom(int chunkX, int chunkZ, long worldSeed, long scrambler)