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

Solved setDrops();

Discussion in 'Plugin Help' started by Fritures, May 13, 2019.

  1. Fritures

    Fritures Spider Jockey

    Messages:
    47
    Hello i want to if i player break a beetroot seeds i give for the player magma cream and beetroot seeds
    But it's don't work and i don't had anything errors
    My code :
    PHP:
    <?php

    namespace Fritures\ItemCore\Ajouts;

    use 
    Fritures\ItemCore\Main;
    use 
    pocketmine\Player;
    use 
    pocketmine\item\Item;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\block\BlockBreakEvent;

    class 
    WeedSeed implements Listener {

        private 
    $plugin null;

        public function 
    __construct(Main $plugin){
            
    $this->plugin $plugin;
        }
        
        public function 
    getPlugin() : ?Main
        
    {
            return 
    $this->plugin;
        }
        
        public function 
    onBreak(BlockBreakEvent $event){
        
            
    $block $event->getBlock();
            
    $rand mt_rand(120);
            if(
    $block->getId() == 244){
                if(
    $block->getDamage() >= 7){
                
                    if(
    $rand == 1){
                    
                        
    $event->setDrops([Item::get(378), Item::get(435)]);
                    
                    } else {
                    
                    
    $event->setDrops([Item::get(435)]);
                    
                    }
                
                }

            }
        
        }

    }

    ?>
     
  2. Mohagames205

    Mohagames205 Spider Jockey

    Messages:
    26
    GitHub:
    mohagames205
    Hi, you will have to change $block->getId() to $block->getItemId()
     
  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.