Need some help with my ENTITY.DAMAGE event.

Discussion in 'Plugin Development' started by Pasukaru, Jun 5, 2011.

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

    Pasukaru

    Hi there,
    How can I get the damager from the damage event?
    with .getEntity() I'm only able to get the damagee...
    What im trying to do is something like this:
    Code:
    public void onEntityDamage(EntityDamageEvent event)
        Entity damager = ... <- there's my problem :/
        Entity damagee = event.getEntity();
    
        if( damager instanceof Wolf ){
            do this stuff;
        }  else if( damager instanceof something else )
            do this stuff;
        }
    }
    
    Well, I've also tried some other events, but they didn't even fire and I'm out of ideas now. :p

    Thanks in advance for your help :>
     
  2. Offline

    CypherX

    Code:
    if (event instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent edbeEvent = (EntityDamageByEntityEvent)event;
        Entity damager = edbeEvent.getDamager();
    }
     
    Pasukaru likes this.
  3. Offline

    Pasukaru

    Ahh thanks a lot :D
    I didn't even think about casting events :>
     
Thread Status:
Not open for further replies.

Share This Page