I have done it this way (I'm not sure if this is an efficient way to do it but it works)
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase ent, EntityLivingBase player)
{
float damage = 0.0f;
if (ent instanceof EntityEnderman || ent instanceof EntityDragon)
{
damage = 25.0f;
stack.damageItem(1, player);
}
DamageSource dmgSource = DamageSource.causePlayerDamage((EntityPlayer) player);
ent.attackEntityFrom(dmgSource, damage);
return true;
}