PaperMC/patches/server/0548-Fix-PlayerBucketEmptyEvent-result-itemstack.patch

43 lines
2.3 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 20 May 2021 22:16:37 -0700
Subject: [PATCH] Fix PlayerBucketEmptyEvent result itemstack
Fixes SPIGOT-2560: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-2560
diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java
2024-06-14 01:32:45 +02:00
index 7617b6a0ad44e8b135d071836dc30df5ad062c42..6caed156ed0cfe0017d578f58cb963ee68272d78 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
2024-04-24 16:29:12 +02:00
@@ -40,6 +40,8 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
2021-06-15 05:50:26 +02:00
public class BucketItem extends Item implements DispensibleContainerItem {
+ private static @Nullable ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper - Fix PlayerBucketEmptyEvent result itemstack
2021-06-15 05:50:26 +02:00
+
public final Fluid content;
public BucketItem(Fluid fluid, Item.Properties settings) {
2024-06-14 01:32:45 +02:00
@@ -125,6 +127,13 @@ public class BucketItem extends Item implements DispensibleContainerItem {
2021-06-11 14:02:28 +02:00
}
2021-06-15 05:50:26 +02:00
public static ItemStack getEmptySuccessItem(ItemStack stack, Player player) {
+ // Paper start - Fix PlayerBucketEmptyEvent result itemstack
2021-06-11 14:02:28 +02:00
+ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) {
+ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent;
+ itemLeftInHandAfterPlayerBucketEmptyEvent = null;
+ return itemInHand;
+ }
+ // Paper end - Fix PlayerBucketEmptyEvent result itemstack
2024-04-24 16:29:12 +02:00
return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : stack;
2021-06-11 14:02:28 +02:00
}
2024-06-14 01:32:45 +02:00
@@ -182,6 +191,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
2021-06-11 14:02:28 +02:00
((ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
return false;
}
+ itemLeftInHandAfterPlayerBucketEmptyEvent = event.getItemStack() != null ? event.getItemStack().equals(CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.BUCKET)) ? null : CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; // Paper - Fix PlayerBucketEmptyEvent result itemstack
2021-06-11 14:02:28 +02:00
}
// CraftBukkit end
2023-09-22 07:41:27 +02:00
if (!flag2) {