Count.java
net.minecraft.client.renderer.item.properties.numeric.Count
信息
- 全限定名:net.minecraft.client.renderer.item.properties.numeric.Count
- 类型:public record
- 包:net.minecraft.client.renderer.item.properties.numeric
- 源码路径:src/main/java/net/minecraft/client/renderer/item/properties/numeric/Count.java
- 起始行号:L15
- 实现:RangeSelectItemModelProperty
- 职责:
TODO
字段/常量
MAP_CODEC- 类型:
MapCodec<Count> - 修饰符:
public static final - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public float get(ItemStack itemStack, ClientLevel level, ItemOwner owner, int seed) @ L20
- 方法名:get
- 源码定位:L20
- 返回类型:float
- 修饰符:public
参数:
- itemStack: ItemStack
- level: ClientLevel
- owner: ItemOwner
- seed: int
说明:
TODO
public MapCodec<Count> type() @ L27
- 方法名:type
- 源码定位:L27
- 返回类型:MapCodec
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public record Count(boolean normalize) implements RangeSelectItemModelProperty {
public static final MapCodec<Count> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(Codec.BOOL.optionalFieldOf("normalize", true).forGetter(Count::normalize)).apply(i, Count::new)
);
@Override
public float get(ItemStack itemStack, @Nullable ClientLevel level, @Nullable ItemOwner owner, int seed) {
float count = itemStack.getCount();
float maxCount = itemStack.getMaxStackSize();
return this.normalize ? Mth.clamp(count / maxCount, 0.0F, 1.0F) : Mth.clamp(count, 0.0F, maxCount);
}
@Override
public MapCodec<Count> type() {
return MAP_CODEC;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clamp()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: