Paper/Spigot-Server-Patches/0412-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch
Zach Brown f09fed894f
Update upstream B/CB
--- work/Bukkit
Submodule work/Bukkit 6a4242cb..337955e3:
  > SPIGOT-5468: Improve Beehive TileEntity API
  > #473: Add an API for passing the heightmap to getHighestBlockAt* method

--- work/CraftBukkit
Submodule work/CraftBukkit 807a677e..708be695:
  > SPIGOT-5468: Improve Beehive TileEntity API
  > #624: Add an API for passing the heightmap to getHighestBlockAt* method
  > MC-135989, SPIGOT-5564: Don't kick players for flight while riptiding

This deprecates the Paper getHighestBlockAt HeightMap APIs now that
Bukkit has added their own. These methods will stick around long enough
for people to migrate. Their API is pretty much the same as ours,
migration should be quick and easy.
2020-02-08 18:32:48 -06:00

39 lines
1.8 KiB
Diff

From eba334b27e400e43ad5a9d2f56be5d0374558907 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 b098cd6d7..6184cced7 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1888,6 +1888,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 f88bcb29d..108377d76 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1430,6 +1430,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.25.0