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

Add Enchant to Item

Discussion in 'Plugin Help' started by ihs4ncim, Feb 5, 2022.

  1. ihs4ncim

    ihs4ncim Silverfish

    Messages:
    16
    GitHub:
    ihs4ncim
    How do i add fortune enchant to item?
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    You would make your own fortune enchantment and register it.
    Currently, pocketmine doesn't support all of the vanilla enchantments yet. Fortune being one of them.
     
  3. ihs4ncim

    ihs4ncim Silverfish

    Messages:
    16
    GitHub:
    ihs4ncim
    Alright, but how do i register enchant?
     
  4. ihs4ncim

    ihs4ncim Silverfish

    Messages:
    16
    GitHub:
    ihs4ncim
    This is true?
    PHP:
     Enchantment::registerEnchantment(new Enchantment(self::Fortune"Fortune"Enchantment::RARITY_COMMONEnchantment::PICKAXE3));
     
  5. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    It would be like this in PM4
    PHP:
    use pocketmine\data\bedrock\EnchantmentIdMap;
    EnchantmentIdMap::getInstance()->register($id$enchant);
     
    Last edited: Feb 6, 2022
    ihs4ncim likes this.
  6. ihs4ncim

    ihs4ncim Silverfish

    Messages:
    16
    GitHub:
    ihs4ncim
    Okey, thanks. I'll be back if it fails.
     
    minijaham likes this.
  7. ihs4ncim

    ihs4ncim Silverfish

    Messages:
    16
    GitHub:
    ihs4ncim
    what is $enchant ?
     
    Last edited: Mar 29, 2022
  8. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    use pocketmine\item\enchantment\Enchantment;
     
  9. ihs4ncim

    ihs4ncim Silverfish

    Messages:
    16
    GitHub:
    ihs4ncim
    Solved. Sample register code:
    PHP:
    API::register(18, new EnchantFile("EnchantName"Rarity::COMMONItemFlags::DIGItemFlags::NONE3));
     
    minijaham likes 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.