WitchConsumePotionEvent

Fires when a witch consumes the potion in their hand
This commit is contained in:
Aikar 2018-05-16 20:35:16 -04:00
parent 40e2712d61
commit 72743537f4

View file

@ -1,7 +1,15 @@
--- a/net/minecraft/world/entity/monster/Witch.java
+++ b/net/minecraft/world/entity/monster/Witch.java
@@ -126,7 +126,7 @@
@@ -124,9 +124,15 @@
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
PotionContents potioncontents = (PotionContents) itemstack.get(DataComponents.POTION_CONTENTS);
+ // Paper start - WitchConsumePotionEvent
+ if (itemstack.is(Items.POTION)) {
+ com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack));
+ potioncontents = event.callEvent() ? org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getPotion()).get(DataComponents.POTION_CONTENTS) : null;
+ }
+ // Paper end - WitchConsumePotionEvent
if (itemstack.is(Items.POTION) && potioncontents != null) {
- potioncontents.forEachEffect(this::addEffect);