ConstantInt.java
net.minecraft.util.valueproviders.ConstantInt
信息
- 全限定名:net.minecraft.util.valueproviders.ConstantInt
- 类型:public record
- 包:net.minecraft.util.valueproviders
- 源码路径:src/main/java/net/minecraft/util/valueproviders/ConstantInt.java
- 起始行号:L8
- 实现:IntProvider
- 职责:
TODO
字段/常量
-
ZERO- 类型:
ConstantInt - 修饰符:
public static final - 源码定位:
L9 - 说明:
TODO
- 类型:
-
MAP_CODEC- 类型:
MapCodec<ConstantInt> - 修饰符:
public static final - 源码定位:
L10 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static ConstantInt of(int value) @ L14
- 方法名:of
- 源码定位:L14
- 返回类型:ConstantInt
- 修饰符:public static
参数:
- value: int
说明:
TODO
public int sample(RandomSource random) @ L18
- 方法名:sample
- 源码定位:L18
- 返回类型:int
- 修饰符:public
参数:
- random: RandomSource
说明:
TODO
public int minInclusive() @ L23
- 方法名:minInclusive
- 源码定位:L23
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public int maxInclusive() @ L28
- 方法名:maxInclusive
- 源码定位:L28
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public MapCodec<ConstantInt> codec() @ L33
- 方法名:codec
- 源码定位:L33
- 返回类型:MapCodec
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L38
- 方法名:toString
- 源码定位:L38
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public record ConstantInt(int value) implements IntProvider {
public static final ConstantInt ZERO = new ConstantInt(0);
public static final MapCodec<ConstantInt> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(Codec.INT.fieldOf("value").forGetter(ConstantInt::value)).apply(i, ConstantInt::of)
);
public static ConstantInt of(int value) {
return value == 0 ? ZERO : new ConstantInt(value);
}
@Override
public int sample(RandomSource random) {
return this.value;
}
@Override
public int minInclusive() {
return this.value;
}
@Override
public int maxInclusive() {
return this.value;
}
@Override
public MapCodec<ConstantInt> codec() {
return MAP_CODEC;
}
@Override
public String toString() {
return Integer.toString(this.value);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置: