Interface EquipmentSlotProvider

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface EquipmentSlotProvider
A provider for the preferred equipment slot of an item. This can be used to give non-armor items, such as blocks, an armor slot that they can go in.

The preferred equipment slot of an item stack can be queried using LivingEntity.getEquipmentSlotForItem(ItemStack).

Equipment slot providers can be set with FabricItem.Properties.equipmentSlot(EquipmentSlotProvider).

If the equipment slot is not entity-dependent, you can set Equippable on the item instead of using this provider.

  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.entity.EquipmentSlot
    getEquipmentSlotForItem(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack stack)
    Gets the preferred equipment slot for an item stack.
  • Method Details

    • getEquipmentSlotForItem

      net.minecraft.world.entity.EquipmentSlot getEquipmentSlotForItem(net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.item.ItemStack stack)
      Gets the preferred equipment slot for an item stack.

      If there is no preferred armor equipment slot for the stack, EquipmentSlot.MAINHAND can be returned.

      Callers are expected to check themselves whether the slot is available for the entity using LivingEntity.canUseSlot(EquipmentSlot). For example, players cannot use EquipmentSlot.BODY, which is instead used for items like horse armors.

      Parameters:
      entity - the entity
      stack - the item stack
      Returns:
      the preferred equipment slot