Package org.spout.vanilla.event.entity

Examples of org.spout.vanilla.event.entity.EntityDamageEvent


      eventCause = (Cause<?>) cause;
    } else {
      eventCause = new NullDamageCause(cause.getType());
    }
    // TODO take potion effects into account
    EntityDamageEvent event = getEngine().getEventManager().callEvent(new EntityDamageEvent(getOwner(), amount, eventCause, sendHurtMessage));
    if (event.isCancelled()) {
      return;
    }

    setHealth(getHealth() - event.getDamage(), HealthChangeCause.DAMAGE);
    lastDamager = event.getDamager();
    lastDamageCause = cause;

    // Add exhaustion to damaged
    Hunger hunger = getOwner().get(Hunger.class);
    if (hunger != null) {
      hunger.setExhaustion(hunger.getExhaustion() + 0.3f);
    }

    if (event.getSendMessage()) {
      getOwner().getNetwork().callProtocolEvent(new EntityAnimationEvent(getOwner(), Animation.DAMAGE_ANIMATION));
      getOwner().getNetwork().callProtocolEvent(new EntityStatusEvent(getOwner(), EntityStatusMessage.ENTITY_HURT));
      //getHurtEffect().playGlobal(getParent().getParent().getPosition());
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.event.entity.EntityDamageEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.