geforkt von Mirrors/Paper
aa52bf9e33
Mojang made some changes to priorities in 1.17 and it seems that these changes conflict with the changes made in this patch, which in some cases appears to cause excessive rescheduling of tasks. This, however, is not confirmed as such but seems to be the behavior that we're seeing to cause this issue, if mojang has adopted the changes we suggested, then a good chunk of this patch may be unneeded, but, this needs a much better look than I'm currently able to do
53 Zeilen
3.0 KiB
Diff
53 Zeilen
3.0 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/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
index 4dc6ab94a50a1dca8603129b28405578d381a06e..8676796ff65cd0bd3f215dc7edcf3a5b2291ca27 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
|
@@ -126,6 +126,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
|
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();
|
|
@@ -135,11 +136,23 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
|
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
|
|
+
|
|
List<Axolotl> list1 = this.level.getEntitiesOfClass(Axolotl.class, axisalignedbb);
|
|
Iterator iterator1 = list1.iterator();
|
|
|
|
@@ -167,6 +180,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
|
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) {
|