Potion.java
net.minecraft.client.color.item.Potion
信息
- 全限定名:net.minecraft.client.color.item.Potion
- 类型:public record
- 包:net.minecraft.client.color.item
- 源码路径:src/main/java/net/minecraft/client/color/item/Potion.java
- 起始行号:L17
- 实现:ItemTintSource
- 职责:
TODO
字段/常量
MAP_CODEC- 类型:
MapCodec<Potion> - 修饰符:
public static final - 源码定位:
L18 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public Potion() @ L22
- 构造器名:Potion
- 源码定位:L22
- 修饰符:public
参数:
- 无
说明:
TODO
方法
下面的方法块按源码顺序生成。
public int calculate(ItemStack itemStack, ClientLevel level, LivingEntity owner) @ L26
- 方法名:calculate
- 源码定位:L26
- 返回类型:int
- 修饰符:public
参数:
- itemStack: ItemStack
- level: ClientLevel
- owner: LivingEntity
说明:
TODO
public MapCodec<Potion> type() @ L32
- 方法名:type
- 源码定位:L32
- 返回类型:MapCodec
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public record Potion(int defaultColor) implements ItemTintSource {
public static final MapCodec<Potion> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(ExtraCodecs.RGB_COLOR_CODEC.fieldOf("default").forGetter(Potion::defaultColor)).apply(i, Potion::new)
);
public Potion() {
this(-13083194);
}
@Override
public int calculate(ItemStack itemStack, @Nullable ClientLevel level, @Nullable LivingEntity owner) {
PotionContents contents = itemStack.get(DataComponents.POTION_CONTENTS);
return contents != null ? ARGB.opaque(contents.getColorOr(this.defaultColor)) : ARGB.opaque(this.defaultColor);
}
@Override
public MapCodec<Potion> type() {
return MAP_CODEC;
}
}引用的其他类
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ARGB.opaque()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: