aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0192-WitchReadyPotionEvent.patch
blob: 8bbf7b47e0b0e4a01af557e04f6b69ca3bcbff60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Jun 2018 22:47:26 -0400
Subject: [PATCH] WitchReadyPotionEvent


diff --git a/src/main/java/net/minecraft/world/entity/monster/Witch.java b/src/main/java/net/minecraft/world/entity/monster/Witch.java
index a14e00d55930628333cc63b18727ea56dbdc4ee3..f6d01d21745391595d61b191832be4c28a3e58cb 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Witch.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java
@@ -151,7 +151,11 @@ public class Witch extends Raider implements RangedAttackMob {
                 }
 
                 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()) {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 50a4e657508e21717a61900660d85203d9373e19..1c53b872b30bcd8535b8686015935025a4c9837f 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1947,4 +1947,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
 }