I'm trying to basically remove the terrain damage from explosions by setting the effected blocks back to their old block type but I keep getting this same error.... Code: PHP: public function onExplode(EntityExplodeEvent $event) { $block = $event->getBlockList(); foreach($block as $blocks) { $blocks->getLevel()->setBlock(new Vector3($blocks->getX(), $blocks->getY(), $blocks->getZ(), Block::get($blocks->getId()))); } } Error: Code: [18:43:36] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\entity\EntityExplodeEvent' to 'ExploasionControl v1': Argument 2 passed to pocketmine\level\Level::setBlock() must be an instance of pocketmine\block\Block, none given, called in C:\Users\Admin\Desktop\PocketMine\Plugin Tests\plugins\ExplosionControl\src\ExplosionControl\Main.php on line 55 and defined on ExplosionControl\Main [18:43:36] [Server thread/NOTICE]: InvalidArgumentException: "Argument 2 passed to pocketmine\level\Level::setBlock() must be an instance of pocketmine\block\Block, none given, called in C:\Users\Admin\Desktop\PocketMine\Plugin Tests\plugins\ExplosionControl\src\ExplosionControl\Main.php on line 55 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/level/Level__32bit" at line 1354 any help would be appreciated, Thanks
You placed the closing parenthesis at the wrong position. The pair of parentheses after Vector3 should only include xyz and the Block should be outside.
Now it dose absolutely nothing when TNT explodes, no errors in the console and it doesn't replace the blocks .-. PHP: public function onExplode(EntityExplodeEvent $event) { $block = $event->getBlockList(); foreach($block as $blocks) { $blocks->getLevel()->setBlock(new Vector3($blocks->getX(), $blocks->getY(), $blocks->getZ()), Block::get($blocks->getId())); } }
Why Block::get($blocks) instead of directly $blocks? Anyway, consider setting the blocks one tick later.
That's what I'm going to do but I still want it to damage players so I'll have to add an explosion to the level and cancel the terrain damage or find away to cancel the terrain damage directly from the TNT.