PaperMC/patches/server/0193-WitchReadyPotionEvent.patch
Jake Potrebic 0b7552272a
194
2024-06-13 11:09:28 -07:00

41 lines
2.4 KiB
Diff

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..a84f873b27bc3bc1ed3c2769e02a88fec37289fe 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Witch.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Witch.java
@@ -151,6 +151,11 @@ public class Witch extends Raider implements RangedAttackMob {
}
if (holder != null) {
+ // 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.setItemSlot(EquipmentSlot.MAINHAND, PotionContents.createItemStack(Items.POTION, holder));
this.usingTime = this.getMainHandItem().getUseDuration(this);
this.setUsingItem(true);
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 000a95dfd5c83b84fcd973a388a705d9470a4fe0..4e0db83bb6a4529b6e0727ea181bf79e06c2025a 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1905,4 +1905,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
}