From 001372bef2433c84245f705ed10582c756db43ac Mon Sep 17 00:00:00 2001 From: KnightMiner Date: Wed, 8 Mar 2023 15:21:04 -0500 Subject: [PATCH] Fix continuing to use items after dropping or when a shield breaks (MC-231097, MC-168573) (#9344) --- .../net/minecraft/client/player/LocalPlayer.java.patch | 8 ++++++++ .../net/minecraft/server/level/ServerPlayer.java.patch | 3 ++- .../net/minecraft/world/entity/player/Player.java.patch | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index 62de244c50..48192aaffe 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -8,6 +8,14 @@ return false; } +@@ -276,6 +_,7 @@ + + public boolean m_108700_(boolean p_108701_) { + ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_ ? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS : ServerboundPlayerActionPacket.Action.DROP_ITEM; ++ if (m_6117_() && m_7655_() == InteractionHand.MAIN_HAND && (p_108701_ || m_21211_().m_41613_() == 1)) m_5810_(); // Forge: fix MC-231097 on the clientside + ItemStack itemstack = this.m_150109_().m_182403_(p_108701_); + this.f_108617_.m_104955_(new ServerboundPlayerActionPacket(serverboundplayeractionpacket$action, BlockPos.f_121853_, Direction.DOWN)); + return !itemstack.m_41619_(); @@ -462,7 +_,14 @@ } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index 3162eb8f06..f91e3b8a3e 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -289,12 +289,13 @@ public TextFilter m_8967_() { return this.f_8939_; } -@@ -1550,11 +_,13 @@ +@@ -1550,11 +_,14 @@ public boolean m_182294_(boolean p_182295_) { Inventory inventory = this.m_150109_(); + ItemStack selected = inventory.m_36056_(); + if (selected.m_41619_() || !selected.onDroppedByPlayer(this)) return false; ++ if (m_6117_() && m_7655_() == InteractionHand.MAIN_HAND && (p_182295_ || selected.m_41613_() == 1)) m_5810_(); // Forge: fix MC-231097 on the serverside ItemStack itemstack = inventory.m_182403_(p_182295_); this.f_36096_.m_182417_(inventory, inventory.f_35977_).ifPresent((p_182293_) -> { this.f_36096_.m_150404_(p_182293_, inventory.m_36056_()); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch index e652aca966..5a0606ab69 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -135,11 +135,12 @@ if (!this.f_19853_.f_46443_) { this.m_36246_(Stats.f_12982_.m_12902_(this.f_20935_.m_41720_())); } -@@ -874,6 +_,7 @@ +@@ -874,6 +_,8 @@ InteractionHand interactionhand = this.m_7655_(); this.f_20935_.m_41622_(i, this, (p_219739_) -> { p_219739_.m_21190_(interactionhand); + net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.f_20935_, interactionhand); ++ m_5810_(); // Forge: fix MC-168573 }); if (this.f_20935_.m_41619_()) { if (interactionhand == InteractionHand.MAIN_HAND) {