RandomSource.java
net.minecraft.util.RandomSource
信息
- 全限定名:net.minecraft.util.RandomSource
- 类型:public interface
- 包:net.minecraft.util
- 源码路径:src/main/java/net/minecraft/util/RandomSource.java
- 起始行号:L10
- 职责:
TODO
字段/常量
GAUSSIAN_SPREAD_FACTOR- 类型:
double - 修饰符:
package-private - 源码定位:
L11 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
static RandomSource create() @ L14
- 方法名:create
- 源码定位:L14
- 返回类型:RandomSource
- 修饰符:static
参数:
- 无
说明:
TODO
static RandomSource createThreadSafe() @ L18
- 方法名:createThreadSafe
- 源码定位:L18
- 返回类型:RandomSource
- 修饰符:static
参数:
- 无
说明:
TODO
static RandomSource create(long seed) @ L23
- 方法名:create
- 源码定位:L23
- 返回类型:RandomSource
- 修饰符:static
参数:
- seed: long
说明:
TODO
static RandomSource createThreadLocalInstance() @ L27
- 方法名:createThreadLocalInstance
- 源码定位:L27
- 返回类型:RandomSource
- 修饰符:static
参数:
- 无
说明:
TODO
static RandomSource createThreadLocalInstance(long seed) @ L31
- 方法名:createThreadLocalInstance
- 源码定位:L31
- 返回类型:RandomSource
- 修饰符:static
参数:
- seed: long
说明:
TODO
RandomSource fork() @ L35
- 方法名:fork
- 源码定位:L35
- 返回类型:RandomSource
- 修饰符:package-private
参数:
- 无
说明:
TODO
PositionalRandomFactory forkPositional() @ L37
- 方法名:forkPositional
- 源码定位:L37
- 返回类型:PositionalRandomFactory
- 修饰符:package-private
参数:
- 无
说明:
TODO
void setSeed(long seed) @ L39
- 方法名:setSeed
- 源码定位:L39
- 返回类型:void
- 修饰符:package-private
参数:
- seed: long
说明:
TODO
int nextInt() @ L41
- 方法名:nextInt
- 源码定位:L41
- 返回类型:int
- 修饰符:package-private
参数:
- 无
说明:
TODO
int nextInt(int bound) @ L43
- 方法名:nextInt
- 源码定位:L43
- 返回类型:int
- 修饰符:package-private
参数:
- bound: int
说明:
TODO
default int nextIntBetweenInclusive(int min, int maxInclusive) @ L45
- 方法名:nextIntBetweenInclusive
- 源码定位:L45
- 返回类型:int
- 修饰符:default
参数:
- min: int
- maxInclusive: int
说明:
TODO
long nextLong() @ L49
- 方法名:nextLong
- 源码定位:L49
- 返回类型:long
- 修饰符:package-private
参数:
- 无
说明:
TODO
boolean nextBoolean() @ L51
- 方法名:nextBoolean
- 源码定位:L51
- 返回类型:boolean
- 修饰符:package-private
参数:
- 无
说明:
TODO
float nextFloat() @ L53
- 方法名:nextFloat
- 源码定位:L53
- 返回类型:float
- 修饰符:package-private
参数:
- 无
说明:
TODO
double nextDouble() @ L55
- 方法名:nextDouble
- 源码定位:L55
- 返回类型:double
- 修饰符:package-private
参数:
- 无
说明:
TODO
double nextGaussian() @ L57
- 方法名:nextGaussian
- 源码定位:L57
- 返回类型:double
- 修饰符:package-private
参数:
- 无
说明:
TODO
default double triangle(double mean, double spread) @ L59
- 方法名:triangle
- 源码定位:L59
- 返回类型:double
- 修饰符:default
参数:
- mean: double
- spread: double
说明:
TODO
default float triangle(float mean, float spread) @ L63
- 方法名:triangle
- 源码定位:L63
- 返回类型:float
- 修饰符:default
参数:
- mean: float
- spread: float
说明:
TODO
default void consumeCount(int rounds) @ L67
- 方法名:consumeCount
- 源码定位:L67
- 返回类型:void
- 修饰符:default
参数:
- rounds: int
说明:
TODO
default int nextInt(int origin, int bound) @ L73
- 方法名:nextInt
- 源码定位:L73
- 返回类型:int
- 修饰符:default
参数:
- origin: int
- bound: int
说明:
TODO
代码
public interface RandomSource {
@Deprecated
double GAUSSIAN_SPREAD_FACTOR = 2.297;
static RandomSource create() {
return create(RandomSupport.generateUniqueSeed());
}
@Deprecated
static RandomSource createThreadSafe() {
return new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
}
static RandomSource create(long seed) {
return new LegacyRandomSource(seed);
}
static RandomSource createThreadLocalInstance() {
return new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
}
static RandomSource createThreadLocalInstance(long seed) {
return new SingleThreadedRandomSource(seed);
}
RandomSource fork();
PositionalRandomFactory forkPositional();
void setSeed(long seed);
int nextInt();
int nextInt(int bound);
default int nextIntBetweenInclusive(int min, int maxInclusive) {
return this.nextInt(maxInclusive - min + 1) + min;
}
long nextLong();
boolean nextBoolean();
float nextFloat();
double nextDouble();
double nextGaussian();
default double triangle(double mean, double spread) {
return mean + spread * (this.nextDouble() - this.nextDouble());
}
default float triangle(float mean, float spread) {
return mean + spread * (this.nextFloat() - this.nextFloat());
}
default void consumeCount(int rounds) {
for (int i = 0; i < rounds; i++) {
this.nextInt();
}
}
default int nextInt(int origin, int bound) {
if (origin >= bound) {
throw new IllegalArgumentException("bound - origin is non positive");
} else {
return origin + this.nextInt(bound - origin);
}
}
}引用的其他类
-
- 引用位置:
构造调用 - 关联成员:
LegacyRandomSource()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RandomSupport.generateUniqueSeed()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
SingleThreadedRandomSource()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ThreadSafeLegacyRandomSource()
- 引用位置: