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.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
doesEnchantApply
(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.item.enchantment.Enchantment enchantment) Checks if an itemStack has a certain enchantment.static net.minecraft.world.item.enchantment.Enchantment
getEnchantment
(net.minecraft.world.item.ItemStack itemStack, int enchantmentListID) Returns the enchantment given an itemStack and the list id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist)static int
getEnchantmentLevel
(net.minecraft.world.item.ItemStack itemStack, int enchantmentListID) Returns the level of an enchantment given an itemStack and the list id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist)static void
setEnchantmentLevel
(net.minecraft.world.item.ItemStack itemStack, int enchantmentListID, int level) Sets the level of an enchantment given an itemStack and the id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist) Will clear the enchantment if the new level <= 0static void
setEnchantmentLevel
(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.item.enchantment.Enchantment enchantment, int level) Sets the level of an enchantment given an itemStack and the id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist) Will clear the enchantment if the new level <= 0
-
Constructor Details
-
EnchantmentHelpers
public EnchantmentHelpers()
-
-
Method Details
-
doesEnchantApply
public static int doesEnchantApply(net.minecraft.world.item.ItemStack itemStack, 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:
- The id of the enchantment in the enchantmentlist or -1 if it does not apply.
-
getEnchantmentLevel
public static int getEnchantmentLevel(net.minecraft.world.item.ItemStack itemStack, int enchantmentListID) Returns the level of an enchantment given an itemStack and the list id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist)- Parameters:
itemStack
- The itemStack which contains the enchanted itemenchantmentListID
- The id of the enchantment in the enchantment list- Returns:
- The level of the enchantment on the given item
-
getEnchantment
public static net.minecraft.world.item.enchantment.Enchantment getEnchantment(net.minecraft.world.item.ItemStack itemStack, int enchantmentListID) Returns the enchantment given an itemStack and the list id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist)- Parameters:
itemStack
- The itemStack which contains the enchanted itemenchantmentListID
- The id of the enchantment in the enchantment list- Returns:
- The enchantment on the given item
-
setEnchantmentLevel
public static void setEnchantmentLevel(net.minecraft.world.item.ItemStack itemStack, int enchantmentListID, int level) Sets the level of an enchantment given an itemStack and the id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist) Will clear the enchantment if the new level <= 0- Parameters:
itemStack
- The itemStack which contains the enchanted itemenchantmentListID
- The id of the enchantment in the enchantment listlevel
- The new level of the enchantment on the given item
-
setEnchantmentLevel
public static void setEnchantmentLevel(net.minecraft.world.item.ItemStack itemStack, net.minecraft.world.item.enchantment.Enchantment enchantment, int level) Sets the level of an enchantment given an itemStack and the id of the enchantment in the enchantmentlist (see doesEnchantApply() to get the id in the enchantmentlist) Will clear the enchantment if the new level <= 0- Parameters:
itemStack
- The itemStack which contains the enchanted itemenchantment
- The enchantmentlevel
- The new level of the enchantment on the given item
-