From b64e7f96d3e4dc5f9b832a38c15e6de3396beef2 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 5 Jun 2018 22:47:26 -0400 Subject: [PATCH] WitchReadyPotionEvent --- .../world/entity/monster/Witch.java.patch | 15 ++++++++++++++- .../craftbukkit/event/CraftEventFactory.java | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch index 617d50b281..d65661e879 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch @@ -17,7 +17,20 @@ } this.gameEvent(GameEvent.DRINK); -@@ -231,6 +237,13 @@ +@@ -146,7 +152,11 @@ + } + + if (holder != null) { +- this.setItemSlot(EquipmentSlot.MAINHAND, PotionContents.createItemStack(Items.POTION, holder)); ++ // Paper start ++ ItemStack potion = PotionContents.createItemStack(Items.POTION, holder); ++ potion = org.bukkit.craftbukkit.event.CraftEventFactory.handleWitchReadyPotionEvent(this, potion); ++ this.setItemSlot(EquipmentSlot.MAINHAND, potion); ++ // Paper end + this.usingTime = this.getMainHandItem().getUseDuration(this); + this.setUsingItem(true); + if (!this.isSilent()) { +@@ -231,6 +241,13 @@ ServerLevel worldserver = (ServerLevel) world; ItemStack itemstack = PotionContents.createItemStack(Items.SPLASH_POTION, holder); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0a3c89dba6..f05a19f868 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1974,4 +1974,14 @@ public class CraftEventFactory { ).callEvent(); } // Paper end - PlayerUseUnknownEntityEvent + + // Paper start - WitchReadyPotionEvent + public static ItemStack handleWitchReadyPotionEvent(net.minecraft.world.entity.monster.Witch witch, @Nullable ItemStack potion) { + com.destroystokyo.paper.event.entity.WitchReadyPotionEvent event = new com.destroystokyo.paper.event.entity.WitchReadyPotionEvent((org.bukkit.entity.Witch) witch.getBukkitEntity(), CraftItemStack.asCraftMirror(potion)); + if (!event.callEvent() || event.getPotion() == null) { + return ItemStack.EMPTY; + } + return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion()); + } + // Paper end - WitchReadyPotionEvent }