Fix continuing to use items after dropping or when a shield breaks (MC-231097, MC-168573) (#9344)

This commit is contained in:
KnightMiner authored and GitHub committed 2023-03-08 12:21:04 -08:00
1 parent 8f72c143a1
commit 001372bef2
3 files changed
+12 -2

No files matched your search

@@ -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 @@
}
@@ -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_());
@@ -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) {