2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-12-08 01:03:10 +00:00
|
|
|
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
|
2020-05-06 09:48:49 +00:00
|
|
|
index 24594aa0e9b8741811acfc9f84f4db7552832bd2..aada8d3b08b437f81f68f8e988412c1071287d54 100644
|
2019-12-08 01:03:10 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-04-27 07:34:45 +00:00
|
|
|
@@ -1891,6 +1891,7 @@ public abstract class EntityLiving extends Entity {
|
2019-12-08 01:03:10 +00:00
|
|
|
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
|
2020-05-06 09:48:49 +00:00
|
|
|
index f00653dfe7a769992069582f1743b477edb47eb9..71d045ee00d1f172d88f076d15cf82bae2527ae8 100644
|
2019-12-08 01:03:10 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
2020-02-09 00:32:48 +00:00
|
|
|
@@ -1430,6 +1430,10 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2019-12-08 01:03:10 +00:00
|
|
|
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
|