Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ConsumeItemEvent

Comments in 'Plugin Development' started by Creeperface, Jun 21, 2015.

  1. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i want to consume rotten flesh but it doesn´t work :/ nothing happens
    PHP:
    public function onEat(PlayerItemConsumeEvent $e){
            
    $p $e->getPlayer();
            
    $i $e->getItem();
            if(
    $i->getId() == 367){
                
    $p->getInventory()->setItem($this->getHeldItemSlot(), Item::get(3670$p->getInventory()->getItemInHand()->count 1));
                
    $rnd rand(15);
                
    $rnd2 rand(1020);
                switch(
    $rnd){
                    case 
    1:
                        
    $p->setHealth($p->getHealth() +1);
                        break;
                    case 
    2:
                        
    $p->setHealth($p->getHealth() +1);
                        
    $effect Effect::getEffect(17);
                        
    $effect->setDuration($rnd2);
                        
    $effect->setAmplifier(1);
                        
    $p->addEffect($effect);
                        break;
                    case 
    3:
                        
    $p->setHealth($p->getHealth() +2);
                        
    $effect Effect::getEffect(17);
                        
    $effect->setDuration($rnd2);
                        
    $effect->setAmplifier(1);
                        
    $p->addEffect($effect);
                        break;
                    case 
    4:
                        
    $p->setHealth($p->getHealth() +2);
                        break;
                    case 
    5:
                        
    $effect Effect::getEffect(17);
                        
    $effect->setDuration($rnd2);
                        
    $effect->setAmplifier(1);
                        
    $p->addEffect($effect);
                }
            }
        }

Share This Page

Advertisement