RandomSequence.java
net.minecraft.world.RandomSequence
信息
- 全限定名:net.minecraft.world.RandomSequence
- 类型:public class
- 包:net.minecraft.world
- 源码路径:src/main/java/net/minecraft/world/RandomSequence.java
- 起始行号:L11
- 职责:
TODO
字段/常量
-
CODEC- 类型:
Codec<RandomSequence> - 修饰符:
public static final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
source- 类型:
XoroshiroRandomSource - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public RandomSequence(XoroshiroRandomSource source) @ L17
- 构造器名:RandomSequence
- 源码定位:L17
- 修饰符:public
参数:
- source: XoroshiroRandomSource
说明:
TODO
public RandomSequence(long seed, Identifier key) @ L21
- 构造器名:RandomSequence
- 源码定位:L21
- 修饰符:public
参数:
- seed: long
- key: Identifier
说明:
TODO
public RandomSequence(long seed, Optional<Identifier> key) @ L25
- 构造器名:RandomSequence
- 源码定位:L25
- 修饰符:public
参数:
- seed: long
- key: Optional
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static XoroshiroRandomSource createSequence(long seed, Optional<Identifier> key) @ L29
- 方法名:createSequence
- 源码定位:L29
- 返回类型:XoroshiroRandomSource
- 修饰符:private static
参数:
- seed: long
- key: Optional
说明:
TODO
public static RandomSupport.Seed128bit seedForKey(Identifier key) @ L38
- 方法名:seedForKey
- 源码定位:L38
- 返回类型:RandomSupport.Seed128bit
- 修饰符:public static
参数:
- key: Identifier
说明:
TODO
public RandomSource random() @ L42
- 方法名:random
- 源码定位:L42
- 返回类型:RandomSource
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class RandomSequence {
public static final Codec<RandomSequence> CODEC = RecordCodecBuilder.create(
i -> i.group(XoroshiroRandomSource.CODEC.fieldOf("source").forGetter(r -> r.source)).apply(i, RandomSequence::new)
);
private final XoroshiroRandomSource source;
public RandomSequence(XoroshiroRandomSource source) {
this.source = source;
}
public RandomSequence(long seed, Identifier key) {
this(createSequence(seed, Optional.of(key)));
}
public RandomSequence(long seed, Optional<Identifier> key) {
this(createSequence(seed, key));
}
private static XoroshiroRandomSource createSequence(long seed, Optional<Identifier> key) {
RandomSupport.Seed128bit seed128bit = RandomSupport.upgradeSeedTo128bitUnmixed(seed);
if (key.isPresent()) {
seed128bit = seed128bit.xor(seedForKey(key.get()));
}
return new XoroshiroRandomSource(seed128bit.mixed());
}
public static RandomSupport.Seed128bit seedForKey(Identifier key) {
return RandomSupport.seedFromHashOf(key.toString());
}
public RandomSource random() {
return this.source;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
RandomSupport.seedFromHashOf(), RandomSupport.upgradeSeedTo128bitUnmixed()
- 引用位置:
-
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
XoroshiroRandomSource()
- 引用位置: