Esempio n. 1
0
  public static void attack(EntityLiving handle, Entity target) {
    AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
    float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
    int i = 0;

    if (target instanceof EntityLiving) {
      f += EnchantmentManager.a(handle.bA(), ((EntityLiving) target).getMonsterType());
      i += EnchantmentManager.a(handle);
    }

    boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);

    if (!flag) return;
    if (i > 0) {
      target.g(
          -Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F,
          0.1D,
          Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
      handle.motX *= 0.6D;
      handle.motZ *= 0.6D;
    }

    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);

    if (fireAspectLevel > 0) {
      target.setOnFire(fireAspectLevel * 4);
    }
  }