From 86daffa21c13f46361313120dd49f4bb9118b8d9 Mon Sep 17 00:00:00 2001 From: Lukasz Derlatka Date: Sat, 7 Dec 2019 19:03:10 -0600 Subject: [PATCH] Fix AssertionError when player hand set to empty type Fixes GH-2718 --- ...or-when-player-hand-set-to-empty-typ.patch | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Spigot-Server-Patches/0425-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch diff --git a/Spigot-Server-Patches/0425-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch b/Spigot-Server-Patches/0425-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch new file mode 100644 index 0000000000..fc4798a4b1 --- /dev/null +++ b/Spigot-Server-Patches/0425-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch @@ -0,0 +1,38 @@ +From 2076e011a05ccc5f7ac008f55cabb56d0f478766 Mon Sep 17 00:00:00 2001 +From: Lukasz Derlatka +Date: Mon, 11 Nov 2019 16:08:13 +0100 +Subject: [PATCH] Fix AssertionError when player hand set to empty type + +Fixes an AssertionError when setting the player's item in hand to null or a new ItemStack of Air in PlayerInteractEvent +Fixes GH-2718 + +diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java +index f675ad2f5..addbafe66 100644 +--- a/src/main/java/net/minecraft/server/EntityLiving.java ++++ b/src/main/java/net/minecraft/server/EntityLiving.java +@@ -1864,6 +1864,7 @@ public abstract class EntityLiving extends Entity { + return this.getEquipment(EnumItemSlot.OFFHAND); + } + ++ public ItemStack getItemInHand(EnumHand enumhand) { return this.b(enumhand); } // Paper - OBFHELPER + public ItemStack b(EnumHand enumhand) { + if (enumhand == EnumHand.MAIN_HAND) { + return this.getEquipment(EnumItemSlot.MAINHAND); +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index ae17cdf23..c9872cbd0 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -1413,6 +1413,10 @@ public class PlayerConnection implements PacketListenerPlayIn { + if (cancelled) { + this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 + } else { ++ // Paper start ++ itemstack = this.player.getItemInHand(enumhand); ++ if (itemstack.isEmpty()) return; ++ // Paper end + this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); + } + // CraftBukkit end +-- +2.24.0 +