mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +00:00
Explosion: add exception throws for bad arguments
This commit is contained in:
parent
69b3bb183d
commit
f2f8c235e7
@ -71,11 +71,18 @@ class Explosion{
|
|||||||
* @param Entity|Block $what
|
* @param Entity|Block $what
|
||||||
*/
|
*/
|
||||||
public function __construct(Position $center, float $size, $what = null){
|
public function __construct(Position $center, float $size, $what = null){
|
||||||
$this->level = $center->getLevel();
|
|
||||||
$this->source = $center;
|
$this->source = $center;
|
||||||
$this->size = max($size, 0);
|
$this->level = $center->getLevel();
|
||||||
$this->what = $what;
|
if($this->level === null){
|
||||||
|
throw new \InvalidArgumentException("Position does not have a valid level");
|
||||||
|
}
|
||||||
|
|
||||||
|
if($size <= 0){
|
||||||
|
throw new \InvalidArgumentException("Explosion radius must be greater than 0, got $size");
|
||||||
|
}
|
||||||
|
$this->size = $size;
|
||||||
|
|
||||||
|
$this->what = $what;
|
||||||
$this->subChunkHandler = new SubChunkIteratorManager($this->level, false);
|
$this->subChunkHandler = new SubChunkIteratorManager($this->level, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user