diff --git a/src/entity/effect/Effect.php b/src/entity/effect/Effect.php index b5c385c6f..3d1bd4c7c 100644 --- a/src/entity/effect/Effect.php +++ b/src/entity/effect/Effect.php @@ -38,12 +38,14 @@ class Effect{ * @param Translatable|string $name Translation key used for effect name * @param Color $color Color of bubbles given by this effect * @param bool $bad Whether the effect is harmful + * @param int $defaultDuration * @param bool $hasBubbles Whether the effect has potion bubbles. Some do not (e.g. Instant Damage has its own particles instead of bubbles) */ public function __construct( protected Translatable|string $name, protected Color $color, protected bool $bad = false, + private int $defaultDuration = 600, protected bool $hasBubbles = true ){} @@ -73,7 +75,7 @@ class Effect{ * Returns the default duration (in ticks) this effect will apply for if a duration is not specified. */ public function getDefaultDuration() : int{ - return 600; + return $this->defaultDuration; } /** diff --git a/src/entity/effect/InstantEffect.php b/src/entity/effect/InstantEffect.php index 653925918..ac5852e2f 100644 --- a/src/entity/effect/InstantEffect.php +++ b/src/entity/effect/InstantEffect.php @@ -23,10 +23,13 @@ declare(strict_types=1); namespace pocketmine\entity\effect; +use pocketmine\color\Color; +use pocketmine\lang\Translatable; + abstract class InstantEffect extends Effect{ - public function getDefaultDuration() : int{ - return 1; + public function __construct(Translatable|string $name, Color $color, bool $bad = false, bool $hasBubbles = true){ + parent::__construct($name, $color, $bad, 1, $hasBubbles); } public function canTick(EffectInstance $instance) : bool{ diff --git a/src/entity/effect/PoisonEffect.php b/src/entity/effect/PoisonEffect.php index 99dffb3af..e3b1618b5 100644 --- a/src/entity/effect/PoisonEffect.php +++ b/src/entity/effect/PoisonEffect.php @@ -34,8 +34,8 @@ class PoisonEffect extends Effect{ /** @var bool */ private $fatal; - public function __construct(Translatable|string $name, Color $color, bool $isBad = false, bool $hasBubbles = true, bool $fatal = false){ - parent::__construct($name, $color, $isBad, $hasBubbles); + public function __construct(Translatable|string $name, Color $color, bool $isBad = false, int $defaultDuration = 600, bool $hasBubbles = true, bool $fatal = false){ + parent::__construct($name, $color, $isBad, $defaultDuration, $hasBubbles); $this->fatal = $fatal; } diff --git a/src/entity/effect/VanillaEffects.php b/src/entity/effect/VanillaEffects.php index 50bddc941..d382a9f60 100644 --- a/src/entity/effect/VanillaEffects.php +++ b/src/entity/effect/VanillaEffects.php @@ -68,7 +68,7 @@ final class VanillaEffects{ //TODO: bad_omen self::register("blindness", new Effect(KnownTranslationFactory::potion_blindness(), new Color(0x1f, 0x1f, 0x23), true)); self::register("conduit_power", new Effect(KnownTranslationFactory::potion_conduitPower(), new Color(0x1d, 0xc2, 0xd1))); - self::register("fatal_poison", new PoisonEffect(KnownTranslationFactory::potion_poison(), new Color(0x4e, 0x93, 0x31), true, true, true)); + self::register("fatal_poison", new PoisonEffect(KnownTranslationFactory::potion_poison(), new Color(0x4e, 0x93, 0x31), true, 600, true, true)); self::register("fire_resistance", new Effect(KnownTranslationFactory::potion_fireResistance(), new Color(0xe4, 0x9a, 0x3a))); self::register("haste", new Effect(KnownTranslationFactory::potion_digSpeed(), new Color(0xd9, 0xc0, 0x43))); self::register("health_boost", new HealthBoostEffect(KnownTranslationFactory::potion_healthBoost(), new Color(0xf8, 0x7d, 0x23))); @@ -84,7 +84,7 @@ final class VanillaEffects{ self::register("poison", new PoisonEffect(KnownTranslationFactory::potion_poison(), new Color(0x4e, 0x93, 0x31), true)); self::register("regeneration", new RegenerationEffect(KnownTranslationFactory::potion_regeneration(), new Color(0xcd, 0x5c, 0xab))); self::register("resistance", new Effect(KnownTranslationFactory::potion_resistance(), new Color(0x99, 0x45, 0x3a))); - self::register("saturation", new SaturationEffect(KnownTranslationFactory::potion_saturation(), new Color(0xf8, 0x24, 0x23), false)); + self::register("saturation", new SaturationEffect(KnownTranslationFactory::potion_saturation(), new Color(0xf8, 0x24, 0x23))); //TODO: slow_falling self::register("slowness", new SlownessEffect(KnownTranslationFactory::potion_moveSlowdown(), new Color(0x5a, 0x6c, 0x81), true)); self::register("speed", new SpeedEffect(KnownTranslationFactory::potion_moveSpeed(), new Color(0x7c, 0xaf, 0xc6)));