22declare(strict_types=1);
24namespace pocketmine\entity\effect;
31 private Effect $effectType;
32 private int $duration;
33 private int $amplifier;
34 private bool $visible;
35 private bool $ambient;
41 public function __construct(
Effect $effectType, ?
int $duration =
null,
int $amplifier = 0,
bool $visible =
true,
bool $ambient =
false, ?
Color $overrideColor =
null){
42 $this->effectType = $effectType;
45 $this->visible = $visible;
46 $this->ambient = $ambient;
47 $this->color = $overrideColor ?? $effectType->
getColor();
50 public function getType() :
Effect{
51 return $this->effectType;
58 return $this->duration;
69 if($duration < 0 || $duration >
Limits::INT32_MAX){
70 throw new \InvalidArgumentException(
"Effect duration must be in range 0 - " . Limits::INT32_MAX .
", got $duration");
72 $this->duration = $duration;
83 $this->duration = max(0, $this->duration - $ticks);
92 return $this->duration <= 0;
95 public function getAmplifier() : int{
96 return $this->amplifier;
103 return $this->amplifier + 1;
110 if($amplifier < 0 || $amplifier > 255){
111 throw new \InvalidArgumentException(
"Amplifier must be in range 0 - 255, got $amplifier");
113 $this->amplifier = $amplifier;
122 return $this->visible;
129 $this->visible = $visible;
140 return $this->ambient;
147 $this->ambient = $ambient;
164 $this->color = $color;
173 $this->color = $this->effectType->getColor();
setAmplifier(int $amplifier)
setAmbient(bool $ambient=true)
decreaseDuration(int $ticks)
__construct(Effect $effectType, ?int $duration=null, int $amplifier=0, bool $visible=true, bool $ambient=false, ?Color $overrideColor=null)
setDuration(int $duration)
setVisible(bool $visible=true)