상속: extends EntityEvent, implements pocketmine\event\Cancellable
예제 #1
0
파일: Entity.php 프로젝트: kniffo80/Genisys
 public function removeEffect($effectId)
 {
     Server::getInstance()->getPluginManager()->callEvent($ev = new EntityEffectRemoveEvent($this, $effectId));
     if ($ev->isCancelled()) {
         return false;
     }
     if (isset($this->effects[$effectId])) {
         $effect = $this->effects[$effectId];
         unset($this->effects[$effectId]);
         $effect->remove($this);
         if ($effectId === Effect::ABSORPTION and $this instanceof Human) {
             $this->setAbsorption(0);
         }
         $this->recalculateEffectColor();
         return true;
     }
 }
예제 #2
0
 public function remove(Entity $entity)
 {
     $entity->getLevel()->getServer()->getPluginManager()->callEvent($ev = new EntityEffectRemoveEvent($entity, $this));
     if ($ev->isCancelled()) {
         return;
     }
     if ($entity instanceof Player) {
         $pk = new MobEffectPacket();
         $pk->eid = 0;
         $pk->eventId = MobEffectPacket::EVENT_REMOVE;
         $pk->effectId = $this->getId();
         $entity->dataPacket($pk);
     }
     if ($this->id === Effect::INVISIBILITY) {
         $entity->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_INVISIBLE, false);
         $entity->setNameTagVisible(true);
     } elseif ($this->id === Effect::SPEED) {
         $attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
         $attr->setValue($attr->getValue() / (1 + 0.2 * $this->amplifier));
     } elseif ($this->id === Effect::SLOWNESS) {
         $attr = $entity->getAttributeMap()->getAttribute(Attribute::MOVEMENT_SPEED);
         $attr->setValue($attr->getValue() / (1 - 0.15 * $this->amplifier));
     }
 }