Interface ItemInstanceExtension
- All Known Subinterfaces:
IItemStackExtension, ItemInstance
- All Known Implementing Classes:
ItemStack, ItemStackTemplate
public interface ItemInstanceExtension
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanPerformAction(ItemAbility itemAbility) Queries if an item can perform the given action.default intgetEnchantmentLevel(Holder<Enchantment> enchantment) Gets the gameplay level of the target enchantment on this stack.default ItemEnchantmentsGets all enchantments from NBT.private ItemInstanceself()
-
Method Details
-
self
-
canPerformAction
Queries if an item can perform the given action. SeeItemAbilitiesfor a description of each stock action- Parameters:
itemAbility- The action being queried- Returns:
- True if the stack can perform the action
-
getTagEnchantments
Gets all enchantments from NBT. UseIItemStackExtension.getAllEnchantments(HolderLookup.RegistryLookup)for gameplay logic. -
getEnchantmentLevel
Gets the gameplay level of the target enchantment on this stack.Use in place of
EnchantmentHelper.getTagEnchantmentLevel(Holder, ItemInstance)for gameplay logic.Use
EnchantmentHelper.getEnchantmentsForCrafting(ItemStack)andEnchantmentHelper.setEnchantments(ItemStack, ItemEnchantments)when modifying the item's enchantments.- Parameters:
enchantment- The enchantment being checked for.- Returns:
- The level of the enchantment, or 0 if not present.
-