InteractionHand.java

net.minecraft.world.InteractionHand

信息

  • 全限定名:net.minecraft.world.InteractionHand
  • 类型:public enum
  • 包:net.minecraft.world
  • 源码路径:src/main/java/net/minecraft/world/InteractionHand.java
  • 起始行号:L10
  • 职责:

    TODO

字段/常量

  • MAIN_HAND, OFF_HAND

    • 类型: InteractionHand
    • 修饰符: package-private
    • 源码定位: L11
    • 说明:

      TODO

  • BY_ID

    • 类型: IntFunction<InteractionHand>
    • 修饰符: private static final
    • 源码定位: L14
    • 说明:

      TODO

  • STREAM_CODEC

    • 类型: StreamCodec<ByteBuf,InteractionHand>
    • 修饰符: public static final
    • 源码定位: L15
    • 说明:

      TODO

  • id

    • 类型: int
    • 修饰符: private final
    • 源码定位: L16
    • 说明:

      TODO

内部类/嵌套类型

构造器

private InteractionHand(int id) @ L18

  • 构造器名:InteractionHand
  • 源码定位:L18
  • 修饰符:private

参数:

  • id: int

说明:

TODO

方法

下面的方法块按源码顺序生成。

public EquipmentSlot asEquipmentSlot() @ L22

  • 方法名:asEquipmentSlot
  • 源码定位:L22
  • 返回类型:EquipmentSlot
  • 修饰符:public

参数:

说明:

TODO

代码

public enum InteractionHand {
    MAIN_HAND(0),
    OFF_HAND(1);
 
    private static final IntFunction<InteractionHand> BY_ID = ByIdMap.continuous(h -> h.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
    public static final StreamCodec<ByteBuf, InteractionHand> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, h -> h.id);
    private final int id;
 
    private InteractionHand(int id) {
        this.id = id;
    }
 
    public EquipmentSlot asEquipmentSlot() {
        return this == MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND;
    }
}

引用的其他类

  • ByteBufCodecs

    • 引用位置: 方法调用
    • 关联成员: ByteBufCodecs.idMapper()
  • StreamCodec

    • 引用位置: 字段
  • ByIdMap

    • 引用位置: 方法调用
    • 关联成员: ByIdMap.continuous()
  • EquipmentSlot

    • 引用位置: 返回值