Interface FabricItemStack
ItemStack.
This interface is automatically implemented on all item stacks via Mixin and interface injection.-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanBeEnchantedWith(RegistryEntry<Enchantment> enchantment, EnchantingContext context) Determines whether thisItemStackcan be enchanted with the givenEnchantment.default StringGets the namespace of the mod or datapack that created this item.default ItemStackReturn a leftover item for use in recipes.
-
Method Details
-
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 thisItemStackcan be enchanted with the givenEnchantment.When checking whether an enchantment can be applied to an
ItemStack, use this method instead ofEnchantment.isAcceptableItem(ItemStack)orEnchantment.isPrimaryItem(ItemStack), with the appropriateEnchantingContext.- Parameters:
enchantment- the enchantment to checkcontext- the context in which the enchantment is being checked- Returns:
- whether the enchantment is allowed to apply to the stack
- See Also:
-
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
-