@Override
  public boolean attackEntityAsMob(Entity par1Entity) {
    float attackDamage =
        (float) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
    int knockback = 0;

    if (par1Entity instanceof EntityLivingBase) {
      attackDamage +=
          EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase) par1Entity);
      knockback += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase) par1Entity);
    }

    boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage);

    if (flag) {
      if (knockback > 0) {
        par1Entity.addVelocity(
            (double)
                (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F)
                    * (float) knockback
                    * 0.5F),
            0.1D,
            (double)
                (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F)
                    * (float) knockback
                    * 0.5F));
        this.motionX *= 0.6D;
        this.motionZ *= 0.6D;
      }

      int j = EnchantmentHelper.getFireAspectModifier(this);
      if (j > 0) par1Entity.setFire(j * 4);

      if (par1Entity instanceof EntityLivingBase)
        EnchantmentHelper.func_151384_a((EntityLivingBase) par1Entity, this);

      EnchantmentHelper.func_151385_b(this, par1Entity);
    }

    return flag;
  }
Exemple #2
0
  public boolean r(Entity entity) {
    boolean flag0 = super.r(entity);

    if (flag0) {
      int i0 = this.o.aa().a();

      if (this.bz() == null && this.au() && this.V.nextFloat() < (float) i0 * 0.3F) {
        entity.e(2 * i0);
      }
    }

    return flag0;
  }