Potions do not give the same time duration to mobs in the same exact area
dispensing a potion onto mobs that are piled in the exacted same area can give different time for the effects.
What we would expect is all mobs get the same time duration of the effect.
Image of all mobs in same location. Yet 2 mobs have different effect lengths.
Created Issue:
potions do not give same time duration to mobs in the same exact area
dispensing a potion onto mobs that are piled in the exacted same area can give different time for the effects.
What we would expect is all mobs get the same time duration of the effect.
Changed Description:
dispensing a potion onto mobs that are piled in the exacted same area can give different time for the effects.
What we would expect is all mobs get the same time duration of the effect.Image of all mobs in same location. Yet 2 mobs have different effect lengths.
Changed Summary:
potions do not give same time duration to mobs in the same exact areaPotions do not give the same time duration to mobs in the same exact area
Added Mojang Priority:
Important
Removed Category: (Unassigned)
Added Assignee:
[Mojang] eowyn36
Removed Assignee:
[Mojang] eowyn36


Can confirm. May be relevant to this comment by [Mojang] Jeb (Jens Bergensten) in
MC-1149:"The duration is less the farther you are from the impact point. I just verified that if you are directly hit by the splash potion, you get the full duration."
Despite the entities being in the same block position, the game may not be handling it as such, and could consider some entities to be further away somehow.
Is this a problem introduced in 1.20.5-pre4, or did this also happen in 1.20.4 or earlier? If so, please update those versions.
From code checking by GuiTaek:
They changed something in the code. I'm not fully sure if it is the bug you encountered, but I'm sure this is a bug. They wrote "return" instead of "break" which makes the whole splash potion event not doing anything the first time, they encounter a mob that is dead. Haven't checked this in game (as I actually don't know how to check that). The durations are calculated correctly (that is, the same as before) but the code is a whole lot more messy and I kinda wish they hadn't done the change.
{ return; }For reference the yarn-mapping translation:
do {
do {
if (!var6.hasNext())
livingEntity = (LivingEntity)var6.next();
} while(!livingEntity.isAffectedBySplashPotions());
d = this.squaredDistanceTo(livingEntity);
} while(!(d < 16.0));
So what I said above wasn't quite right, because the iterator is iterated over in the whole function. But reading the code I got a theory and I tested the theory. Maybe you can say, if this theory applies to you?
{id:creeper, Health: 24}So in the code, every entity colliding with the splash potion can trigger the splash potion. It does not depend on the distance, I think, just on whatever entity is calling onCollision first. When it is the entity that triggered the potion, it will get its full power. Else it will trigger the distance debuff.
You can test this in pre4 with the following two commands:
/give @p minecraft:zombie_spawn_egg[minecraft:entity_data=
]
{id:instant_damage,amplifier:2,duration:-1}/give @p minecraft:splash_potion[minecraft:potion_contents={custom_effects:[
]}]
{ e = 1.0; }The first one will give you a spawn egg with a creeper that has health 24, exactly the amount that the potion of the second command does. When you spawn enough creepers in a hole where they can't escape, then splash the creepers with the potion, exactly one will die, the others won't. To be honest, if this is your bug, I'm not even sure if this is fixable because it sounds a little bit intended.
The code part in question is:
if (livingEntity == entity)
else
{ e = 1.0 - Math.sqrt(d) / 4.0; }