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

Register Enchantment

Discussion in 'Development' started by FresherGAMING, Mar 7, 2022.

  1. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    I want to register fortune enchantment, but there is an error

    The error :
    PHP:
    2022-03-07 [05:22:50.484] [Server thread/CRITICAL]: ArgumentCountError"Expected exactly 0 arguments, 2 passed" (EXCEPTIONin "pmsrc/src/utils/RegistryTrait" at line 91
    --- Stack trace ---
      
    #0 plugins/LytraEnchantShop/src/LES/MainPlugin(67): pocketmine\item\enchantment\VanillaEnchantments::__callStatic(string[8] register, array[2])
      #1 plugins/LytraEnchantShop/src/LES/MainPlugin(44): LES\MainPlugin->registerTypes()
      #2 pmsrc/src/plugin/PluginBase(95): LES\MainPlugin->onLoad()
      #3 pmsrc/src/plugin/PluginManager(214): pocketmine\plugin\PluginBase->__construct(object DevTools\FolderPluginLoader#24899, object pocketmine\Server#10, object pocketmine\plugin\PluginDescription#25014, string[100] /storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/plugin_d, string[96] /storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/plugins/, object pocketmine\plugin\DiskResourceProvider#24997)
      #4 pmsrc/src/plugin/PluginManager(356): pocketmine\plugin\PluginManager->internalLoadPlugin(string[96] /storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/plugins/, object DevTools\FolderPluginLoader#24899, object pocketmine\plugin\PluginDescription#25014)
      #5 pmsrc/src/Server(1005): pocketmine\plugin\PluginManager->loadPlugins(string[80] /storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/plugins/)
      #6 pmsrc/src/PocketMine(304): pocketmine\Server->__construct(object BaseClassLoader#2, object pocketmine\utils\MainLogger#3, string[72] /storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/, string[80] /storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/plugins/)
      #7 pmsrc/src/PocketMine(327): pocketmine\server()
      #8 pmsrc(11): require(string[116] phar:///storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/P)
    --- End of exception information ---
    2022-03-07 [05:22:50.484] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashedCreating a crash dump
    2022
    -03-07 [05:22:50.489] [Server thread/EMERGENCY]: Please upload the "/storage/emulated/0/Android/data/io.scer.pocketmine/files/PocketMine-MP/crashdumps/Mon_Mar_7-05.22.50-UTC_2022.log" file to the Crash Archive and submit the link to the Bug Reporting pageGive as much info as you can.
    2022-03-07 [05:22:55.501] [Server thread/EMERGENCY]: Failed to communicate with crash archiveCould not resolve hostcrash.pmmp.io
    2022
    -03-07 [05:22:55.501] [Server thread/EMERGENCY]: Forcing server shutdown
    The code :
    PHP:
        public function onLoad() : void{
            
    $this->registerTypes();
        }

        public function 
    registerTypes() : void{
            
    VanillaEnchantments::register("FORTUNE", new Enchantment(KnownTranslationFactory::enchantment_lootBonusDigger(), Rarity::UNCOMMONItemFlags::DIGItemFlags::SHEARS3));
        }
     
  2. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    Can you tell me what the error means ?
     
  3. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    I use pm4
     
  4. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    thank you, btw the code that I shown above, I'm just following how the pocketmine/item/enchantment/vanilla enchantments do
     
  5. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    one more, how to apply enchantment that I made to my item ?
     
  6. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    like this ?

    PHP:
    $item->addEnchantment(new EnchantmentInstance(VanillaEnchantments::FORTUNE(), 1));
     
  7. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    I tried and it seems like the enchantment didn't registered, and when I /enchant, the enchantment didn't registered

    I think there is something wrong in the code
    PHP:
        public function onLoad() : void{
            
    EnchantmentIdMap::getInstance()->register(100, new Enchantment('FORTUNE'Rarity::UNCOMMONItemFlags::ALLItemFlags::NONE3));
        }
    The error :
    PHP:
    2022-03-09 [14:18:07.624] [Server thread/CRITICAL]: Error"No such registry member: pocketmine\item\enchantment\VanillaEnchantments::FORTUNE" (EXCEPTIONin "pmsrc/src/utils/RegistryTrait" at line 96
     
  8. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    I've call the event, this is the event that I call
    PHP:
    use pocketmine\plugin\PluginBase;

    use 
    pocketmine\player\Player;
    use 
    pocketmine\Server;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    use 
    pocketmine\item\Item;
    use 
    pocketmine\item\Tool;
    use 
    pocketmine\item\Sword;
    use 
    pocketmine\item\Armor;
    use 
    pocketmine\item\Bow;
    use 
    pocketmine\item\Durable;

    use 
    pocketmine\item\enchantment\Enchantment;
    use 
    pocketmine\item\enchantment\EnchantmentInstance;
    use 
    pocketmine\item\enchantment\VanillaEnchantments;
    use 
    pocketmine\item\enchantment\Rarity;
    use 
    pocketmine\item\enchantment\ItemFlags;

    use 
    pocketmine\data\bedrock\EnchantmentIdMap;

    use 
    pocketmine\lang\KnownTranslationFactory;

    use 
    pocketmine\network\mcpe\protocol\PlaySoundPacket;

    use 
    onebone\economyapi\EconomyAPI;

    use 
    jojoe77777\FormAPI\SimpleForm;
    use 
    jojoe77777\FormAPI\CustomForm;
    When I enchant my item with sharpness, efficiency, etc that are already registered in pocketmine, It work
     
  9. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    Sorry, I'm still a beginner on making plugin
     
  10. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    now the problem is the enchantment didn't shown on the item
     
  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.