Fix potions splash events

Fix PotionSplashEvent for water splash potions
Fixes SPIGOT-6221: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6221
Fix splash events cancellation that still show particles/sound
This commit is contained in:
Jake Potrebic
2021-05-20 20:40:53 -07:00
parent 9b7c0ce420
commit 0bf80e49be
2 changed files with 100 additions and 13 deletions

View File

@@ -884,6 +884,32 @@ public class CraftEventFactory {
return event;
}
// Paper start - Fix potions splash events
public static io.papermc.paper.event.entity.WaterBottleSplashEvent callWaterBottleSplashEvent(net.minecraft.world.entity.projectile.ThrownPotion potion, @Nullable HitResult hitResult, Map<LivingEntity, Double> affectedEntities, java.util.Set<LivingEntity> rehydrate, java.util.Set<LivingEntity> extinguish) {
ThrownPotion thrownPotion = (ThrownPotion) potion.getBukkitEntity();
Block hitBlock = null;
BlockFace hitFace = null;
org.bukkit.entity.Entity hitEntity = null;
if (hitResult != null) {
if (hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHitResult = (BlockHitResult) hitResult;
hitBlock = CraftBlock.at(potion.level(), blockHitResult.getBlockPos());
hitFace = CraftBlock.notchToBlockFace(blockHitResult.getDirection());
} else if (hitResult.getType() == HitResult.Type.ENTITY) {
hitEntity = ((EntityHitResult) hitResult).getEntity().getBukkitEntity();
}
}
io.papermc.paper.event.entity.WaterBottleSplashEvent event = new io.papermc.paper.event.entity.WaterBottleSplashEvent(
thrownPotion, hitEntity, hitBlock, hitFace, affectedEntities, rehydrate, extinguish
);
event.callEvent();
return event;
}
// Paper end - Fix potions splash events
/**
* BlockFadeEvent
*/