Class EnchantmentHelpers

java.lang.Object
org.cyclops.cyclopscore.helper.EnchantmentHelpers

public class EnchantmentHelpers extends Object
This class contains helper methods to get and set certain enchants and enchantment levels on item stacks.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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 <= 0
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 item
      enchantmentListID - 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 item
      enchantmentListID - 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 item
      enchantmentListID - The id of the enchantment in the enchantment list
      level - 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 item
      enchantment - The enchantment
      level - The new level of the enchantment on the given item