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

Stupid EnchantmentInstance

Discussion in 'Development' started by TwistedAsylumMC, Mar 29, 2018.

  1. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    Trying to make kits plugin, im using TeaSpoon to register some non registered enchants in pmmp and i get this error
    Code:
    29.03 19:12:50 [Server] Server thread/CRITICAL TypeError: "Argument 1 passed to pocketmine\item\enchantment\EnchantmentInstance::__construct() must be an instance of pocketmine\item\enchantment\Enchantment, null given, called in /plugins/AnvardKitPvP/src/Anvard/Kits/KitCommand.php on line 50" (EXCEPTION) in "src/pocketmine/item/enchantment/EnchantmentInstance" at line 41
    My code:
    PHP:
    $sword Item::get(Item::DIAMOND_SWORD);
    $sword->addEnchantment(new EnchantmentInstance(Enchantment::getEnchantment(Enchantment::SHARPNESS), 2));
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    The Sharpness enchantment is not automatically registered
    you need to register it beforehand
     
  3. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    TeaSpoon registers it
     
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    Check if the vanilla enchantments option on TeaSpoon is enabled.
     
  5. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    Code:
    enchantments:
     # Weather to enable & register Vanilla Enchantments (Set to false if you're going to use VanillaEnchantments plugin etc...) or not
     register: true
     enchantingTableEnabled: true
     
  6. JackMD

    JackMD Silverfish

    Messages:
    22
    GitHub:
    jackmd
    Code:
    Enchantment::getEnchantment();
    That is used for getting enchantment ID i.e. integer value. Its 9 for Sharpness. For declaring enchants using string it is
    Code:
    Enchantment::SHARPNESS;
     
  7. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    nope, u still need Enchantment::get() because Enchantment::SHARPNESS returns 9
     
  8. di2134876

    di2134876 Spider Jockey

    Messages:
    29
    GitHub:
    dk1234987
    Use VanillaEnchants by TheAz128
     
    TheShinPin 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.