mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 19:00:16 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
64 lines
3.8 KiB
Diff
64 lines
3.8 KiB
Diff
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 ed81d2a306d28561370745bb3389c49012f677a7..fbdfab50af195d219f9745324c8924fc777f76ec 100644
|
|
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
|
@@ -99,6 +99,7 @@ public class DamageSource {
|
|
return (new IndirectEntityDamageSource("thrown", projectile, attacker)).setProjectile();
|
|
}
|
|
|
|
+ public static DamageSource indirectMagic(Entity target, Entity cause) { return indirectMagic(target, cause); } // Paper - OBFHELPER
|
|
public static DamageSource indirectMagic(Entity magic, @Nullable Entity attacker) {
|
|
return (new IndirectEntityDamageSource("indirectMagic", magic, attacker)).bypassArmor().setMagic();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
index 2ff7e8dfc0a520fb330177c140a1ae5c729f14c0..8bf095bce9dfec6479185b6e60c2e9d76e3363eb 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
@@ -122,6 +122,7 @@ public class ThrownPotion extends ThrowableItemProjectile {
|
|
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();
|
|
@@ -131,11 +132,22 @@ public class ThrownPotion extends ThrowableItemProjectile {
|
|
double d0 = this.distanceToSqr(entityliving);
|
|
|
|
if (d0 < 16.0D && entityliving.isSensitiveToWater()) {
|
|
- entityliving.hurt(DamageSource.indirectMagic(entityliving, this.getOwner()), 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()) {
|
|
+ net.minecraft.world.entity.LivingEntity entityliving = ((CraftLivingEntity) affectedEntity).getHandle();
|
|
+ entityliving.hurt(DamageSource.indirectMagic(entityliving, this.getOwner()), 1.0F);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
private void applySplash(List<MobEffectInstance> statusEffects, @Nullable Entity entity) {
|
|
@@ -153,6 +165,7 @@ public class ThrownPotion extends ThrowableItemProjectile {
|
|
double d0 = this.distanceToSqr(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) {
|