mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Effect default duration is once again NOT hardcoded, like PM3
I have no fucking idea why I hardcoded this to begin with. Not one of my better ideas ...
This commit is contained in:
parent
09a2e006a8
commit
c3ec9c0948
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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{
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user