1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Add Enchantments

Discussion in 'Development' started by ethaniccc, Feb 16, 2020.

  1. ethaniccc

    ethaniccc Baby Zombie

    Messages:
    189
    GitHub:
    ethaniccc
    So currently, in my KitGUI plugin which I have right now, I have this line of code:

    $p->getInventory()->addItem(Item::get(267, 0, 1)->setCustomName("§aWitch Blade"));

    The problem is, I don't know how to add enchantments to these items, so if anyone could help..? :D
    Thanks alot in advance <3 (no homo)
    ~ ethaniccc
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    PHP:
    $i Item::get(ItemIds::IRON_SWORD);
            
    $i->setCustomName("§aWitch Blade");
            
    $e Enchantment::getEnchantment(Enchantment::EFFICIENCY);
            
    $i->addEnchantment(new EnchantmentInstance($e,1));
            
    $p->getInventory()->addItem($i);
     
    ethaniccc and GamakCZ like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.