42 private bool $blockBreaking =
true;
44 public function __construct(
46 private float $radius,
47 private readonly ?
Player $player =
null,
48 private float $fireChance = 0.0
50 Utils::checkFloatNotInfOrNaN(
"radius", $radius);
52 throw new \InvalidArgumentException(
"Explosion radius must be positive");
54 Utils::checkFloatNotInfOrNaN(
"fireChance", $fireChance);
55 if($fireChance < 0.0 || $fireChance > 1.0){
56 throw new \InvalidArgumentException(
"Fire chance must be a number between 0 and 1.");
58 parent::__construct($block);
61 public function getRadius() :
float{
65 public function setRadius(
float $radius) :
void{
66 Utils::checkFloatNotInfOrNaN(
"radius", $radius);
68 throw new \InvalidArgumentException(
"Explosion radius must be positive");
70 $this->radius = $radius;
73 public function isBlockBreaking() :
bool{
74 return $this->blockBreaking;
77 public function setBlockBreaking(
bool $affectsBlocks) :
void{
78 $this->blockBreaking = $affectsBlocks;
85 return $this->fireChance > 0;
95 $this->fireChance = 0;
96 }elseif($this->fireChance <= 0){
97 $this->fireChance = Explosion::DEFAULT_FIRE_CHANCE;
105 return $this->fireChance;
115 Utils::checkFloatNotInfOrNaN(
"fireChance", $fireChance);
116 if($fireChance < 0.0 || $fireChance > 1.0){
117 throw new \InvalidArgumentException(
"Fire chance must be a number between 0 and 1.");
119 $this->fireChance = $fireChance;
127 return $this->player;