Solved Add enchantment to item stack

Discussion in 'Plugin Development' started by PureIndianSkillz, Jul 30, 2013.

Thread Status:
Not open for further replies.
  1. how would I add an enchantment to an item stack? ive been trying to figure it out but cant here is what i have
    1. ItemStack stonesword = new ItemStack(Material.STONE_SWORD, 1, Enchantment.DAMAGE_UNDEAD ???);
  2. Code:java
    1. ItemStack testEnchant = new ItemStack (Material.BOW, 1);
    2. ItemMeta testEnchantMeta = testEnchant.getItemMeta();
    3. testEnchantMeta.addEnchant(Enchantment.ARROW_FIRE, 10, true);
    4. testEnchant.setItemMeta(testEnchantMeta);

    There you go :>
    maxmar628 and TheUndeadGamer101 like this.
  3. Offline


    ItemStack item = new ItemStack(Material.BOW, 1);
    item.addEnchantment(Enchantment.ARROW_FIRE, 2);
    You use ItemMeta to store enchantments, for example in books.
    PureIndianSkillz likes this.
  4. Use @Seadragon91's way, not Disturbed's.
  5. KingFaris11, my way works. I do it that way so that I can also add a title easily.
  6. Offline


    I think he want to have the enchantment on the item, for using, not for storing it.
    KingFaris11 likes this.
  7. Seadragon91 Ah! In that case he should go with what you described.
  8. Disturbed_Creator
    That's exactly why I said that. :)
  9. thanks everyone it worked
  10. Thank you so much, enchantments were breaking my kit command until now :)
Thread Status:
Not open for further replies.

Share This Page