mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 14:05:35 +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 Translatable|string $name Translation key used for effect name
|
||||||
* @param Color $color Color of bubbles given by this effect
|
* @param Color $color Color of bubbles given by this effect
|
||||||
* @param bool $bad Whether the effect is harmful
|
* @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)
|
* @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(
|
public function __construct(
|
||||||
protected Translatable|string $name,
|
protected Translatable|string $name,
|
||||||
protected Color $color,
|
protected Color $color,
|
||||||
protected bool $bad = false,
|
protected bool $bad = false,
|
||||||
|
private int $defaultDuration = 600,
|
||||||
protected bool $hasBubbles = true
|
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.
|
* Returns the default duration (in ticks) this effect will apply for if a duration is not specified.
|
||||||
*/
|
*/
|
||||||
public function getDefaultDuration() : int{
|
public function getDefaultDuration() : int{
|
||||||
return 600;
|
return $this->defaultDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,10 +23,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\entity\effect;
|
namespace pocketmine\entity\effect;
|
||||||
|
|
||||||
|
use pocketmine\color\Color;
|
||||||
|
use pocketmine\lang\Translatable;
|
||||||
|
|
||||||
abstract class InstantEffect extends Effect{
|
abstract class InstantEffect extends Effect{
|
||||||
|
|
||||||
public function getDefaultDuration() : int{
|
public function __construct(Translatable|string $name, Color $color, bool $bad = false, bool $hasBubbles = true){
|
||||||
return 1;
|
parent::__construct($name, $color, $bad, 1, $hasBubbles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canTick(EffectInstance $instance) : bool{
|
public function canTick(EffectInstance $instance) : bool{
|
||||||
|
@ -34,8 +34,8 @@ class PoisonEffect extends Effect{
|
|||||||
/** @var bool */
|
/** @var bool */
|
||||||
private $fatal;
|
private $fatal;
|
||||||
|
|
||||||
public function __construct(Translatable|string $name, Color $color, bool $isBad = false, bool $hasBubbles = true, bool $fatal = false){
|
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, $hasBubbles);
|
parent::__construct($name, $color, $isBad, $defaultDuration, $hasBubbles);
|
||||||
$this->fatal = $fatal;
|
$this->fatal = $fatal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ final class VanillaEffects{
|
|||||||
//TODO: bad_omen
|
//TODO: bad_omen
|
||||||
self::register("blindness", new Effect(KnownTranslationFactory::potion_blindness(), new Color(0x1f, 0x1f, 0x23), true));
|
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("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("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("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)));
|
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("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("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("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
|
//TODO: slow_falling
|
||||||
self::register("slowness", new SlownessEffect(KnownTranslationFactory::potion_moveSlowdown(), new Color(0x5a, 0x6c, 0x81), true));
|
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)));
|
self::register("speed", new SpeedEffect(KnownTranslationFactory::potion_moveSpeed(), new Color(0x7c, 0xaf, 0xc6)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user