mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 19:00:16 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
36 lines
2.2 KiB
Diff
36 lines
2.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/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index e45690b6197335ed1c07fa04c39b311b401724d7..2b79413bb8a592a7b7093e11d3a0cce895286c8f 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1706,6 +1706,10 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
|
|
this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
|
return;
|
|
}
|
|
+ // Paper start
|
|
+ itemstack = this.player.getItemInHand(enumhand);
|
|
+ if (itemstack.isEmpty()) return;
|
|
+ // Paper end
|
|
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
|
|
|
if (enuminteractionresult.shouldSwing()) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index f8917123547615dd624e3e428ec1bf6450c7b7d8..b49d4772932a58852b3195f5f56ff93dbcabf766 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -2153,6 +2153,7 @@ public abstract class LivingEntity extends Entity {
|
|
return predicate.test(this.getMainHandItem().getItem()) || predicate.test(this.getOffhandItem().getItem());
|
|
}
|
|
|
|
+ public final ItemStack getItemInHand(InteractionHand enumhand) { return this.getItemInHand(enumhand); } // Paper - OBFHELPER
|
|
public ItemStack getItemInHand(InteractionHand hand) {
|
|
if (hand == InteractionHand.MAIN_HAND) {
|
|
return this.getItemBySlot(EquipmentSlot.MAINHAND);
|