Hello. I'm updating my plugin Claymores to the new API, and I've learned a lot just from trial and error, but I can't seem to understand how to create an explosion no matter what I try. The docs (found here) are a bit confusing to me. Maybe I'm comparing it too much to the old API. I obviously know how to make the explosion, but I can't seem to figure out how to set the explosion size or position at all. If anyone can make sense of those docs and try to explain what I'm missing, I think I can learn a lot! Thanks
It looks pretty much the same. Just use the explosion class and then do (new Explosion(new Position($x, $y, $z, $level), $size))-> explode()
Hmmm....I did that, and here's the error I'm getting: Spoiler: Error 01:36:42 [NOTICE] A E_RECOVERABLE_ERROR error happened: "Argument 4 passed to pocketmine\level\Position::__construct() must be an instance of pocketmine\level\Level, instance of WeakRef given, called in C:\Users\Darunia18\Desktop\PocketMine-MP-1.4\plugins\ClaymoresSource\src\Darunia18\Claymores\Main.php on line 44 and defined" in "phar://C:/Users/Darunia18/Desktop/PocketMine-MP-1.4/PocketMine-MP.phar/src/pocketmine/level/Position.php" at line 38 01:36:42 [NOTICE] A E_NOTICE error happened: "Undefined property: WeakRef::$level" in "phar://C:/Users/Darunia18/Desktop/PocketMine-MP-1.4/PocketMine-MP.phar/src/pocketmine/level/Explosion.php" at line 75 Fatal error: Call to a member function getBlockID() on a non-object in phar://C:/Users/Darunia18/Desktop/PocketMine-MP-1.4/PocketMine-MP.phar/src/pocketmine/level/Explosion.php on line 75
Use $pos->getLevel() not $pos->level because of WeakRef. Yeah and you have to change all ->level into ->getLevel() now.
Ok. I did that and it got rid of some of the errors, but I'm still getting Spoiler: Errors [NOTICE] A E_NOTICE error happened: "Undefined property: WeakRef::$level" in "phar://C:/Users/Darunia18/Desktop/PocketMine-MP-1.4/PocketMine-MP.phar/src/pocketmine/level/Explosion.php" at line 75 Fatal error: Call to a member function getBlockID() on a non-object in phar://C:/Users/Darunia18/Desktop/PocketMine-MP-1.4/PocketMine-MP.phar/src/pocketmine/level/Explosion.php on line 75
PHP: $entity = $event->getEntity();$explosion = new Explosion(new Position($entity->x, ($entity->y -1), $entity->z, $entity->getLevel()), $this->explosionSize);$explosion->explode(); That's what I have. This is all the code that would be related to the errors (the others are just if statements that I've had no problems with).
Ok. I guess I'll just keep looking through things, ask @shoghicp about it tomorrow Thanks for your help guys! At least I got half the errors fixed!
Awesome. Thank you very much! I'm guessing it was never found because no one's really used the explosion event yet XD
The error is at Explosion.php not the event Well, in fact we aren't even touching the event at all xD https://github.com/PocketMine/PocketMine-MP/issues/1508 pull request sent
Yeah I saw that. Thanks! I guess I'll just start figuring out some other features I wanted to add until he merges and releases the phar Thanks so much for all the help!