Package net.minecraft.util.math.random
Interface Random
- All Known Subinterfaces:
BaseRandom
- All Known Implementing Classes:
CheckedRandom,ChunkRandom,LocalRandom,ThreadSafeRandom,Xoroshiro128PlusPlusRandom
public interface Random
A reimplementation of
Random.
There are four built-in implementations, three based on the classic Java algorithm and one using Xoroshiro128++ algorithm.
LocalRandom: Silently breaks when used concurrently. Based onRandom.CheckedRandom: Throws when used concurrently. Based onRandom.ThreadSafeRandom: Blocks the thread when used concurrently. Based onRandom.Xoroshiro128PlusPlusRandom: Silently breaks when used concurrently. Implements the Xoroshiro128++ algorithm.
- See Also:
- Implementation Note:
- Note that due to MC-239059, this is not an exact reimplementation of the Java random number generator algorithm.
- Mappings:
Namespace Name official aluintermediary net/minecraft/class_5819named net/minecraft/util/math/random/Random
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Randomcreate()Returns a random.static Randomcreate(long seed) Returns a random with the givenseed.static RandomReturns a random split from the thread local random.static RandomDeprecated.This one is hard to ensure deterministic behavior compared to the non-thread-safe one.default intnextBetween(int min, int max) default intnextBetweenExclusive(int min, int max) booleandoublefloatdoubleintnextInt()intnextInt(int bound) longnextLong()default doublenextTriangular(double mode, double deviation) Returns a randomdoublebetweenmode - deviationandmode + deviation(both inclusive) with modemode.voidsetSeed(long seed) default voidskip(int count) split()
-
Field Details
-
field_38930
Deprecated.- See Also:
- Mappings:
Namespace Name Mixin selector official aLalu;a:Dintermediary field_38930Lnet/minecraft/class_5819;field_38930:Dnamed field_38930Lnet/minecraft/util/math/random/Random;field_38930:D
-
-
Method Details
-
create
Returns a random. The returned random actively detects concurrent usage and fails on detection.- Returns:
- a random
- Mappings:
Namespace Name Mixin selector official aLalu;a()Lalu;intermediary method_43047Lnet/minecraft/class_5819;method_43047()Lnet/minecraft/class_5819;named createLnet/minecraft/util/math/random/Random;create()Lnet/minecraft/util/math/random/Random;
-
createThreadSafe
Deprecated.This one is hard to ensure deterministic behavior compared to the non-thread-safe one.Returns a random, suitable for multithreaded scenarios.- Returns:
- a random, suitable for multithreaded scenarios
- Mappings:
Namespace Name Mixin selector official bLalu;b()Lalu;intermediary method_43050Lnet/minecraft/class_5819;method_43050()Lnet/minecraft/class_5819;named createThreadSafeLnet/minecraft/util/math/random/Random;createThreadSafe()Lnet/minecraft/util/math/random/Random;
-
create
Returns a random with the givenseed. The returned random actively detects concurrent usage and fails on detection.- Returns:
- a random with the given
seed - Mappings:
Namespace Name Mixin selector official aLalu;a(J)Lalu;intermediary method_43049Lnet/minecraft/class_5819;method_43049(J)Lnet/minecraft/class_5819;named createLnet/minecraft/util/math/random/Random;create(J)Lnet/minecraft/util/math/random/Random;
-
createLocal
Returns a random split from the thread local random. Users must ensure this random is not used concurrently.- Returns:
- a random split from the thread local random
- Mappings:
Namespace Name Mixin selector official cLalu;c()Lalu;intermediary method_43053Lnet/minecraft/class_5819;method_43053()Lnet/minecraft/class_5819;named createLocalLnet/minecraft/util/math/random/Random;createLocal()Lnet/minecraft/util/math/random/Random;
-
split
Random split()- Mappings:
Namespace Name Mixin selector official dLalu;d()Lalu;intermediary method_38420Lnet/minecraft/class_5819;method_38420()Lnet/minecraft/class_5819;named splitLnet/minecraft/util/math/random/Random;split()Lnet/minecraft/util/math/random/Random;
-
nextSplitter
RandomSplitter nextSplitter()- Mappings:
Namespace Name Mixin selector official eLalu;e()Ldah;intermediary method_38421Lnet/minecraft/class_5819;method_38421()Lnet/minecraft/class_6574;named nextSplitterLnet/minecraft/util/math/random/Random;nextSplitter()Lnet/minecraft/util/math/random/RandomSplitter;
-
setSeed
void setSeed(long seed) - Mappings:
Namespace Name Mixin selector official bLalu;b(J)Vintermediary method_43052Lnet/minecraft/class_5819;method_43052(J)Vnamed setSeedLnet/minecraft/util/math/random/Random;setSeed(J)V
-
nextInt
int nextInt()- Mappings:
Namespace Name Mixin selector official fLalu;f()Iintermediary method_43054Lnet/minecraft/class_5819;method_43054()Inamed nextIntLnet/minecraft/util/math/random/Random;nextInt()I
-
nextInt
int nextInt(int bound) - Mappings:
Namespace Name Mixin selector official aLalu;a(I)Iintermediary method_43048Lnet/minecraft/class_5819;method_43048(I)Inamed nextIntLnet/minecraft/util/math/random/Random;nextInt(I)I
-
nextBetween
default int nextBetween(int min, int max) - Mappings:
Namespace Name Mixin selector official aLalu;a(II)Iintermediary method_39332Lnet/minecraft/class_5819;method_39332(II)Inamed nextBetweenLnet/minecraft/util/math/random/Random;nextBetween(II)I
-
nextLong
long nextLong()- Mappings:
Namespace Name Mixin selector official gLalu;g()Jintermediary method_43055Lnet/minecraft/class_5819;method_43055()Jnamed nextLongLnet/minecraft/util/math/random/Random;nextLong()J
-
nextBoolean
boolean nextBoolean()- Mappings:
Namespace Name Mixin selector official hLalu;h()Zintermediary method_43056Lnet/minecraft/class_5819;method_43056()Znamed nextBooleanLnet/minecraft/util/math/random/Random;nextBoolean()Z
-
nextFloat
float nextFloat()- Mappings:
Namespace Name Mixin selector official iLalu;i()Fintermediary method_43057Lnet/minecraft/class_5819;method_43057()Fnamed nextFloatLnet/minecraft/util/math/random/Random;nextFloat()F
-
nextDouble
double nextDouble()- Mappings:
Namespace Name Mixin selector official jLalu;j()Dintermediary method_43058Lnet/minecraft/class_5819;method_43058()Dnamed nextDoubleLnet/minecraft/util/math/random/Random;nextDouble()D
-
nextGaussian
double nextGaussian()- Mappings:
Namespace Name Mixin selector official kLalu;k()Dintermediary method_43059Lnet/minecraft/class_5819;method_43059()Dnamed nextGaussianLnet/minecraft/util/math/random/Random;nextGaussian()D
-
nextTriangular
default double nextTriangular(double mode, double deviation) Returns a randomdoublebetweenmode - deviationandmode + deviation(both inclusive) with modemode.Because the return value follows a symmetric triangular distribution, the distribution's mean and median are equal to
mode.- Returns:
- a random
doublebetweenmode - deviationandmode + deviation(both inclusive) with modemode - Mappings:
Namespace Name Mixin selector official aLalu;a(DD)Dintermediary method_43385Lnet/minecraft/class_5819;method_43385(DD)Dnamed nextTriangularLnet/minecraft/util/math/random/Random;nextTriangular(DD)D
-
skip
default void skip(int count) - Mappings:
Namespace Name Mixin selector official bLalu;b(I)Vintermediary method_33650Lnet/minecraft/class_5819;method_33650(I)Vnamed skipLnet/minecraft/util/math/random/Random;skip(I)V
-
nextBetweenExclusive
default int nextBetweenExclusive(int min, int max) - Mappings:
Namespace Name Mixin selector official bLalu;b(II)Iintermediary method_43051Lnet/minecraft/class_5819;method_43051(II)Inamed nextBetweenExclusiveLnet/minecraft/util/math/random/Random;nextBetweenExclusive(II)I
-