After doing some research and then finally coming to a realization. I discovered that obsidian cannot be blown up using TNT and I was looking for a plugin on Poggit to see if there was one and there wasn't. I wanted to know how you could change a block's durability or hardness if it's an instance of primed TNT for example or if that is even possible in PocketMine.
I Have Not Tested The Code, Test And Ve If there are any serious errors that I correct, even more Sorry (google translate) PHP: public static $obsidians = [];public static $durability = 5;public function addToList(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if(!isset(self::$obsidians[$pos])){ self::$obsidians[$pos] = self::$durability; }}public function existsBlock(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();return isset(self::$obsidians[$pos]);}public function getDurability(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if($this->existsBlock($b)){return self::$obsidians[$pos]; }return self::$durability;}public function reduceDurability(Block $b, int $v = 1){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if($this->existsBlock($b)){ self::$obsidians[$pos] = $this->getDurability($b) - $v;return true;}return false;}public function onExplode(EntityExplodeEvent $e){if($e->isCancelled()) return;$bl = $e->getBlockList();$nbl = [];foreach($bl as $b){if($b->getId() == Item::OBSIDIAN){if($this->existsBlock($b) and $this->getDurability($b) <= 0){$nbl[] = $b; }else{$this->addToBlockList($b);$this->reduceDurability($b);} }else{$nbl[] = $b; } }$e->setBlockList($nbl);}
Thank you for your attempt to help, although I did run into an error with this line. ParseError: "syntax error, unexpected 'public static ' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)" (EXCEPTION) PHP: public static $obsidians = [];
PHP: <?phpnamespace NickteeChunky;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\entity\EntityExplodeEvent;use pocketmine\block\Block;class Main extends PluginBase implements Listener{public static $obsidians = [];public static $durability = 5; public function addToList(Block $b){ $pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName(); if(!isset(self::$obsidians[$pos])){ self::$obsidians[$pos] = self::$durability; } }public function existsBlock(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();return isset(self::$obsidians[$pos]);}public function getDurability(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if($this->existsBlock($b)){return self::$obsidians[$pos]; }return self::$durability;}public function reduceDurability(Block $b, int $v = 1){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if($this->existsBlock($b)){ self::$obsidians[$pos] = $this->getDurability($b) - $v;return true;}return false;}public function onExplode(EntityExplodeEvent $e){if($e->isCancelled()) return;$bl = $e->getBlockList();$nbl = [];foreach($bl as $b){if($b->getId() == Item::OBSIDIAN){if($this->existsBlock($b) and $this->getDurability($b) <= 0){$nbl[] = $b; }else{$this->addToBlockList($b);$this->reduceDurability($b);} }else{$nbl[] = $b; } }$e->setBlockList($nbl);}
PHP: <?phpnamespace NickteeChunky;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\entity\EntityExplodeEvent;use pocketmine\block\Block;class Main extends PluginBase implements Listener{public $obsidians = [];public static $durability = 5; public function addToList(Block $b){ $pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName(); if(!isset($this->obsidians[$pos])){ $this->obsidians[$pos] = self::$durability; } }public function existsBlock(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();return isset($this->obsidians[$pos]);}public function getDurability(Block $b){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if($this->existsBlock($b)){return $this->obsidians[$pos]; }return self::$durability;}public function reduceDurability(Block $b, int $v = 1){$pos = $b->getFloorX()."_".$b->getFloorY()."_".$b->getFloorZ()."_".$b->getLevel()->getName();if($this->existsBlock($b)){ $this->obsidians[$pos] = $this->getDurability($b) - $v;return true;}return false;}public function onExplode(EntityExplodeEvent $e){if($e->isCancelled()) return;$bl = $e->getBlockList();$nbl = [];foreach($bl as $b){if($b->getId() == Item::OBSIDIAN){if($this->existsBlock($b) and $this->getDurability($b) <= 0){$nbl[] = $b; }else{$this->addToBlockList($b);$this->reduceDurability($b);} }else{$nbl[] = $b; } }$e->setBlockList($nbl);}}
You would have to override the block PHP: class Main extends PluginBase{public function onEnable(){BlockFactory::registerBlock(new MyObsidian());}}class MyObsidian extends \pocketmine\block\Obsidian{public function getBlastResistance() : float{return 7.5;//same as stone}}
I got an error for "Trying to overwrite an already registered block", and when I remove the onEnable function but the MyObsidian file, it didn't make a difference and the obsidian still wouldn't blow up.
Amazing! It works, thank you so much @wolfdale, @HeyDeniis_ . I just have one question, if I want to set it so obsidian is broken every 4 explosions, what blast resistance would I have to set it to? Or what do I set the $durability to in main?