22declare(strict_types=1);
24namespace pocketmine\entity\effect;
30 private Effect $effectType;
31 private int $duration;
32 private int $amplifier;
33 private bool $visible;
34 private bool $ambient;
36 private bool $infinite;
41 public function __construct(
Effect $effectType, ?
int $duration =
null,
int $amplifier = 0,
bool $visible =
true,
bool $ambient =
false, ?
Color $overrideColor =
null,
bool $infinite =
false){
42 $this->effectType = $effectType;
45 $this->visible = $visible;
46 $this->ambient = $ambient;
47 $this->color = $overrideColor ?? $effectType->
getColor();
48 $this->infinite = $infinite;
51 public function getType() :
Effect{
52 return $this->effectType;
59 return $this->duration;
70 if($duration < 0 || $duration >
Limits::INT32_MAX){
71 throw new \InvalidArgumentException(
"Effect duration must be in range 0 - " . Limits::INT32_MAX .
", got $duration");
73 $this->duration = $duration;
86 $newDuration = $this->duration - $ticks;
87 if($newDuration <= 0){
89 $newDuration += Limits::INT32_MAX;
94 $this->duration = $newDuration;
103 return $this->duration <= 0;
106 public function getAmplifier() : int{
107 return $this->amplifier;
114 return $this->amplifier + 1;
121 if($amplifier < 0 || $amplifier > 255){
122 throw new \InvalidArgumentException(
"Amplifier must be in range 0 - 255, got $amplifier");
124 $this->amplifier = $amplifier;
133 return $this->visible;
140 $this->visible = $visible;
151 return $this->ambient;
158 $this->ambient = $ambient;
175 $this->color = $color;
184 $this->color = $this->effectType->getColor();
193 return $this->infinite;
setAmplifier(int $amplifier)
__construct(Effect $effectType, ?int $duration=null, int $amplifier=0, bool $visible=true, bool $ambient=false, ?Color $overrideColor=null, bool $infinite=false)
setAmbient(bool $ambient=true)
decreaseDuration(int $ticks)
setDuration(int $duration)
setVisible(bool $visible=true)