mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
Living: Do not rely on attribute map for moveSpeed attribute access
This commit is contained in:
@ -23,18 +23,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\entity\effect;
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
class SlownessEffect extends Effect{
|
||||
|
||||
public function add(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() * (1 - 0.15 * $instance->getEffectLevel()), true);
|
||||
$entity->setMovementSpeed($entity->getMovementSpeed() * (1 - 0.15 * $instance->getEffectLevel()), true);
|
||||
}
|
||||
|
||||
public function remove(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() / (1 - 0.15 * $instance->getEffectLevel()));
|
||||
$entity->setMovementSpeed($entity->getMovementSpeed() / (1 - 0.15 * $instance->getEffectLevel()));
|
||||
}
|
||||
}
|
||||
|
@ -23,18 +23,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\entity\effect;
|
||||
|
||||
use pocketmine\entity\Attribute;
|
||||
use pocketmine\entity\Living;
|
||||
|
||||
class SpeedEffect extends Effect{
|
||||
|
||||
public function add(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() * (1 + 0.2 * $instance->getEffectLevel()));
|
||||
$entity->setMovementSpeed($entity->getMovementSpeed() * (1 + 0.2 * $instance->getEffectLevel()));
|
||||
}
|
||||
|
||||
public function remove(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() / (1 + 0.2 * $instance->getEffectLevel()));
|
||||
$entity->setMovementSpeed($entity->getMovementSpeed() / (1 + 0.2 * $instance->getEffectLevel()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user