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
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-03-16 13:04:28 +00:00
|
|
|
index bae1fb41b1559373f73d4ed3ba145d81a71cabeb..28106cc6acbdcd026c646c030491d74049306861 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
@@ -1705,6 +1705,10 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2019-12-08 01:03:10 +00:00
|
|
|
this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
|
2020-06-25 23:38:24 +00:00
|
|
|
return;
|
2019-12-08 01:03:10 +00:00
|
|
|
}
|
2020-06-25 23:38:24 +00: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()) {
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
2021-03-16 13:04:28 +00:00
|
|
|
index 903c3cfdaae3dd1750aa2f32f6cdbb423909eb47..58cf4bb4c6267c4d8d71bbd29ed34575eb93aed3 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -2156,6 +2156,7 @@ public abstract class EntityLiving extends Entity {
|
2021-03-16 07:19:45 +00:00
|
|
|
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);
|