mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
reduce boilerplate around attribute handling
This commit is contained in:
@ -29,12 +29,12 @@ use pocketmine\entity\Living;
|
||||
class SlownessEffect extends Effect{
|
||||
|
||||
public function add(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() * (1 - 0.15 * $instance->getEffectLevel()), true);
|
||||
}
|
||||
|
||||
public function remove(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() / (1 - 0.15 * $instance->getEffectLevel()));
|
||||
}
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ use pocketmine\entity\Living;
|
||||
class SpeedEffect extends Effect{
|
||||
|
||||
public function add(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() * (1 + 0.2 * $instance->getEffectLevel()));
|
||||
}
|
||||
|
||||
public function remove(Living $entity, EffectInstance $instance) : void{
|
||||
$attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
|
||||
$attr = $entity->getAttributeMap()->get(Attribute::MOVEMENT_SPEED);
|
||||
$attr->setValue($attr->getValue() / (1 + 0.2 * $instance->getEffectLevel()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user