Ignite TNT when placed

Discussion in 'Development' started by A354-PH, Feb 9, 2019.

  1. A354-PH

    A354-PH Baby Zombie

    Messages:
    177
    GitHub:
    A354-PH
    Hello, how to ignite tnt when its placed?
     
  2. KielKing

    KielKing Zombie

    Messages:
    271
    GitHub:
    kielking
    PHP:
    public function onPlace(BlockPlaceEvent $ev): void{
        
    $item $ev->getItem();
        if(
    $item->getId() === Item::TNT){
            
    $ev->getBlock()->ignite();
        }
    }
     
  3. A354-PH

    A354-PH Baby Zombie

    Messages:
    177
    GitHub:
    A354-PH
    Thank you!
     
  4. KielKing

    KielKing Zombie

    Messages:
    271
    GitHub:
    kielking
    no problem
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    661
    You should set the event's priority to lowest and check if the event is cancelled first. Placing tnts to the lobby world will make them explode even if the event is cancelled.
     

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.