[SOLVED] Is there any way to disable critical hit?

I want to disable vanilla crits but it is harder than i thought. It would be perfect if i can disable crits and its animation, but now i only can recalculate final damage in AttackEntityEvent. I’ve tried to change DamageModifier's in event, but all of them are in immutable lists, so i can’t do this. So, is there any way to do this?

DamageModifierTypes.CRITICAL_HIT is a modifier type for critical hits.

So in the event you can iterate the list of DamageModifiers and if you find one of type CRITICAL_HIT, then you can set its function to be Functions.identity() - that is, it will not modify the damage in any way. You can do that with AttackEntityEvent#setOutputDamage(DamageModifier, Function<Double,Double>) function.

You are almost right! But instead Function.identity() i set d -> 0.0, becase it doubles base damage in your case. Critical particles are also gone.
Thank you :slight_smile:

Tick the checkout at the bottom of the posted solution to mark as solved

It shouldn’t be doubling the damage using Functions.identity() That smells of a bug.

Yep, it is really strange. It seems that final damage is sum of all functions, but critical function multiplies input damage by 1.5, so the final damage is 250% instead of 150%.

Or maybe it is my fault? I’m using AttackEntityEvent#setBaseOutputDamage(double) to set base damage to value that i need, for example 10, and final damage during critical hit is 25, it is always 250%, but if i look into AttackEntityEvent#getOriginalDamages() on critical DamageModifier value is 150% of my weapon damage. Do not understand what is original damages.