Destroying Obsidian with TNT

Discussion in 'Development' started by BlobKing21, Dec 23, 2019.

  1. BlobKing21

    BlobKing21 Creeper

    Messages:
    1
    I know, I know...another obsidian thread, but this time it's mainly to do with making the obsidian blow up after a couple of hits with TNT instead of just one explosion.
    PHP:
    <?php

    declare(strict_types=1);

    namespace 
    BlobKing21\ObbyDestroyer;

    use 
    pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\block\Block;
    use 
    pocketmine\block\Obsidian;
    use 
    pocketmine\block\BlockFactory;

    class 
    Main extends PluginBase implements Listener
    {
        public function 
    onEnable()
        {
            
    BlockFactory::registerBlock(new MyObsidian(), true);
        }
    }

    class 
    MyObsidian extends \pocketmine\block\Obsidian
    {
        public function 
    getBlastResistance() : float
        
    {
              return 
    7.5;//same as stone
        
    }
    }
    This code works, but as I previously said, I want to make some way of blowing up the obsidian after, say 4 times. If you guys could point me in the right direction of how to do this, that will be greatly appreciated, Thanks!

    Edit: I know that I could just set the hardness to 77, and it be the hardest block that TNT can break, but that isn't the way I want it to break, just so you know!
     
    Last edited: Dec 23, 2019
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,449
    GitHub:
    jasonwynn10
    on block break, increment a counter. if counter > 4 actually break the block
     
    HimbeersaftLP likes this.

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.