PaperMC/Spigot-Server-Patches/0394-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch
Prof-Bloodstone 42433c2626
Updated Upstream (Bukkit/CraftBukkit) (#3980)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
09f10fd9 SPIGOT-5950: Add PrepareSmithingEvent event

CraftBukkit Changes:
7c03d257 SPIGOT-6011: End Gateways do not work on Non-Main End Worlds
d492e363 SPIGOT-6015: Small Armor Stand doesn't drop items
5db13eea SPIGOT-5950: Add PrepareSmithingEvent event
2020-07-22 19:35:44 -04:00

35 lines
2 KiB
Diff

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/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 0515587559a75e4afddbcac90f65d5d60156a527..f71ca4ee57d86c30d78c8292ced0531b963beabb 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2037,6 +2037,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 092e49ae11ff735cf0179de8e0aaa73f7842e372..eb5231571884d1c828935b007d8fba3499bb68d2 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1478,6 +1478,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()) {