1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

EntityDamageEvent

Discussion in 'Development' started by DanielYTK, Feb 8, 2017.

  1. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    Can i use this?
    PHP:
    $entity->teleport(new Vector3($entity->getX(), $entity->getY() + 15$entity->getZ()));
                        if(
    $entity->getLastDamageCause()->getCause(5)){ //Verificar a causa do dano, no caso "queda"
                            
    $player->sendMessage(" ");
                            
    $player->sendMessage("§7A vida do §a".$entity->getName() ." §7agora é: §a".$entity->getHealth);
                            
    $player->sendMessage(" ");
                            }
     
  2. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    To check when a player takes fall damage
     
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You would have to change it to something like this:
    PHP:
    if($entity->getLastDamageCause() === EntityDamageEvent::CAUSE_FALL){
    if I'm correct.
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Actually, it should be
    PHP:
    if($entity->getLastDamageCause()->getCause() === EntityDamageEvent::CAUSE_FALL){
    But if you are already using EntityDamageEvent why not just use
    PHP:
    if($event->getCause() === EntityDamageEvent::CAUSE_FALL){
     
  5. DanielYTK

    DanielYTK Zombie

    Messages:
    227
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.