get entity that killed an entity

Discussion in 'Plugin Development' started by rmb938, Jun 14, 2011.

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

    rmb938

    Hi, how do I get an entity that killed an entity?

    So far I have

    Code:
    @Override
        public void onEntityDeath(EntityDeathEvent event) {
    EntityDamageEvent e = event.getEntity().getLastDamageCause();
                    if (e.getCause() == DamageCause.ENTITY_ATTACK) {
                    }
    
    }
    Not to sure what to do after that.
     
  2. Offline

    Crash

    I don't think there is a way.

    You can try EntityDamageEvent and check if the entity's health is less than or equal to zero
     
  3. Offline

    chronopolis

    That won't work because the event is called before the damage is done :p You could check the Entitys health and see if its <= event.getDamage()
     
  4. Offline

    rmb938

    That will work. How do I get the entity's health?

    Wait you do LivingEntity le = (LivingEntity) defenderEntity;

    le.getHealth() right?
     
  5. Offline

    K S

    Beside that ENTITY_ATTACK doesn't even appear to be implemented. The only DamageCauses I see in bukkit code are FIRE, FIRE_TICK, SUFFOCATION, DROWNING, and FALL (in net.minecraft.server.Entity and LivingEntity)
     
  6. Offline

    Shamebot

    You can get the damaging entity by casting to EntityDamagedByEntityEvent.
     
  7. Offline

    nisovin

  8. Offline

    K S

    cool (i appear to have missed a bunch on my initial search)
    Code:
    new EntityDamageByEntityEvent(damager, damagee, damageType, i);
     
  9. Offline

    Avatharian

    What? No! You can't stop there! How do you finish it?
     
Thread Status:
Not open for further replies.

Share This Page