Add effecst to items

Discussion in 'Development' started by XiXaFia, Mar 13, 2020.

  1. XiXaFia

    XiXaFia Spider Jockey

    Messages:
    26
    how to add effects to items
     
    Last edited: Mar 13, 2020
  2. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    Please use your hands to write a better description if you want help
     
  3. XiXaFia

    XiXaFia Spider Jockey

    Messages:
    26
    Am i wrong?
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,382
    GitHub:
    HimbeersaftLP
    You mean an effect the player gets while holding or using the item or an enchantment?
     
    Invy55 likes this.
  5. Invy55

    Invy55 Witch

    Messages:
    52
    GitHub:
    invy55
    No you are too general please describe better
     
  6. Asanino

    Asanino Spider

    Messages:
    14
    When Player helds an item:
    PHP:
    public function onItemHeld(PlayerItemHeldEvent $e){
    $player $e->getPlayer();
    $item $e->getItem();
    if(
    $item === Item::TORCH)){
    $ef =new EffectInstance(Effect::getEffect(EffectID), DurationAmplifier);
    $player->addeffect($ef);
    }


    When interacts with item:

    PHP:
     public function onInteract(PlayerInteractEvent $e){
    $player $e->getPlayer();
    $item $e->getItem();
    if(
    $item === Item::TORCH)){
    $ef =new EffectInstance(Effect::getEffect(EffectID), DurationAmplifier);
    $player->addeffect($ef);



     

Share This Page

  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.