Setting Damage Cause And Running Death Event

Discussion in 'Plugin Development' started by Acer_Mortem, Aug 18, 2013.

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

    Acer_Mortem

    If the plugin were to damage a player by 4 hearts, how can I set the damagecause to another player and then run the death event?
     
  2. Offline

    slater96

  3. Offline

    Acer_Mortem

    slater96

    I don't think you get what I mean. Allow me to explain it a bit more:


    A player right clicks an item in their inventory, and all entities nearby are damaged for 4 hearts, and one entity (creeper) dies. How could I run the death event with the killers name so I could set it to lastdamagcause/killer?
     
  4. Offline

    callum.thepro

    EntityDamageEvent: Check which entities was damaged and set the last damage cause to the instance of the entity which damaged them which would be an entity of a player.
     
  5. Offline

    Quantix

    When damaging entities such as creepers or players, instead of only inputting the the amount of damage, add a second argument as the source of the damage or the damager (in this case the player) like this:
    Code:java
    1. livingEntity.damage(6D, player)
    If I'm not mistaken this automatically fires an EntityDamageByEntity event with the damager being the player and if the entity dies the getKiller() of that entity will also return the player. Hope this helps!
     
Thread Status:
Not open for further replies.

Share This Page