Fix empty effect clouds from lingering potions (#8641)

This commit is contained in:
Jake Potrebic 2022-12-10 14:52:37 -08:00
parent 8b951a41ae
commit 09c45d4cab

View file

@ -126,6 +126,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Entity entity = this.getOwner();
@@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
entityareaeffectcloud.setPotion(potion);
Iterator iterator = PotionUtils.getCustomEffects(stack).iterator();
+ boolean noEffects = potion.getEffects().isEmpty(); // Paper
while (iterator.hasNext()) {
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
entityareaeffectcloud.addEffect(new MobEffectInstance(mobeffect));
+ noEffects = false; // Paper
}
CompoundTag nbttagcompound = stack.getTag();
@@ -0,0 +0,0 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
// CraftBukkit start
org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud);
- if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) {
+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved() || (noEffects && entityareaeffectcloud.effects.isEmpty() && entityareaeffectcloud.getPotion().getEffects().isEmpty()))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling
this.level.addFreshEntity(entityareaeffectcloud);
} else {
entityareaeffectcloud.discard();
}
// CraftBukkit end