From 0000000000000000000000000000000000000000 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 1cd1c80a867316cf68998962bba169db04cefe13..8dc2e28b2386a3b9512dfcc382f9deb534381392 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -2040,6 +2040,7 @@ public abstract class EntityLiving extends Entity { return predicate.test(this.getItemInMainHand().getItem()) || predicate.test(this.getItemInOffHand().getItem()); } + public final 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 e382315c91540ac24821e432ee31a8244f4f7efa..204eae3abdb006c3006537e6cf8f4c7a0bae2a47 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -1477,6 +1477,10 @@ public class PlayerConnection implements PacketListenerPlayIn { this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524 return; } + // Paper start + itemstack = this.player.getItemInHand(enumhand); + if (itemstack.isEmpty()) return; + // Paper end EnumInteractionResult enuminteractionresult = this.player.playerInteractManager.a(this.player, worldserver, itemstack, enumhand); if (enuminteractionresult.b()) {