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 alu
intermediary net/minecraft/class_5819
named net/minecraft/util/math/random/Random
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Random
create()
Returns a random.static Random
create
(long seed) Returns a random with the givenseed
.static Random
Returns a random split from the thread local random.static Random
Deprecated.This one is hard to ensure deterministic behavior compared to the non-thread-safe one.default int
nextBetween
(int min, int max) default int
nextBetweenExclusive
(int min, int max) boolean
double
float
double
int
nextInt()
int
nextInt
(int bound) long
nextLong()
default double
nextTriangular
(double mode, double deviation) Returns a randomdouble
betweenmode - deviation
andmode + deviation
(both inclusive) with modemode
.void
setSeed
(long seed) default void
skip
(int count) split()
-
Field Details
-
field_38930
Deprecated.- See Also:
- Mappings:
Namespace Name Mixin selector official a
Lalu;a:D
intermediary field_38930
Lnet/minecraft/class_5819;field_38930:D
named field_38930
Lnet/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 a
Lalu;a()Lalu;
intermediary method_43047
Lnet/minecraft/class_5819;method_43047()Lnet/minecraft/class_5819;
named create
Lnet/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 b
Lalu;b()Lalu;
intermediary method_43050
Lnet/minecraft/class_5819;method_43050()Lnet/minecraft/class_5819;
named createThreadSafe
Lnet/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 a
Lalu;a(J)Lalu;
intermediary method_43049
Lnet/minecraft/class_5819;method_43049(J)Lnet/minecraft/class_5819;
named create
Lnet/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 c
Lalu;c()Lalu;
intermediary method_43053
Lnet/minecraft/class_5819;method_43053()Lnet/minecraft/class_5819;
named createLocal
Lnet/minecraft/util/math/random/Random;createLocal()Lnet/minecraft/util/math/random/Random;
-
split
Random split()- Mappings:
Namespace Name Mixin selector official d
Lalu;d()Lalu;
intermediary method_38420
Lnet/minecraft/class_5819;method_38420()Lnet/minecraft/class_5819;
named split
Lnet/minecraft/util/math/random/Random;split()Lnet/minecraft/util/math/random/Random;
-
nextSplitter
RandomSplitter nextSplitter()- Mappings:
Namespace Name Mixin selector official e
Lalu;e()Ldag;
intermediary method_38421
Lnet/minecraft/class_5819;method_38421()Lnet/minecraft/class_6574;
named nextSplitter
Lnet/minecraft/util/math/random/Random;nextSplitter()Lnet/minecraft/util/math/random/RandomSplitter;
-
setSeed
void setSeed(long seed) - Mappings:
Namespace Name Mixin selector official b
Lalu;b(J)V
intermediary method_43052
Lnet/minecraft/class_5819;method_43052(J)V
named setSeed
Lnet/minecraft/util/math/random/Random;setSeed(J)V
-
nextInt
int nextInt()- Mappings:
Namespace Name Mixin selector official f
Lalu;f()I
intermediary method_43054
Lnet/minecraft/class_5819;method_43054()I
named nextInt
Lnet/minecraft/util/math/random/Random;nextInt()I
-
nextInt
int nextInt(int bound) - Mappings:
Namespace Name Mixin selector official a
Lalu;a(I)I
intermediary method_43048
Lnet/minecraft/class_5819;method_43048(I)I
named nextInt
Lnet/minecraft/util/math/random/Random;nextInt(I)I
-
nextBetween
default int nextBetween(int min, int max) - Mappings:
Namespace Name Mixin selector official a
Lalu;a(II)I
intermediary method_39332
Lnet/minecraft/class_5819;method_39332(II)I
named nextBetween
Lnet/minecraft/util/math/random/Random;nextBetween(II)I
-
nextLong
long nextLong()- Mappings:
Namespace Name Mixin selector official g
Lalu;g()J
intermediary method_43055
Lnet/minecraft/class_5819;method_43055()J
named nextLong
Lnet/minecraft/util/math/random/Random;nextLong()J
-
nextBoolean
boolean nextBoolean()- Mappings:
Namespace Name Mixin selector official h
Lalu;h()Z
intermediary method_43056
Lnet/minecraft/class_5819;method_43056()Z
named nextBoolean
Lnet/minecraft/util/math/random/Random;nextBoolean()Z
-
nextFloat
float nextFloat()- Mappings:
Namespace Name Mixin selector official i
Lalu;i()F
intermediary method_43057
Lnet/minecraft/class_5819;method_43057()F
named nextFloat
Lnet/minecraft/util/math/random/Random;nextFloat()F
-
nextDouble
double nextDouble()- Mappings:
Namespace Name Mixin selector official j
Lalu;j()D
intermediary method_43058
Lnet/minecraft/class_5819;method_43058()D
named nextDouble
Lnet/minecraft/util/math/random/Random;nextDouble()D
-
nextGaussian
double nextGaussian()- Mappings:
Namespace Name Mixin selector official k
Lalu;k()D
intermediary method_43059
Lnet/minecraft/class_5819;method_43059()D
named nextGaussian
Lnet/minecraft/util/math/random/Random;nextGaussian()D
-
nextTriangular
default double nextTriangular(double mode, double deviation) Returns a randomdouble
betweenmode - deviation
andmode + 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
double
betweenmode - deviation
andmode + deviation
(both inclusive) with modemode
- Mappings:
Namespace Name Mixin selector official a
Lalu;a(DD)D
intermediary method_43385
Lnet/minecraft/class_5819;method_43385(DD)D
named nextTriangular
Lnet/minecraft/util/math/random/Random;nextTriangular(DD)D
-
skip
default void skip(int count) - Mappings:
Namespace Name Mixin selector official b
Lalu;b(I)V
intermediary method_33650
Lnet/minecraft/class_5819;method_33650(I)V
named skip
Lnet/minecraft/util/math/random/Random;skip(I)V
-
nextBetweenExclusive
default int nextBetweenExclusive(int min, int max) - Mappings:
Namespace Name Mixin selector official b
Lalu;b(II)I
intermediary method_43051
Lnet/minecraft/class_5819;method_43051(II)I
named nextBetweenExclusive
Lnet/minecraft/util/math/random/Random;nextBetweenExclusive(II)I
-