papermc/patches/unapplied/server/0693-Fix-PlayerBucketEmptyEvent-result-itemstack.patch

45 lines
2.1 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
index 650b59b69eb12112bc71e5ff164767e3118e1c2a..69c992ef0c526adf35907de7726832605187beb6 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
2021-06-15 03:50:26 +00:00
@@ -41,6 +41,8 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
public class BucketItem extends Item implements DispensibleContainerItem {
+ private static ItemStack itemLeftInHandAfterPlayerBucketEmptyEvent = null; // Paper
+
public final Fluid content;
public BucketItem(Fluid fluid, Item.Properties settings) {
@@ -122,6 +124,13 @@ public class BucketItem extends Item implements DispensibleContainerItem {
2021-06-11 12:02:28 +00:00
}
2021-06-15 03:50:26 +00:00
public static ItemStack getEmptySuccessItem(ItemStack stack, Player player) {
+ // Paper start
2021-06-11 12:02:28 +00:00
+ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) {
+ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent;
+ itemLeftInHandAfterPlayerBucketEmptyEvent = null;
+ return itemInHand;
+ }
2021-06-15 03:50:26 +00:00
+ // Paper end
return !player.getAbilities().instabuild ? new ItemStack(Items.BUCKET) : stack;
2021-06-11 12:02:28 +00:00
}
@@ -154,6 +163,9 @@ public class BucketItem extends Item implements DispensibleContainerItem {
2021-06-11 12:02:28 +00:00
((ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
return false;
}
+ // Paper start
+ itemLeftInHandAfterPlayerBucketEmptyEvent = event.getItemStack().equals(CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.BUCKET)) ? null : CraftItemStack.asNMSCopy(event.getItemStack());
+ // Paper end
}
// CraftBukkit end
if (!flag1) {