DamageCause ???

Discussion in 'Plugin Development' started by paxi, Jun 21, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    paxi

    Hello everybody,

    i have a small question to the DamageCauses....
    When i kill a mob with an void in my plugin (target.damage() ) i can't get the Cause....
    Why? And how can i get the DamageCause?
     
  2. Use the EntityDamageEvent and the getCause() function :)
     
  3. Offline

    paxi

    It doens't work!
    At the moment i have following:
    Code:java
    1. pTarget.damage(dmg);
    2. EntityDamageEvent evt= new EntityDamageEvent(pTarget, EntityDamageEvent.DamageCause.ENTITY_ATTACK,dmg);
    3. pTarget.setLastDamageCause(evt);


    With this i made the damage at the Entity!

    Then at a working listener:
    Code:java
    1. Entity deadE = event.getEntity();
    2. DamageCause cause = ((EntityDamageEvent) event.getEntity().getLastDamageCause()).getCause();

    I got a NullPointerException at this line:
    DamageCause cause = ((EntityDamageEvent) event.getEntity().getLastDamageCause()).getCause();
    Why? I set the last DamageCause with the new Event or?
     
Thread Status:
Not open for further replies.

Share This Page