onEntityDeath Big Problem Please help.

Discussion in 'Plugin Development' started by sajmonks, Jan 4, 2012.

Thread Status:
Not open for further replies.
  1. Hi everyone.
    I have a big problem with event onEntityDeath, as you know when time set to 'morning' zombies are burning, and question is how to block this thing. I want to to make something like that.
    if(event.getEntity().getLastCause().getCause == DamageCause.ENTITY_ATTACK) {return;} // it won't work

    Edit: Its important becouse when i get EntityDamagedByEntity then server showing error.
  2. Offline


    You did not specify your problem very well, and I can't quite tell what your code is even about.
    Please tell us exactly what you want to achieve and why your approach failed, or in general, what you have tried before.

    In case you have never dealt with plugins before, you should read this and have a reference to this, before you ask.

    I hope this helps, I'll be glad to help you with your problem once I know what it is. =P
  3. Look for EntityCombustEvent (event type ENTITY_COMBUST)
  4. Look at that

    public void onEntityDeath(EntityDeathEvent event){
         if(!(event.getEntity().getLastCause().getCause == DamageCause.FIRE)){
              EntityDamagedByEntityEvent e = (EntityDamagedByEntityEvent)event.getEntity().getLastCause();
              Entity damager = e.getDamager(); // ERROR HELP
              //if i do something with damager it show error.
    Sorry for my english, but i have to fix it very quick. And Thanks for all.
  5. Offline


    Just a guess: how can you get the damager if fire isn't an entity?
  6. Ohh man i try to get a cause of damage. And one another thing the error is showing when i cast a
    EntityDamagedByEntityEvent e = (EntityDamagedByEntityEvent)event.getEntity().getLastCause();
  7. As the name suggests, EntityDamagedByEntityEvent means the damage came from another entity. When you check if the damage cause was FIRE (and fire is not an entity, as @bogdacutu pointed out), the event is obviously not an EntityDamagedByEntityEvent, thus you can't cast it. To get the cause of the damage, use getCause() as you already did, where is the problem?!

    To prevent mobs from burning due to sunlight, you are still supposed to use EntityCombustEvent ...
Thread Status:
Not open for further replies.

Share This Page