IsKeybindDown.java
net.minecraft.client.renderer.item.properties.conditional.IsKeybindDown
信息
- 全限定名:net.minecraft.client.renderer.item.properties.conditional.IsKeybindDown
- 类型:public record
- 包:net.minecraft.client.renderer.item.properties.conditional
- 源码路径:src/main/java/net/minecraft/client/renderer/item/properties/conditional/IsKeybindDown.java
- 起始行号:L17
- 实现:ConditionalItemModelProperty
- 职责:
TODO
字段/常量
-
KEYBIND_CODEC- 类型:
Codec<KeyMapping> - 修饰符:
private static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
MAP_CODEC- 类型:
MapCodec<IsKeybindDown> - 修饰符:
public static final - 源码定位:
L22 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public boolean get(ItemStack itemStack, ClientLevel level, LivingEntity owner, int seed, ItemDisplayContext displayContext) @ L26
- 方法名:get
- 源码定位:L26
- 返回类型:boolean
- 修饰符:public
参数:
- itemStack: ItemStack
- level: ClientLevel
- owner: LivingEntity
- seed: int
- displayContext: ItemDisplayContext
说明:
TODO
public MapCodec<IsKeybindDown> type() @ L31
- 方法名:type
- 源码定位:L31
- 返回类型:MapCodec
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public record IsKeybindDown(KeyMapping keybind) implements ConditionalItemModelProperty {
private static final Codec<KeyMapping> KEYBIND_CODEC = Codec.STRING.comapFlatMap(id -> {
KeyMapping mapping = KeyMapping.get(id);
return mapping != null ? DataResult.success(mapping) : DataResult.error(() -> "Invalid keybind: " + id);
}, KeyMapping::getName);
public static final MapCodec<IsKeybindDown> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(KEYBIND_CODEC.fieldOf("keybind").forGetter(IsKeybindDown::keybind)).apply(i, IsKeybindDown::new)
);
@Override
public boolean get(ItemStack itemStack, @Nullable ClientLevel level, @Nullable LivingEntity owner, int seed, ItemDisplayContext displayContext) {
return this.keybind.isDown();
}
@Override
public MapCodec<IsKeybindDown> type() {
return MAP_CODEC;
}
}引用的其他类
-
- 引用位置:
字段/方法调用 - 关联成员:
KeyMapping.get()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: