From 92bc19b04906c187cf297ce1742c06751867ace8 Mon Sep 17 00:00:00 2001 From: Owen <23108066+Owen1212055@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:48:46 -0400 Subject: [PATCH] Fix missing item interaction cancelling case (#9427) Properly cancels brushes now --- .../0974-Properly-Cancel-Usable-Items.patch | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/patches/server/0974-Properly-Cancel-Usable-Items.patch b/patches/server/0974-Properly-Cancel-Usable-Items.patch index 45da59d385..a51b429994 100644 --- a/patches/server/0974-Properly-Cancel-Usable-Items.patch +++ b/patches/server/0974-Properly-Cancel-Usable-Items.patch @@ -9,6 +9,30 @@ For example, items being consumed but never finishing, shields being put up, etc The underlying issue of this is that the client modifies their synced data values, and so we have to (forcibly) resend them in order for the client to reset their using item state. +diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +index 1635fee928d64f4d2c336dca6675ed4641918830..afcee1e5bf1f735f3c893ec0b835dc5cd9759b7b 100644 +--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java ++++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +@@ -562,6 +562,7 @@ public class ServerPlayerGameMode { + } + // Paper end - extend Player Interact cancellation + player.getBukkitEntity().updateInventory(); // SPIGOT-2867 ++ this.player.resyncUsingItem(this.player); // Paper - Resend player's using item status + enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? InteractionResult.SUCCESS : InteractionResult.PASS; + } else if (this.gameModeForPlayer == GameType.SPECTATOR) { + MenuProvider itileinventory = iblockdata.getMenuProvider(world, blockposition); +@@ -605,6 +606,11 @@ public class ServerPlayerGameMode { + + return enuminteractionresult1; + } ++ // Paper start - Cancel only if cancelled + if the interact result is different from default response ++ else if (this.interactResult && this.interactResult != cancelledItem) { ++ this.player.resyncUsingItem(this.player); ++ } ++ // Paper end + } + return enuminteractionresult; + // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java index 1d0e439c00ac4ab72dc656038c9271b1240acc88..b777547cb9f8edf4e7b3c2cfb894f8cd1b1a35a5 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java