public static void attack(EntityLiving handle, Entity target) { AttributeInstance attribute = handle.getAttributeInstance(GenericAttributes.e); float damage = (float) (attribute == null ? 1D : attribute.getValue()); if (handle.hasEffect(MobEffectList.INCREASE_DAMAGE)) { damage += 3 << handle.getEffect(MobEffectList.INCREASE_DAMAGE).getAmplifier(); } if (handle.hasEffect(MobEffectList.WEAKNESS)) { damage -= 2 << handle.getEffect(MobEffectList.WEAKNESS).getAmplifier(); } int knockbackLevel = 0; if (target instanceof EntityLiving) { damage += EnchantmentManager.a(handle, (EntityLiving) target); knockbackLevel += EnchantmentManager.getKnockbackEnchantmentLevel(handle, (EntityLiving) target); } boolean success = target.damageEntity(DamageSource.mobAttack(handle), damage); if (!success) return; if (knockbackLevel > 0) { target.g( -Math.sin(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * knockbackLevel * 0.5F); handle.motX *= 0.6D; handle.motZ *= 0.6D; } int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle); if (fireAspectLevel > 0) { target.setOnFire(fireAspectLevel * 4); } }
public boolean attack(Entity entity, float damage) { return this.attack(entity, DamageSource.mobAttack(this), f); }