Package org.cyclops.cyclopscore.helper
Class EnchantmentHelpers
java.lang.Object
org.cyclops.cyclopscore.helper.EnchantmentHelpers
This class contains helper methods to get and set certain enchants
and enchantment levels on item stacks.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
doesEnchantApply
(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment) Checks if an itemStack has a certain enchantment.static net.minecraft.core.component.DataComponentType
<net.minecraft.world.item.enchantment.ItemEnchantments> getComponentType
(net.minecraft.world.item.ItemStack itemStack) static int
getEnchantmentLevel
(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment) Returns the level of an enchantment given an itemStack.static void
runIterationOnItem
(net.minecraft.world.item.ItemStack itemStack, EnchantmentHelpers.EnchantmentVisitor visitor) static void
setEnchantmentLevel
(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment, int level) Sets the level of an enchantment given an itemStack.
-
Constructor Details
-
EnchantmentHelpers
public EnchantmentHelpers()
-
-
Method Details
-
doesEnchantApply
public static boolean doesEnchantApply(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment) Checks if an itemStack has a certain enchantment.- Parameters:
itemStack
- The itemStack to check.enchantment
- The Enchantment to compare.- Returns:
- If it applies.
-
getEnchantmentLevel
public static int getEnchantmentLevel(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment) Returns the level of an enchantment given an itemStack.- Parameters:
itemStack
- The itemStack which contains the enchanted itemenchantment
- The Enchantment to compare.- Returns:
- The level of the enchantment on the given item
-
getComponentType
public static net.minecraft.core.component.DataComponentType<net.minecraft.world.item.enchantment.ItemEnchantments> getComponentType(net.minecraft.world.item.ItemStack itemStack) -
setEnchantmentLevel
public static void setEnchantmentLevel(net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Holder<net.minecraft.world.item.enchantment.Enchantment> enchantment, int level) Sets the level of an enchantment given an itemStack. Will clear the enchantment if the new level <= 0- Parameters:
itemStack
- The itemStack which contains the enchanted itemenchantment
- The Enchantment to compare.level
- The new level of the enchantment on the given item
-
runIterationOnItem
public static void runIterationOnItem(net.minecraft.world.item.ItemStack itemStack, EnchantmentHelpers.EnchantmentVisitor visitor)
-