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

Help with multiple item ids

Discussion in 'Development' started by Azonuno, Oct 5, 2021.

  1. Azonuno

    Azonuno Spider

    Messages:
    12
    Is there a way I can call for more then 1 block item instead of starting a hole new function for the block?



    public function onBreak(BlockBreakEvent $event){

    $block = $event->getBlock();
    $dropItems = $event->getDrops();

    if($block->getId() == 16){ //set block coal
    $event->setCancelled();
    $world = $block->getLevel();

    foreach ($dropItems as $item){
    $world->dropItem($block, $item);
    }
    $world->setBlock($block, BlockFactory::get(0, 0, null)); //sets the block to air

    $this->getScheduler()->scheduleDelayedTask(new sample($this, $block), 20 * 3 );
    }
    }
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    You would make a new if statement.
     
  3. Azonuno

    Azonuno Spider

    Messages:
    12
    Thank u I'm new to php and works perfect !
     
    minijaham likes this.
  4. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    You're doing better than most people here who are "new" to php!
    Well done.


    Of course, assuming that you solved it yourself by actually understanding what I said!
     
    Azonuno and NTT like this.
  5. Azonuno

    Azonuno Spider

    Messages:
    12
    Thank you! I have watched a 5 hour php course video, then watch recap videos to refresh my memory. Thanks for the help!
     
    Axon and NTT like 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.