Interface FabricItemStack


public interface FabricItemStack
Fabric-provided extensions for ItemStack. This interface is automatically implemented on all item stacks via Mixin and interface injection.
  • Method Details

    • getRecipeRemainder

      default ItemStack getRecipeRemainder()
      Return a leftover item for use in recipes.

      See FabricItem.getRecipeRemainder(ItemStack) for a more in depth description.

      Stack-aware version of Item.getRecipeRemainder().

      Returns:
      the leftover item
    • canBeEnchantedWith

      default boolean canBeEnchantedWith(RegistryEntry<Enchantment> enchantment, EnchantingContext context)
      Determines whether this ItemStack can be enchanted with the given Enchantment.

      When checking whether an enchantment can be applied to an ItemStack, use this method instead of Enchantment.isAcceptableItem(ItemStack) or Enchantment.isPrimaryItem(ItemStack), with the appropriate EnchantingContext.

      Parameters:
      enchantment - the enchantment to check
      context - the context in which the enchantment is being checked
      Returns:
      whether the enchantment is allowed to apply to the stack
      See Also:
    • getCreatorNamespace

      default String getCreatorNamespace()
      Gets the namespace of the mod or datapack that created this item.

      This can be used if, for example, a library mod registers a generic item that other mods can create new variants for, allowing those mods to take credit for those variants if a player wishes to know what mod they come from.

      Should be used instead of querying the item ID namespace to determine what mod an item is from when displaying to the player.

      Defaults to the namespace of the item's own registry entry, except in the cases of potions or enchanted books, in which it uses the namespace of the potion contents or single enchantment applied.

      Note that while it is recommended that this reflect a namespace and/or mod ID, it can technically be any arbitrary string.

      Returns:
      the namespace of the mod that created the item