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

Explosions does not work..

Discussion in 'Development' started by 65xGamer, Apr 3, 2018.

  1. 65xGamer

    65xGamer Spider

    Messages:
    7
    The Explosion dosnt wrk:
    PHP:
    <?php
    namespace gr;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\entity\ProjectileHitEvent;
    use 
    pocketmine\level\Position;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\level\Explosion;
    use 
    pocketmine\entity\projectile\Egg;

    class 
    Grenade extends PluginBase implements Listener {

        public function 
    onEnable(){
            
    $this->getLogger()->info("Plugin Enabled");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
       
        public function 
    onGrenadeThrow(ProjectileHitEvent $ev){
            if(
    $ev->getEntity() instanceof Egg){
                
    $explosion = new Explosion(new Position($ev->getEntity()->getX(), $ev->getEntity()->getY(), $ev->getEntity()->getZ(), $ev->getEntity()->getLevel()), 4null);
                
    $explosion->explodeA();
            }
        }
       
        public function 
    onJoin(PlayerJoinEvent $ev){
            if(
    $ev->getPlayer()->isOp()){
                
    $ev->getPlayer()->sendMessage("┬žeYou are using Grenade version: 1.0");
            } else {

            }   
        }
    }
    ?>
     
  2. HimbeersaftLP

    HimbeersaftLP Wither Skeleton

    Messages:
    1,310
    GitHub:
    HimbeersaftLP
    I know absolutely nothing about Explosions, but are you sure it passes that if?
    And are there any errors?
     
  3. 65xGamer

    65xGamer Spider

    Messages:
    7
    Nope no errors
     
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Baby Zombie

    Messages:
    167
    Same, I think the event is bugged or something because the explotions worked on CobaltGuns (I tested with an older pmmp version tho)
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Baby Zombie

    Messages:
    167
    Btw, you can remove this code (it is useless - on the join event):

    PHP:
     else {

            }
     
  6. TheDiamondYT

    TheDiamondYT Zombie Verified

    Messages:
    296
    GitHub:
    TheDiamondYT1
    Cant you just use $event->getEntity()->getPosition()
     
  7. 65xGamer

    65xGamer Spider

    Messages:
    7
    Same thing
     
  8. MineBuilderFR

    MineBuilderFR Creeper

    Messages:
    2
    GitHub:
    MineBuilderFR
    > ExplosionA is for 'Calculated blocks that will be affected by the explosion'
    > ExplosionB is to create the explosion from the blocks given by the explosionA (I express myself very badly sorry x))

    So if you just use $explosion->explodeA () it will only give the blocks broken but will not create the explosion
    If you only use $explosion-> explodeB() it will create an explosion yes, but no blocks will be broken.

    So to create an explosion that calculates the broken blocks and removes them it is necessary to use:

    PHP:
    $explosion = new Explosion(new Position($en>getX(), $en->getY(), $en>getZ(), $en->getLevel()), 4null);
    $explosion->explosionA();
    $explosion->explosionB();
    https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/level/Explosion.php#L92#L257
     
  9. TheDiamondYT

    TheDiamondYT Zombie Verified

    Messages:
    296
    GitHub:
    TheDiamondYT1
    it would be better to do it that way instead of constructing a new class.
     
  10. 65xGamer

    65xGamer Spider

    Messages:
    7
    I mean its the same, i tried it and its the same error
     
  11. 65xGamer

    65xGamer Spider

    Messages:
    7
    so i have to use:
    PHP:
    explosion->explosionA();
    $explosion->explosionB();
    to make it work?
     
  12. MineBuilderFR

    MineBuilderFR Creeper

    Messages:
    2
    GitHub:
    MineBuilderFR
    Yep
     
  13. TheDiamondYT

    TheDiamondYT Zombie Verified

    Messages:
    296
    GitHub:
    TheDiamondYT1
    i didnt say it would fix your problem
     
  14. 65xGamer

    65xGamer Spider

    Messages:
    7
    it worked but the blocks doesnt explode
     
  15. Khaled

    Khaled Witch

    Messages:
    58
    nvm i fixed it, and yes i'm 65xGamer
     

Share This Page