public static final StreamCodec<ByteBuf, InteractionHand> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, h -> h.id);
17
private final int id;
18
19
InteractionHand(final int id) {
20
this.id = id;
21
}
22
23
public HumanoidArm asArm(final HumanoidArm mainArm) {
24
return switch (this) {
25
case MAIN_HAND -> mainArm;
26
case OFF_HAND -> mainArm.getOpposite();
27
};
28
}
29
30
public EquipmentSlot asEquipmentSlot() {
31
return this == MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND;
32
}
33
}
34
Decompiled Minecraft 26.3 source of InteractionHand (net/minecraft/world/InteractionHand.java) with Mojang official mappings, stored verbatim on the site.