Package com.teampotato.potacore.item
Class EnchantHelper
java.lang.Object
com.teampotato.potacore.item.EnchantHelper
Provides utility methods for manipulating enchantments on items and enchanted books.
This class supports removing specific enchantments from both regular items and enchanted books.
It handles both Enchantment instances and enchantments identified by ResourceLocation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanremoveEnchantment(@NotNull net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.enchantment.Enchantment enchantment) Removes a specific enchantment from an item stack or enchanted book.static booleanremoveEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceLocation enchantment) Removes a specific enchantment from an item stack using its registry name.static intremoveEnchantments(net.minecraft.world.item.ItemStack stack, @NotNull Iterable<net.minecraft.world.item.enchantment.Enchantment> enchantments) Removes multiple enchantments from an item stack.
-
Constructor Details
-
EnchantHelper
public EnchantHelper()
-
-
Method Details
-
removeEnchantments
public static int removeEnchantments(net.minecraft.world.item.ItemStack stack, @NotNull @NotNull Iterable<net.minecraft.world.item.enchantment.Enchantment> enchantments) Removes multiple enchantments from an item stack.- Parameters:
stack- The item stack to modifyenchantments- Iterable collection of enchantments to remove- Returns:
- Number of enchantments successfully removed from the item
- See Also:
-
removeEnchantment
public static boolean removeEnchantment(net.minecraft.world.item.ItemStack stack, net.minecraft.resources.ResourceLocation enchantment) Removes a specific enchantment from an item stack using its registry name.- Parameters:
stack- The item stack to modifyenchantment- Registry name (ResourceLocation) of the enchantment to remove- Returns:
trueif the enchantment was found and removed,falseotherwise- See Also:
-
removeEnchantment
public static boolean removeEnchantment(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.enchantment.Enchantment enchantment) Removes a specific enchantment from an item stack or enchanted book.Handles both regular items (using "Enchantments" tag) and enchanted books (using "StoredEnchantments" tag). If the resulting NBT becomes empty after removal, the entire NBT tag is cleared.
- Parameters:
stack- The item stack to modify. Must not be empty.enchantment- Enchantment to remove. Must not benull.- Returns:
trueif the enchantment was found and removed,falseotherwise
-