diff --git a/src/pocketmine/command/defaults/EffectCommand.php b/src/pocketmine/command/defaults/EffectCommand.php index 4eea21c74..6f95a1b13 100644 --- a/src/pocketmine/command/defaults/EffectCommand.php +++ b/src/pocketmine/command/defaults/EffectCommand.php @@ -25,8 +25,8 @@ namespace pocketmine\command\defaults; use pocketmine\command\CommandSender; use pocketmine\command\utils\InvalidCommandSyntaxException; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use pocketmine\lang\TranslationContainer; use pocketmine\utils\TextFormat; use function count; @@ -68,10 +68,10 @@ class EffectCommand extends VanillaCommand{ return true; } - $effect = Effect::fromString($args[1]); + $effect = VanillaEffects::fromString($args[1]); if($effect === null){ - $effect = Effect::get((int) $args[1]); + $effect = VanillaEffects::byMcpeId((int) $args[1]); } if($effect === null){ diff --git a/src/pocketmine/entity/EntityFactory.php b/src/pocketmine/entity/EntityFactory.php index fcac6d759..d3a71f367 100644 --- a/src/pocketmine/entity/EntityFactory.php +++ b/src/pocketmine/entity/EntityFactory.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace pocketmine\entity; -use pocketmine\entity\effect\Effect; use pocketmine\entity\object\ExperienceOrb; use pocketmine\entity\object\FallingBlock; use pocketmine\entity\object\ItemEntity; @@ -98,7 +97,6 @@ final class EntityFactory{ self::register(Human::class, ['Human']); Attribute::init(); - Effect::init(); PaintingMotive::init(); } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 472435348..e72a5b494 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\entity; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use pocketmine\entity\projectile\ProjectileSource; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\player\PlayerExhaustEvent; @@ -315,9 +315,9 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ if($totemModifier < 0){ //Totem prevented death $this->effectManager->clear(); - $this->effectManager->add(new EffectInstance(Effect::REGENERATION(), 40 * 20, 1)); - $this->effectManager->add(new EffectInstance(Effect::FIRE_RESISTANCE(), 40 * 20, 1)); - $this->effectManager->add(new EffectInstance(Effect::ABSORPTION(), 5 * 20, 1)); + $this->effectManager->add(new EffectInstance(VanillaEffects::REGENERATION(), 40 * 20, 1)); + $this->effectManager->add(new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 40 * 20, 1)); + $this->effectManager->add(new EffectInstance(VanillaEffects::ABSORPTION(), 5 * 20, 1)); $this->broadcastEntityEvent(ActorEventPacket::CONSUME_TOTEM); $this->world->addSound($this->add(0, $this->eyeHeight, 0), new TotemUseSound()); diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 853cb9fc6..b56b484b7 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -24,9 +24,9 @@ declare(strict_types=1); namespace pocketmine\entity; use pocketmine\block\Block; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; use pocketmine\entity\effect\EffectManager; +use pocketmine\entity\effect\VanillaEffects; use pocketmine\event\entity\EntityDamageByChildEntityEvent; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageEvent; @@ -118,7 +118,7 @@ abstract class Living extends Entity{ $activeEffectsTag = $nbt->getListTag("ActiveEffects"); if($activeEffectsTag !== null){ foreach($activeEffectsTag as $e){ - $effect = Effect::get($e->getByte("Id")); + $effect = VanillaEffects::byMcpeId($e->getByte("Id")); if($effect === null){ continue; } @@ -241,7 +241,7 @@ abstract class Living extends Entity{ * @return float */ public function getJumpVelocity() : float{ - return $this->jumpVelocity + ($this->effectManager->has(Effect::JUMP_BOOST()) ? ($this->effectManager->get(Effect::JUMP_BOOST())->getEffectLevel() / 10) : 0); + return $this->jumpVelocity + ($this->effectManager->has(VanillaEffects::JUMP_BOOST()) ? ($this->effectManager->get(VanillaEffects::JUMP_BOOST())->getEffectLevel() / 10) : 0); } /** @@ -254,7 +254,7 @@ abstract class Living extends Entity{ } public function fall(float $fallDistance) : void{ - $damage = ceil($fallDistance - 3 - ($this->effectManager->has(Effect::JUMP_BOOST()) ? $this->effectManager->get(Effect::JUMP_BOOST())->getEffectLevel() : 0)); + $damage = ceil($fallDistance - 3 - ($this->effectManager->has(VanillaEffects::JUMP_BOOST()) ? $this->effectManager->get(VanillaEffects::JUMP_BOOST())->getEffectLevel() : 0)); if($damage > 0){ $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage); $this->attack($ev); @@ -317,8 +317,8 @@ abstract class Living extends Entity{ } $cause = $source->getCause(); - if($this->effectManager->has(Effect::RESISTANCE()) and $cause !== EntityDamageEvent::CAUSE_VOID and $cause !== EntityDamageEvent::CAUSE_SUICIDE){ - $source->setModifier(-$source->getFinalDamage() * min(1, 0.2 * $this->effectManager->get(Effect::RESISTANCE())->getEffectLevel()), EntityDamageEvent::MODIFIER_RESISTANCE); + if($this->effectManager->has(VanillaEffects::RESISTANCE()) and $cause !== EntityDamageEvent::CAUSE_VOID and $cause !== EntityDamageEvent::CAUSE_SUICIDE){ + $source->setModifier(-$source->getFinalDamage() * min(1, 0.2 * $this->effectManager->get(VanillaEffects::RESISTANCE())->getEffectLevel()), EntityDamageEvent::MODIFIER_RESISTANCE); } $totalEpf = 0; @@ -400,7 +400,7 @@ abstract class Living extends Entity{ } } - if($this->effectManager->has(Effect::FIRE_RESISTANCE()) and ( + if($this->effectManager->has(VanillaEffects::FIRE_RESISTANCE()) and ( $source->getCause() === EntityDamageEvent::CAUSE_FIRE or $source->getCause() === EntityDamageEvent::CAUSE_FIRE_TICK or $source->getCause() === EntityDamageEvent::CAUSE_LAVA @@ -590,7 +590,7 @@ abstract class Living extends Entity{ * @return bool */ public function canBreathe() : bool{ - return $this->effectManager->has(Effect::WATER_BREATHING()) or $this->effectManager->has(Effect::CONDUIT_POWER()) or !$this->isUnderwater(); + return $this->effectManager->has(VanillaEffects::WATER_BREATHING()) or $this->effectManager->has(VanillaEffects::CONDUIT_POWER()) or !$this->isUnderwater(); } /** diff --git a/src/pocketmine/entity/effect/Effect.php b/src/pocketmine/entity/effect/Effect.php index 5774c338a..6e7192e2e 100644 --- a/src/pocketmine/entity/effect/Effect.php +++ b/src/pocketmine/entity/effect/Effect.php @@ -26,212 +26,9 @@ namespace pocketmine\entity\effect; use pocketmine\entity\Entity; use pocketmine\entity\Living; use pocketmine\utils\Color; -use function constant; -use function defined; -use function strtoupper; class Effect{ - //TODO: remove our dependence on these magic numbers - public const SPEED = 1; - public const SLOWNESS = 2; - public const HASTE = 3; - public const FATIGUE = 4, MINING_FATIGUE = 4; - public const STRENGTH = 5; - public const INSTANT_HEALTH = 6, HEALING = 6; - public const INSTANT_DAMAGE = 7, HARMING = 7; - public const JUMP_BOOST = 8, JUMP = 8; - public const NAUSEA = 9, CONFUSION = 9; - public const REGENERATION = 10; - public const RESISTANCE = 11, DAMAGE_RESISTANCE = 11; - public const FIRE_RESISTANCE = 12; - public const WATER_BREATHING = 13; - public const INVISIBILITY = 14; - public const BLINDNESS = 15; - public const NIGHT_VISION = 16; - public const HUNGER = 17; - public const WEAKNESS = 18; - public const POISON = 19; - public const WITHER = 20; - public const HEALTH_BOOST = 21; - public const ABSORPTION = 22; - public const SATURATION = 23; - public const LEVITATION = 24; //TODO - public const FATAL_POISON = 25; - public const CONDUIT_POWER = 26; - public const SLOW_FALLING = 27; - public const BAD_OMEN = 28; - public const VILLAGE_HERO = 29; - - /** @var Effect[] */ - protected static $effects = []; - - public static function init() : void{ - self::register(new SpeedEffect(Effect::SPEED, "%potion.moveSpeed", new Color(0x7c, 0xaf, 0xc6))); - self::register(new SlownessEffect(Effect::SLOWNESS, "%potion.moveSlowdown", new Color(0x5a, 0x6c, 0x81), true)); - self::register(new Effect(Effect::HASTE, "%potion.digSpeed", new Color(0xd9, 0xc0, 0x43))); - self::register(new Effect(Effect::MINING_FATIGUE, "%potion.digSlowDown", new Color(0x4a, 0x42, 0x17), true)); - self::register(new Effect(Effect::STRENGTH, "%potion.damageBoost", new Color(0x93, 0x24, 0x23))); - self::register(new InstantHealthEffect(Effect::INSTANT_HEALTH, "%potion.heal", new Color(0xf8, 0x24, 0x23), false, false)); - self::register(new InstantDamageEffect(Effect::INSTANT_DAMAGE, "%potion.harm", new Color(0x43, 0x0a, 0x09), true, false)); - self::register(new Effect(Effect::JUMP_BOOST, "%potion.jump", new Color(0x22, 0xff, 0x4c))); - self::register(new Effect(Effect::NAUSEA, "%potion.confusion", new Color(0x55, 0x1d, 0x4a), true)); - self::register(new RegenerationEffect(Effect::REGENERATION, "%potion.regeneration", new Color(0xcd, 0x5c, 0xab))); - self::register(new Effect(Effect::RESISTANCE, "%potion.resistance", new Color(0x99, 0x45, 0x3a))); - self::register(new Effect(Effect::FIRE_RESISTANCE, "%potion.fireResistance", new Color(0xe4, 0x9a, 0x3a))); - self::register(new Effect(Effect::WATER_BREATHING, "%potion.waterBreathing", new Color(0x2e, 0x52, 0x99))); - self::register(new InvisibilityEffect(Effect::INVISIBILITY, "%potion.invisibility", new Color(0x7f, 0x83, 0x92))); - self::register(new Effect(Effect::BLINDNESS, "%potion.blindness", new Color(0x1f, 0x1f, 0x23), true)); - self::register(new Effect(Effect::NIGHT_VISION, "%potion.nightVision", new Color(0x1f, 0x1f, 0xa1))); - self::register(new HungerEffect(Effect::HUNGER, "%potion.hunger", new Color(0x58, 0x76, 0x53), true)); - self::register(new Effect(Effect::WEAKNESS, "%potion.weakness", new Color(0x48, 0x4d, 0x48), true)); - self::register(new PoisonEffect(Effect::POISON, "%potion.poison", new Color(0x4e, 0x93, 0x31), true)); - self::register(new WitherEffect(Effect::WITHER, "%potion.wither", new Color(0x35, 0x2a, 0x27), true)); - self::register(new HealthBoostEffect(Effect::HEALTH_BOOST, "%potion.healthBoost", new Color(0xf8, 0x7d, 0x23))); - self::register(new AbsorptionEffect(Effect::ABSORPTION, "%potion.absorption", new Color(0x25, 0x52, 0xa5))); - self::register(new SaturationEffect(Effect::SATURATION, "%potion.saturation", new Color(0xf8, 0x24, 0x23), false)); - self::register(new LevitationEffect(Effect::LEVITATION, "%potion.levitation", new Color(0xce, 0xff, 0xff))); - self::register(new PoisonEffect(Effect::FATAL_POISON, "%potion.poison", new Color(0x4e, 0x93, 0x31), true, true, true)); - self::register(new Effect(Effect::CONDUIT_POWER, "%potion.conduitPower", new Color(0x1d, 0xc2, 0xd1))); - } - - //region --- auto-generated code --- - - public static function ABSORPTION() : Effect{ - return self::get(Effect::ABSORPTION); - } - - public static function BLINDNESS() : Effect{ - return self::get(Effect::BLINDNESS); - } - - public static function CONDUIT_POWER() : Effect{ - return self::get(Effect::CONDUIT_POWER); - } - - public static function FATAL_POISON() : Effect{ - return self::get(Effect::FATAL_POISON); - } - - public static function FIRE_RESISTANCE() : Effect{ - return self::get(Effect::FIRE_RESISTANCE); - } - - public static function HASTE() : Effect{ - return self::get(Effect::HASTE); - } - - public static function HEALTH_BOOST() : Effect{ - return self::get(Effect::HEALTH_BOOST); - } - - public static function HUNGER() : Effect{ - return self::get(Effect::HUNGER); - } - - public static function INSTANT_DAMAGE() : Effect{ - return self::get(Effect::INSTANT_DAMAGE); - } - - public static function INSTANT_HEALTH() : Effect{ - return self::get(Effect::INSTANT_HEALTH); - } - - public static function INVISIBILITY() : Effect{ - return self::get(Effect::INVISIBILITY); - } - - public static function JUMP_BOOST() : Effect{ - return self::get(Effect::JUMP_BOOST); - } - - public static function LEVITATION() : Effect{ - return self::get(Effect::LEVITATION); - } - - public static function MINING_FATIGUE() : Effect{ - return self::get(Effect::MINING_FATIGUE); - } - - public static function NAUSEA() : Effect{ - return self::get(Effect::NAUSEA); - } - - public static function NIGHT_VISION() : Effect{ - return self::get(Effect::NIGHT_VISION); - } - - public static function POISON() : Effect{ - return self::get(Effect::POISON); - } - - public static function REGENERATION() : Effect{ - return self::get(Effect::REGENERATION); - } - - public static function RESISTANCE() : Effect{ - return self::get(Effect::RESISTANCE); - } - - public static function SATURATION() : Effect{ - return self::get(Effect::SATURATION); - } - - public static function SLOWNESS() : Effect{ - return self::get(Effect::SLOWNESS); - } - - public static function SPEED() : Effect{ - return self::get(Effect::SPEED); - } - - public static function STRENGTH() : Effect{ - return self::get(Effect::STRENGTH); - } - - public static function WATER_BREATHING() : Effect{ - return self::get(Effect::WATER_BREATHING); - } - - public static function WEAKNESS() : Effect{ - return self::get(Effect::WEAKNESS); - } - - public static function WITHER() : Effect{ - return self::get(Effect::WITHER); - } - - //endregion - - /** - * @param Effect $effect - */ - public static function register(Effect $effect) : void{ - self::$effects[$effect->getId()] = $effect; - } - - /** - * @param int $id - * - * @return Effect|null - */ - public static function get(int $id) : ?Effect{ - return self::$effects[$id] ?? null; - } - - /** - * @param string $name - * - * @return Effect|null - */ - public static function fromString(string $name) : ?Effect{ - $const = self::class . "::" . strtoupper($name); - if(defined($const)){ - return self::get(constant($const)); - } - return null; - } - /** @var int */ protected $id; /** @var string */ diff --git a/src/pocketmine/entity/effect/VanillaEffects.php b/src/pocketmine/entity/effect/VanillaEffects.php new file mode 100644 index 000000000..9b81e2b22 --- /dev/null +++ b/src/pocketmine/entity/effect/VanillaEffects.php @@ -0,0 +1,134 @@ +getId()])); + self::$mcpeIdMap[$member->getId()] = $member; + } + + /** + * @param int $id + * + * @return Effect + */ + public static function byMcpeId(int $id) : Effect{ + self::checkInit(); + if(!isset(self::$mcpeIdMap[$id])){ + throw new \InvalidArgumentException("No such effect with MCPE ID $id"); + } + return self::$mcpeIdMap[$id]; + } + + /** + * @return Effect[] + */ + public static function getAll() : array{ + return self::_registryGetAll(); + } + + /** + * @param string $name + * + * @return Effect + */ + public static function fromString(string $name) : Effect{ + $result = self::_registryFromString($name); + assert($result instanceof Effect); + return $result; + } +} diff --git a/src/pocketmine/event/entity/EntityDamageByEntityEvent.php b/src/pocketmine/event/entity/EntityDamageByEntityEvent.php index 2793f4673..755e4e088 100644 --- a/src/pocketmine/event/entity/EntityDamageByEntityEvent.php +++ b/src/pocketmine/event/entity/EntityDamageByEntityEvent.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace pocketmine\event\entity; -use pocketmine\entity\effect\Effect; +use pocketmine\entity\effect\VanillaEffects; use pocketmine\entity\Entity; use pocketmine\entity\Living; @@ -54,12 +54,12 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{ protected function addAttackerModifiers(Entity $damager) : void{ if($damager instanceof Living){ //TODO: move this to entity classes $effects = $damager->getEffects(); - if($effects->has(Effect::STRENGTH())){ - $this->setModifier($this->getBaseDamage() * 0.3 * $effects->get(Effect::STRENGTH())->getEffectLevel(), self::MODIFIER_STRENGTH); + if($effects->has(VanillaEffects::STRENGTH())){ + $this->setModifier($this->getBaseDamage() * 0.3 * $effects->get(VanillaEffects::STRENGTH())->getEffectLevel(), self::MODIFIER_STRENGTH); } - if($effects->has(Effect::WEAKNESS())){ - $this->setModifier(-($this->getBaseDamage() * 0.2 * $effects->get(Effect::WEAKNESS())->getEffectLevel()), self::MODIFIER_WEAKNESS); + if($effects->has(VanillaEffects::WEAKNESS())){ + $this->setModifier(-($this->getBaseDamage() * 0.2 * $effects->get(VanillaEffects::WEAKNESS())->getEffectLevel()), self::MODIFIER_WEAKNESS); } } } diff --git a/src/pocketmine/item/GoldenApple.php b/src/pocketmine/item/GoldenApple.php index ba0220528..76487fdd6 100644 --- a/src/pocketmine/item/GoldenApple.php +++ b/src/pocketmine/item/GoldenApple.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; class GoldenApple extends Food{ @@ -42,8 +42,8 @@ class GoldenApple extends Food{ public function getAdditionalEffects() : array{ return [ - new EffectInstance(Effect::REGENERATION(), 100, 1), - new EffectInstance(Effect::ABSORPTION(), 2400) + new EffectInstance(VanillaEffects::REGENERATION(), 100, 1), + new EffectInstance(VanillaEffects::ABSORPTION(), 2400) ]; } } diff --git a/src/pocketmine/item/GoldenAppleEnchanted.php b/src/pocketmine/item/GoldenAppleEnchanted.php index 1064373c2..c807ac897 100644 --- a/src/pocketmine/item/GoldenAppleEnchanted.php +++ b/src/pocketmine/item/GoldenAppleEnchanted.php @@ -23,17 +23,17 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; class GoldenAppleEnchanted extends GoldenApple{ public function getAdditionalEffects() : array{ return [ - new EffectInstance(Effect::REGENERATION(), 600, 4), - new EffectInstance(Effect::ABSORPTION(), 2400, 3), - new EffectInstance(Effect::RESISTANCE(), 6000), - new EffectInstance(Effect::FIRE_RESISTANCE(), 6000) + new EffectInstance(VanillaEffects::REGENERATION(), 600, 4), + new EffectInstance(VanillaEffects::ABSORPTION(), 2400, 3), + new EffectInstance(VanillaEffects::RESISTANCE(), 6000), + new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 6000) ]; } } diff --git a/src/pocketmine/item/PoisonousPotato.php b/src/pocketmine/item/PoisonousPotato.php index 962e87a2c..fb997d48e 100644 --- a/src/pocketmine/item/PoisonousPotato.php +++ b/src/pocketmine/item/PoisonousPotato.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use function mt_rand; class PoisonousPotato extends Food{ @@ -40,7 +40,7 @@ class PoisonousPotato extends Food{ public function getAdditionalEffects() : array{ if(mt_rand(0, 100) > 40){ return [ - new EffectInstance(Effect::POISON(), 100) + new EffectInstance(VanillaEffects::POISON(), 100) ]; } return []; diff --git a/src/pocketmine/item/Potion.php b/src/pocketmine/item/Potion.php index c45ac84ea..619882a56 100644 --- a/src/pocketmine/item/Potion.php +++ b/src/pocketmine/item/Potion.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use pocketmine\entity\Living; class Potion extends Item implements Consumable{ @@ -124,131 +124,131 @@ class Potion extends Item implements Consumable{ return []; case self::NIGHT_VISION: return [ - new EffectInstance(Effect::NIGHT_VISION(), 3600) + new EffectInstance(VanillaEffects::NIGHT_VISION(), 3600) ]; case self::LONG_NIGHT_VISION: return [ - new EffectInstance(Effect::NIGHT_VISION(), 9600) + new EffectInstance(VanillaEffects::NIGHT_VISION(), 9600) ]; case self::INVISIBILITY: return [ - new EffectInstance(Effect::INVISIBILITY(), 3600) + new EffectInstance(VanillaEffects::INVISIBILITY(), 3600) ]; case self::LONG_INVISIBILITY: return [ - new EffectInstance(Effect::INVISIBILITY(), 9600) + new EffectInstance(VanillaEffects::INVISIBILITY(), 9600) ]; case self::LEAPING: return [ - new EffectInstance(Effect::JUMP_BOOST(), 3600) + new EffectInstance(VanillaEffects::JUMP_BOOST(), 3600) ]; case self::LONG_LEAPING: return [ - new EffectInstance(Effect::JUMP_BOOST(), 9600) + new EffectInstance(VanillaEffects::JUMP_BOOST(), 9600) ]; case self::STRONG_LEAPING: return [ - new EffectInstance(Effect::JUMP_BOOST(), 1800, 1) + new EffectInstance(VanillaEffects::JUMP_BOOST(), 1800, 1) ]; case self::FIRE_RESISTANCE: return [ - new EffectInstance(Effect::FIRE_RESISTANCE(), 3600) + new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 3600) ]; case self::LONG_FIRE_RESISTANCE: return [ - new EffectInstance(Effect::FIRE_RESISTANCE(), 9600) + new EffectInstance(VanillaEffects::FIRE_RESISTANCE(), 9600) ]; case self::SWIFTNESS: return [ - new EffectInstance(Effect::SPEED(), 3600) + new EffectInstance(VanillaEffects::SPEED(), 3600) ]; case self::LONG_SWIFTNESS: return [ - new EffectInstance(Effect::SPEED(), 9600) + new EffectInstance(VanillaEffects::SPEED(), 9600) ]; case self::STRONG_SWIFTNESS: return [ - new EffectInstance(Effect::SPEED(), 1800, 1) + new EffectInstance(VanillaEffects::SPEED(), 1800, 1) ]; case self::SLOWNESS: return [ - new EffectInstance(Effect::SLOWNESS(), 1800) + new EffectInstance(VanillaEffects::SLOWNESS(), 1800) ]; case self::LONG_SLOWNESS: return [ - new EffectInstance(Effect::SLOWNESS(), 4800) + new EffectInstance(VanillaEffects::SLOWNESS(), 4800) ]; case self::WATER_BREATHING: return [ - new EffectInstance(Effect::WATER_BREATHING(), 3600) + new EffectInstance(VanillaEffects::WATER_BREATHING(), 3600) ]; case self::LONG_WATER_BREATHING: return [ - new EffectInstance(Effect::WATER_BREATHING(), 9600) + new EffectInstance(VanillaEffects::WATER_BREATHING(), 9600) ]; case self::HEALING: return [ - new EffectInstance(Effect::INSTANT_HEALTH()) + new EffectInstance(VanillaEffects::INSTANT_HEALTH()) ]; case self::STRONG_HEALING: return [ - new EffectInstance(Effect::INSTANT_HEALTH(), null, 1) + new EffectInstance(VanillaEffects::INSTANT_HEALTH(), null, 1) ]; case self::HARMING: return [ - new EffectInstance(Effect::INSTANT_DAMAGE()) + new EffectInstance(VanillaEffects::INSTANT_DAMAGE()) ]; case self::STRONG_HARMING: return [ - new EffectInstance(Effect::INSTANT_DAMAGE(), null, 1) + new EffectInstance(VanillaEffects::INSTANT_DAMAGE(), null, 1) ]; case self::POISON: return [ - new EffectInstance(Effect::POISON(), 900) + new EffectInstance(VanillaEffects::POISON(), 900) ]; case self::LONG_POISON: return [ - new EffectInstance(Effect::POISON(), 2400) + new EffectInstance(VanillaEffects::POISON(), 2400) ]; case self::STRONG_POISON: return [ - new EffectInstance(Effect::POISON(), 440, 1) + new EffectInstance(VanillaEffects::POISON(), 440, 1) ]; case self::REGENERATION: return [ - new EffectInstance(Effect::REGENERATION(), 900) + new EffectInstance(VanillaEffects::REGENERATION(), 900) ]; case self::LONG_REGENERATION: return [ - new EffectInstance(Effect::REGENERATION(), 2400) + new EffectInstance(VanillaEffects::REGENERATION(), 2400) ]; case self::STRONG_REGENERATION: return [ - new EffectInstance(Effect::REGENERATION(), 440, 1) + new EffectInstance(VanillaEffects::REGENERATION(), 440, 1) ]; case self::STRENGTH: return [ - new EffectInstance(Effect::STRENGTH(), 3600) + new EffectInstance(VanillaEffects::STRENGTH(), 3600) ]; case self::LONG_STRENGTH: return [ - new EffectInstance(Effect::STRENGTH(), 9600) + new EffectInstance(VanillaEffects::STRENGTH(), 9600) ]; case self::STRONG_STRENGTH: return [ - new EffectInstance(Effect::STRENGTH(), 1800, 1) + new EffectInstance(VanillaEffects::STRENGTH(), 1800, 1) ]; case self::WEAKNESS: return [ - new EffectInstance(Effect::WEAKNESS(), 1800) + new EffectInstance(VanillaEffects::WEAKNESS(), 1800) ]; case self::LONG_WEAKNESS: return [ - new EffectInstance(Effect::WEAKNESS(), 4800) + new EffectInstance(VanillaEffects::WEAKNESS(), 4800) ]; case self::WITHER: return [ - new EffectInstance(Effect::WITHER(), 800, 1) + new EffectInstance(VanillaEffects::WITHER(), 800, 1) ]; } diff --git a/src/pocketmine/item/Pufferfish.php b/src/pocketmine/item/Pufferfish.php index 6e9826fb4..d657ae8ad 100644 --- a/src/pocketmine/item/Pufferfish.php +++ b/src/pocketmine/item/Pufferfish.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; class Pufferfish extends Food{ @@ -38,9 +38,9 @@ class Pufferfish extends Food{ public function getAdditionalEffects() : array{ return [ - new EffectInstance(Effect::HUNGER(), 300, 2), - new EffectInstance(Effect::POISON(), 1200, 3), - new EffectInstance(Effect::NAUSEA(), 300, 1) + new EffectInstance(VanillaEffects::HUNGER(), 300, 2), + new EffectInstance(VanillaEffects::POISON(), 1200, 3), + new EffectInstance(VanillaEffects::NAUSEA(), 300, 1) ]; } } diff --git a/src/pocketmine/item/RawChicken.php b/src/pocketmine/item/RawChicken.php index 0408a6552..16a795203 100644 --- a/src/pocketmine/item/RawChicken.php +++ b/src/pocketmine/item/RawChicken.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use function mt_rand; class RawChicken extends Food{ @@ -38,6 +38,6 @@ class RawChicken extends Food{ } public function getAdditionalEffects() : array{ - return mt_rand(0, 9) < 3 ? [new EffectInstance(Effect::HUNGER(), 600)] : []; + return mt_rand(0, 9) < 3 ? [new EffectInstance(VanillaEffects::HUNGER(), 600)] : []; } } diff --git a/src/pocketmine/item/RottenFlesh.php b/src/pocketmine/item/RottenFlesh.php index 90f4c9050..401149a4a 100644 --- a/src/pocketmine/item/RottenFlesh.php +++ b/src/pocketmine/item/RottenFlesh.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use function lcg_value; class RottenFlesh extends Food{ @@ -40,7 +40,7 @@ class RottenFlesh extends Food{ public function getAdditionalEffects() : array{ if(lcg_value() <= 0.8){ return [ - new EffectInstance(Effect::HUNGER(), 600) + new EffectInstance(VanillaEffects::HUNGER(), 600) ]; } diff --git a/src/pocketmine/item/SpiderEye.php b/src/pocketmine/item/SpiderEye.php index b443a4fad..22e5ecab1 100644 --- a/src/pocketmine/item/SpiderEye.php +++ b/src/pocketmine/item/SpiderEye.php @@ -23,8 +23,8 @@ declare(strict_types=1); namespace pocketmine\item; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; class SpiderEye extends Food{ @@ -37,6 +37,6 @@ class SpiderEye extends Food{ } public function getAdditionalEffects() : array{ - return [new EffectInstance(Effect::POISON(), 80)]; + return [new EffectInstance(VanillaEffects::POISON(), 80)]; } } diff --git a/src/pocketmine/player/Player.php b/src/pocketmine/player/Player.php index a01aa6549..a883016e4 100644 --- a/src/pocketmine/player/Player.php +++ b/src/pocketmine/player/Player.php @@ -29,8 +29,8 @@ use pocketmine\block\UnknownBlock; use pocketmine\block\VanillaBlocks; use pocketmine\command\CommandSender; use pocketmine\crafting\CraftingGrid; -use pocketmine\entity\effect\Effect; use pocketmine\entity\effect\EffectInstance; +use pocketmine\entity\effect\VanillaEffects; use pocketmine\entity\Entity; use pocketmine\entity\EntityFactory; use pocketmine\entity\Human; @@ -1884,7 +1884,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, } $ev->setModifier($meleeEnchantmentDamage, EntityDamageEvent::MODIFIER_WEAPON_ENCHANTMENTS); - if(!$this->isSprinting() and !$this->isFlying() and $this->fallDistance > 0 and !$this->effectManager->has(Effect::BLINDNESS()) and !$this->isUnderwater()){ + if(!$this->isSprinting() and !$this->isFlying() and $this->fallDistance > 0 and !$this->effectManager->has(VanillaEffects::BLINDNESS()) and !$this->isUnderwater()){ $ev->setModifier($ev->getFinalDamage() / 2, EntityDamageEvent::MODIFIER_CRITICAL); }