Specified enchantment cannot be applied to this itemstack

Discussion in 'Plugin Development' started by UltraMC, Dec 22, 2013.

Thread Status:
Not open for further replies.
  1. Offline


    Why do I get this error on attempt to set item's enchantment (error line is one of 'itemToAdd.addEnchantment'):

    ItemStack itemToAdd = new ItemStack(itemID, itemQTY, itemSUB);
    if (isItABook == true) {
        EnchantmentStorageMeta bookmeta = (EnchantmentStorageMeta) itemToAdd.getItemMeta();
        bookmeta.addStoredEnchant(enchantTYPE, enchantLVL, true);
    } else {
        itemToAdd.addEnchantment(enchantTYPE, enchantLVL);
    Self solved:

    I was trying to add ARROW_DAMAGE to a DIAMOND_SWORD ;-)

    But I've craeted that thing in creative so there is a way to it without error. But how?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 5, 2016
  2. Offline


    Instead of .addEnchantment() use .addUnsafeEnchantment()
    UltraMC likes this.
Thread Status:
Not open for further replies.

Share This Page