3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0658-Fix-PlayerBucketEmptyEvent-result-itemstack.patch

43 Zeilen
2.2 KiB
Diff

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
2022-06-08 11:31:06 +02:00
index 7c6c928da4e0f3ac54fa9b9ddce7b0e0bf3cce4b..73f1211470d9626c82c8345037da19aed9db3f23 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
2022-06-08 11:31:06 +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
2021-06-15 05:50:26 +02:00
+
public final Fluid content;
public BucketItem(Fluid fluid, Item.Properties settings) {
2022-06-08 11:31:06 +02:00
@@ -121,6 +123,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
2021-06-11 14:02:28 +02:00
+ if (itemLeftInHandAfterPlayerBucketEmptyEvent != null) {
+ ItemStack itemInHand = itemLeftInHandAfterPlayerBucketEmptyEvent;
+ itemLeftInHandAfterPlayerBucketEmptyEvent = null;
+ return itemInHand;
+ }
2021-06-15 05:50:26 +02:00
+ // Paper end
return !player.getAbilities().instabuild ? new ItemStack(Items.BUCKET) : stack;
2021-06-11 14:02:28 +02:00
}
2022-06-08 11:31:06 +02:00
@@ -153,6 +162,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 empty event result itemstack
2021-06-11 14:02:28 +02:00
}
// CraftBukkit end
if (!flag1) {