2021-06-11 12:02:28 +00:00
|
|
|
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/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
2021-11-24 23:26:29 +00:00
|
|
|
index 517a0f6bf847c5bf01851ae326d1b12332c2672c..1adcc0321b5528a4a173027be67139a9e9be5770 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
2021-11-24 23:26:29 +00:00
|
|
|
@@ -125,6 +125,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
2021-06-11 12:02:28 +00:00
|
|
|
private void applyWater() {
|
|
|
|
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
|
|
|
|
List<net.minecraft.world.entity.LivingEntity> list = this.level.getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE);
|
|
|
|
+ Map<LivingEntity, Double> affected = new HashMap<>(); // Paper
|
|
|
|
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
Iterator iterator = list.iterator();
|
2021-11-24 23:26:29 +00:00
|
|
|
@@ -134,11 +135,23 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
|
|
|
double d0 = this.distanceToSqr((Entity) entityliving);
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
if (d0 < 16.0D && entityliving.isSensitiveToWater()) {
|
2021-11-24 23:26:29 +00:00
|
|
|
- entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ double intensity = 1.0D - Math.sqrt(d0) / 4.0D;
|
|
|
|
+ affected.put(entityliving.getBukkitLivingEntity(), intensity);
|
2021-11-24 23:26:29 +00:00
|
|
|
+ // entityliving.hurt(DamageSource.indirectMagic(this, this.getOwner()), 1.0F); // Paper - moved down
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ org.bukkit.event.entity.PotionSplashEvent event = CraftEventFactory.callPotionSplashEvent(this, affected);
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ for (LivingEntity affectedEntity : event.getAffectedEntities()) {
|
|
|
|
+ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) affectedEntity).getHandle();
|
|
|
|
+ entityliving.hurt(DamageSource.indirectMagic(entityliving, this.getOwner()), 1.0F);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2021-06-15 04:55:46 +00:00
|
|
|
+
|
|
|
|
List<Axolotl> list1 = this.level.getEntitiesOfClass(Axolotl.class, axisalignedbb);
|
|
|
|
Iterator iterator1 = list1.iterator();
|
2021-06-11 12:02:28 +00:00
|
|
|
|
2021-11-24 23:26:29 +00:00
|
|
|
@@ -166,6 +179,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
|
|
|
double d0 = this.distanceToSqr((Entity) entityliving);
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
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) {
|