aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0338-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch
blob: e1945e2b80f9bf860266f58ab1956fd2cc69a448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Lukasz Derlatka <toranktto@gmail.com>
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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 9d3a88ed093c5eda7a11133ebc97226c544fbd18..0df93b204ddf55a2a3b8af33d6a3273697eea91e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1870,6 +1870,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
                 this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
                 return;
             }
+            // Paper start
+            itemstack = this.player.getItemInHand(enumhand);
+            if (itemstack.isEmpty()) return;
+            // Paper end
             InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
 
             if (enuminteractionresult.shouldSwing()) {