public boolean m(Entity entity) {
    int i = this.c(entity);

    if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
      i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
    }

    if (this.hasEffect(MobEffectList.WEAKNESS)) {
      i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier();
    }

    int j = 0;

    if (entity instanceof EntityLiving) {
      i += EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity);
      j += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity);
    }

    boolean flag = entity.damageEntity(DamageSource.mobAttack(this), i);

    if (flag) {
      if (j > 0) {
        entity.g(
            (double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F),
            0.1D,
            (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F));
        this.motX *= 0.6D;
        this.motZ *= 0.6D;
      }

      int k = EnchantmentManager.getFireAspectEnchantmentLevel(this);

      if (k > 0) {
        entity.setOnFire(k * 4);
      }
    }

    return flag;
  }
Exemple #2
0
  public void attack(Entity entity) {
    if (entity.k_()) {
      int i = this.inventory.a(entity);

      if (this.hasEffect(MobEffectList.INCREASE_DAMAGE)) {
        i += 3 << this.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier();
      }

      if (this.hasEffect(MobEffectList.WEAKNESS)) {
        i -= 2 << this.getEffect(MobEffectList.WEAKNESS).getAmplifier();
      }

      int j = 0;
      int k = 0;

      if (entity instanceof EntityLiving) {
        k = EnchantmentManager.a(this.inventory, (EntityLiving) entity);
        j += EnchantmentManager.getKnockbackEnchantmentLevel(this.inventory, (EntityLiving) entity);
      }

      if (this.isSprinting()) {
        ++j;
      }

      if (i > 0 || k > 0) {
        boolean flag =
            this.fallDistance > 0.0F
                && !this.onGround
                && !this.t()
                && !this.aU()
                && !this.hasEffect(MobEffectList.BLINDNESS)
                && this.vehicle == null
                && entity instanceof EntityLiving;

        if (flag) {
          i += this.random.nextInt(i / 2 + 2);
        }

        i += k;
        boolean flag1 = entity.damageEntity(DamageSource.playerAttack(this), i);

        if (flag1) {
          if (j > 0) {
            entity.b_(
                (double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F),
                0.1D,
                (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) j * 0.5F));
            this.motX *= 0.6D;
            this.motZ *= 0.6D;
            this.setSprinting(false);
          }

          if (flag) {
            this.c(entity);
          }

          if (k > 0) {
            this.d(entity);
          }

          if (i >= 18) {
            this.a((Statistic) AchievementList.E);
          }

          this.g(entity);
        }

        ItemStack itemstack = this.U();

        if (itemstack != null && entity instanceof EntityLiving) {
          itemstack.a((EntityLiving) entity, this);
          if (itemstack.count <= 0) {
            itemstack.a(this);
            this.V();
          }
        }

        if (entity instanceof EntityLiving) {
          if (entity.isAlive()) {
            this.a((EntityLiving) entity, true);
          }

          this.a(StatisticList.w, i);
          int l =
              EnchantmentManager.getFireAspectEnchantmentLevel(
                  this.inventory, (EntityLiving) entity);

          if (l > 0) {
            entity.setOnFire(l * 4);
          }
        }

        this.c(0.3F);
      }
    }
  }