Paper/Spigot-Server-Patches/0385-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch

36 lines
2.0 KiB
Diff
Raw Normal View History

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 4567b0fe175765748bb787049e10fbe0af0a61d9..11a1fad5450ec94aeb4b135d7efc72718297c9cd 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2062,6 +2062,7 @@ public abstract class EntityLiving extends Entity {
2020-06-26 01:38:24 +02:00
return predicate.test(this.getItemInMainHand().getItem()) || predicate.test(this.getItemInOffHand().getItem());
}
2020-06-26 01:38:24 +02:00
+ 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
2021-02-22 19:24:44 +01:00
index 5be06182f2987f16c96c3b54fa7314f403ca69bd..60046183e610f406020c9835c295e2732812b37b 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2021-02-22 19:24:44 +01:00
@@ -1561,6 +1561,10 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
2020-06-26 01:38:24 +02:00
return;
}
2020-06-26 01:38:24 +02:00
+ // 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()) {