PaperMC/patches
Bjarne Koll 9b149d34f9
Properly remove overriding potion effect modifiers
As of minecraft 1.15.2's first pre-release potion effects no longer
completely replace weaker once of the same potion effect type but rather
build a list of overriding potion effects to preserve and eventually
re-apply weaker potion effects that last longer than more powerful but
more shortlived overriding potion effects of the same type.

This replacement of such overriding potion effects simply removes the
attribute modifier added by the potion effect based on a single uuid
defined by each potion effect type.
After the removal, a new attribute modified is added that holds the
updated modifications based on the lower amplifier of the weaker potion
effect.
As the removal of the stronger potion effect is purely based on the
single uuid of each individual potion effect type the amplifier of the
old effect is not needed to properly remove the effect and is sadly not
passed to the removal logic in the first place.

This however fails for the absorption potion effect type, as it cannot
make use of the attribute modifier system and the single uuid concept
used by other potion effect types.
Hence, prior to this commit, it simply calculates the amount of
absorption hearts granted by the amplifier of the potion effect and
removes these.
As the server however only provides the amplifier (more specifically the
new potion effect) to the update method once an overriding absorption
effect is replaced, the removal only removes the amount of absorption
hearts.

This patch combats this faulty behaviour by now properly passing the old
and new mob effect (and their respective amplifier) through the update
logic of the living entity and mob effects.
While this prevents the absorption effect from leaving the player with
absorption hearts after the effect completely expires, it did allow the
effect to re-generate absorption hearts that were lost due to damage
when replacing the overriding effect with the lower potion effect.

The patch introduces MobEffect#updateAttributeModifiers which is
responsible for performing the previously described logic of removing
and applying attribute modifiers.
This method is then leveraged by the absorption mob effect to correctly
calculate the difference between the old and new amplifiers.

Resolves: https://bugs.mojang.com/browse/MC-182497
2022-06-12 01:23:33 +02:00
..
api Updated Upstream (Bukkit/CraftBukkit) (#7936) 2022-06-11 11:02:57 +02:00
removed Readd mc-4 fix 2022-06-11 10:41:59 +02:00
server Properly remove overriding potion effect modifiers 2022-06-12 01:23:33 +02:00