Tamed wolves killing mobs

Discussion in 'Plugin Development' started by flametornado, Jun 16, 2011.

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

    flametornado

    Hi, Is there anyone that can help me with finding out when a tamed wolf killed a mob/creature?

    I tried:

    Code:
    if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf){
    			System.out.println("hello world");
    		}
    
    but it never seems to go off when one of my wolves is killing anything.

    Any help would be appreciated.
     
  2. Offline

    jeffadkins51

    Hm. I have never really played with something like this, but ill look into it.
     
  3. Hay this should work:D
    Code:
    public void onEntityDeath(EntityDeathEvent event)
    {
        if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)
        {
            EntityDamageByEntityEvent e = (EntityDamageByEntityEvent)event.getEntity().getLastDamageCause();
            if(e.getDamager() instanceof Wolf && ((Wolf)e.getDamager()).isTamed() == true)
            {
                
                
            }
        }
    }
     
  4. Offline

    flametornado

    i tried that, and it didn't work for me :(. I also outputted what class the last damage cause damager was and it said it was a player. I wonder if bukkit does something strange when tamed wolves attack.
     
  5. Offline

    DreadKyller

    it works for me just fine, I made it add a number for every kill a wolf makes when tamed and then at the end I typed a command that printed the total kills to the console and I got the 6 kills my wolf did.
     
  6. It definitely works because I use it myself:p
    please post the code where u use it.
     
  7. Offline

    flametornado

Thread Status:
Not open for further replies.

Share This Page