diff --git a/Spigot-Server-Patches/Fix-PotionSplashEvent-for-water-splash-potions.patch b/Spigot-Server-Patches/Fix-PotionSplashEvent-for-water-splash-potions.patch new file mode 100644 index 0000000000..f6c8dc0c59 --- /dev/null +++ b/Spigot-Server-Patches/Fix-PotionSplashEvent-for-water-splash-potions.patch @@ -0,0 +1,63 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic <jake.m.potrebic@gmail.com> +Date: Thu, 20 May 2021 20:40:53 -0700 +Subject: [PATCH] Fix PotionSplashEvent for water splash potions + +Fixes SPIGOT-6221: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6221 + +diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java ++++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java +@@ -0,0 +0,0 @@ public class DamageSource { + return (new EntityDamageSourceIndirect("thrown", entity, entity1)).c(); + } + ++ public static DamageSource indirectMagic(Entity target, Entity cause) { return c(target, cause); } // Paper - OBFHELPER + public static DamageSource c(Entity entity, @Nullable Entity entity1) { + return (new EntityDamageSourceIndirect("indirectMagic", entity, entity1)).setIgnoreArmor().setMagic(); + } +diff --git a/src/main/java/net/minecraft/world/entity/projectile/EntityPotion.java b/src/main/java/net/minecraft/world/entity/projectile/EntityPotion.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/EntityPotion.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/EntityPotion.java +@@ -0,0 +0,0 @@ public class EntityPotion extends EntityProjectileThrowable { + private void splash() { + AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D); + List<EntityLiving> list = this.world.a(EntityLiving.class, axisalignedbb, EntityPotion.b); ++ Map<LivingEntity, Double> affected = new HashMap<>(); // Paper + + if (!list.isEmpty()) { + Iterator iterator = list.iterator(); +@@ -0,0 +0,0 @@ public class EntityPotion extends EntityProjectileThrowable { + double d0 = this.h(entityliving); + + if (d0 < 16.0D && entityliving.dO()) { +- entityliving.damageEntity(DamageSource.c(entityliving, this.getShooter()), 1.0F); ++ // Paper start ++ double intensity = 1.0D - Math.sqrt(d0) / 4.0D; ++ affected.put(entityliving.getBukkitLivingEntity(), intensity); ++ // entityliving.damageEntity(DamageSource.c(entityliving, this.getShooter()), 1.0F); // Paper - moved down + } + } + } + ++ org.bukkit.event.entity.PotionSplashEvent event = CraftEventFactory.callPotionSplashEvent(this, affected); ++ if (!event.isCancelled()) { ++ for (LivingEntity affectedEntity : event.getAffectedEntities()) { ++ EntityLiving entityliving = ((CraftLivingEntity) affectedEntity).getHandle(); ++ entityliving.damageEntity(DamageSource.indirectMagic(entityliving, this.getShooter()), 1.0F); ++ } ++ } ++ // Paper end + } + + private void a(List<MobEffect> list, @Nullable Entity entity) { +@@ -0,0 +0,0 @@ public class EntityPotion extends EntityProjectileThrowable { + double d0 = this.h(entityliving); + + if (d0 < 16.0D) { ++ // Paper - diff on change, used when calling the splash event for water splash potions + double d1 = 1.0D - Math.sqrt(d0) / 4.0D; + + if (entityliving == entity) {