Explosion: add exception throws for bad arguments

This commit is contained in:
Dylan K. Taylor 2018-03-11 13:06:29 +00:00
parent 69b3bb183d
commit f2f8c235e7

View File

@ -71,11 +71,18 @@ class Explosion{
* @param Entity|Block $what
*/
public function __construct(Position $center, float $size, $what = null){
$this->level = $center->getLevel();
$this->source = $center;
$this->size = max($size, 0);
$this->what = $what;
$this->level = $center->getLevel();
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);
}