PocketMine-MP 5.28.3 git-d5a1007c80fcee27feb2251cf5dcf1ad5a59a85c
Loading...
Searching...
No Matches
EntityPreExplodeEvent.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
25
28use pocketmine\event\CancellableTrait;
31
42
43 private bool $blockBreaking = true;
44
45 public function __construct(
47 protected float $radius,
48 private float $fireChance = 0.0,
49 ){
50 if($radius <= 0){
51 throw new \InvalidArgumentException("Explosion radius must be positive");
52 }
53 Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
54 if($fireChance < 0.0 || $fireChance > 1.0){
55 throw new \InvalidArgumentException("Fire chance must be between 0 and 1.");
56 }
57 $this->entity = $entity;
58 }
59
60 public function getRadius() : float{
61 return $this->radius;
62 }
63
64 public function setRadius(float $radius) : void{
65 if($radius <= 0){
66 throw new \InvalidArgumentException("Explosion radius must be positive");
67 }
68 $this->radius = $radius;
69 }
70
74 public function isIncendiary() : bool{
75 return $this->fireChance > 0;
76 }
77
83 public function setIncendiary(bool $incendiary) : void{
84 if(!$incendiary){
85 $this->fireChance = 0;
86 }elseif($this->fireChance <= 0){
87 $this->fireChance = Explosion::DEFAULT_FIRE_CHANCE;
88 }
89 }
90
94 public function getFireChance() : float{
95 return $this->fireChance;
96 }
97
104 public function setFireChance(float $fireChance) : void{
105 Utils::checkFloatNotInfOrNaN("fireChance", $fireChance);
106 if($fireChance < 0.0 || $fireChance > 1.0){
107 throw new \InvalidArgumentException("Fire chance must be between 0 and 1.");
108 }
109 $this->fireChance = $fireChance;
110 }
111
112 public function isBlockBreaking() : bool{
113 return $this->blockBreaking;
114 }
115
116 public function setBlockBreaking(bool $affectsBlocks) : void{
117 $this->blockBreaking = $affectsBlocks;
118 }
119}