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

Solved Obsidian TNT

Discussion in 'Development' started by minijaham, Dec 27, 2020.

  1. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Hey, I came across this thinking of blowing up obsidian with TNT.
    I did a code stealing from BlockHorizon's FactionsPE plugin, and tested the code.

    PHP:

    public function explodeInWater(EntityExplodeEvent $event)
         {
         
    $entity $event->getEntity();
         if (!
    $entity instanceof PrimedTNT) return;
              
    $center $entity->getLevel()->getBlock($entity);
              if (!
    $center instanceof Liquid) return;
                   
    $targets = [];
                   for (
    $i 0$i <= 6$i++) {
                        
    $targets[] = $center->getSide($i);
                   }
                   foreach (
    $targets as $target) {
                        
    $id $target->getId();
                             if (
    $id != && ($id || $id 11) && $id != 49 && $id != 90 && $id != 116 && $id != 119 && $id != 120 && $id != 130) {
                                  
    // Break
                                  
    $target->getLevel()->setBlock($targetBlock::get(0));
                                  echo 
    'Hi';
                             }
                        }
                   }

    public function 
    explosion(EntityExplodeEvent $event)
         {
         
    $entity $event->getEntity();
         if (!
    $entity instanceof PrimedTNT) return;
              
    $center $entity->getLevel()->getBlock($entity);
              
    $targets = [];
              for (
    $i 0$i <= 6$i++) {
                   
    $targets[] = $center->getSide($i);
              }
              foreach (
    $targets as $target) {
                   if (
    $target->getId() === 49) {
                        
    $target->getLevel()->setBlock($targetBlock::get(0));
                        echo 
    'Hi';
                   }
              }
         }
    However, the code isn't working. What could be the problem?
     
  2. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    PrimedTNT class was mis-imported.
     
  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.