Package net.minecraft.util.math.random
Interface Random
- All Known Subinterfaces:
BaseRandom
- All Known Implementing Classes:
CheckedRandom,ChunkRandom,LocalRandom,RandomSequencesState.WrappedRandom,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 named net/minecraft/util/math/random/Randomintermediary net/minecraft/class_5819official ayw
-
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 named field_38930Lnet/minecraft/util/math/random/Random;field_38930:Dintermediary field_38930Lnet/minecraft/class_5819;field_38930:Dofficial aLayw;a: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 named createLnet/minecraft/util/math/random/Random;create()Lnet/minecraft/util/math/random/Random;intermediary method_43047Lnet/minecraft/class_5819;method_43047()Lnet/minecraft/class_5819;official aLayw;a()Layw;
-
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 named createThreadSafeLnet/minecraft/util/math/random/Random;createThreadSafe()Lnet/minecraft/util/math/random/Random;intermediary method_43050Lnet/minecraft/class_5819;method_43050()Lnet/minecraft/class_5819;official bLayw;b()Layw;
-
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 named createLnet/minecraft/util/math/random/Random;create(J)Lnet/minecraft/util/math/random/Random;intermediary method_43049Lnet/minecraft/class_5819;method_43049(J)Lnet/minecraft/class_5819;official aLayw;a(J)Layw;
-
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 named createLocalLnet/minecraft/util/math/random/Random;createLocal()Lnet/minecraft/util/math/random/Random;intermediary method_43053Lnet/minecraft/class_5819;method_43053()Lnet/minecraft/class_5819;official cLayw;c()Layw;
-
split
Random split()- Mappings:
Namespace Name Mixin selector named splitLnet/minecraft/util/math/random/Random;split()Lnet/minecraft/util/math/random/Random;intermediary method_38420Lnet/minecraft/class_5819;method_38420()Lnet/minecraft/class_5819;official dLayw;d()Layw;
-
nextSplitter
RandomSplitter nextSplitter()- Mappings:
Namespace Name Mixin selector named nextSplitterLnet/minecraft/util/math/random/Random;nextSplitter()Lnet/minecraft/util/math/random/RandomSplitter;intermediary method_38421Lnet/minecraft/class_5819;method_38421()Lnet/minecraft/class_6574;official eLayw;e()Ldzl;
-
setSeed
void setSeed(long seed) - Mappings:
Namespace Name Mixin selector named setSeedLnet/minecraft/util/math/random/Random;setSeed(J)Vintermediary method_43052Lnet/minecraft/class_5819;method_43052(J)Vofficial bLayw;b(J)V
-
nextInt
int nextInt()- Mappings:
Namespace Name Mixin selector named nextIntLnet/minecraft/util/math/random/Random;nextInt()Iintermediary method_43054Lnet/minecraft/class_5819;method_43054()Iofficial fLayw;f()I
-
nextInt
int nextInt(int bound) - Mappings:
Namespace Name Mixin selector named nextIntLnet/minecraft/util/math/random/Random;nextInt(I)Iintermediary method_43048Lnet/minecraft/class_5819;method_43048(I)Iofficial aLayw;a(I)I
-
nextBetween
default int nextBetween(int min, int max) - Mappings:
Namespace Name Mixin selector named nextBetweenLnet/minecraft/util/math/random/Random;nextBetween(II)Iintermediary method_39332Lnet/minecraft/class_5819;method_39332(II)Iofficial aLayw;a(II)I
-
nextLong
long nextLong()- Mappings:
Namespace Name Mixin selector named nextLongLnet/minecraft/util/math/random/Random;nextLong()Jintermediary method_43055Lnet/minecraft/class_5819;method_43055()Jofficial gLayw;g()J
-
nextBoolean
boolean nextBoolean()- Mappings:
Namespace Name Mixin selector named nextBooleanLnet/minecraft/util/math/random/Random;nextBoolean()Zintermediary method_43056Lnet/minecraft/class_5819;method_43056()Zofficial hLayw;h()Z
-
nextFloat
float nextFloat()- Mappings:
Namespace Name Mixin selector named nextFloatLnet/minecraft/util/math/random/Random;nextFloat()Fintermediary method_43057Lnet/minecraft/class_5819;method_43057()Fofficial iLayw;i()F
-
nextDouble
double nextDouble()- Mappings:
Namespace Name Mixin selector named nextDoubleLnet/minecraft/util/math/random/Random;nextDouble()Dintermediary method_43058Lnet/minecraft/class_5819;method_43058()Dofficial jLayw;j()D
-
nextGaussian
double nextGaussian()- Mappings:
Namespace Name Mixin selector named nextGaussianLnet/minecraft/util/math/random/Random;nextGaussian()Dintermediary method_43059Lnet/minecraft/class_5819;method_43059()Dofficial kLayw;k()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 named nextTriangularLnet/minecraft/util/math/random/Random;nextTriangular(DD)Dintermediary method_43385Lnet/minecraft/class_5819;method_43385(DD)Dofficial aLayw;a(DD)D
-
skip
default void skip(int count) - Mappings:
Namespace Name Mixin selector named skipLnet/minecraft/util/math/random/Random;skip(I)Vintermediary method_33650Lnet/minecraft/class_5819;method_33650(I)Vofficial bLayw;b(I)V
-
nextBetweenExclusive
default int nextBetweenExclusive(int min, int max) - Mappings:
Namespace Name Mixin selector named nextBetweenExclusiveLnet/minecraft/util/math/random/Random;nextBetweenExclusive(II)Iintermediary method_43051Lnet/minecraft/class_5819;method_43051(II)Iofficial bLayw;b(II)I
-