3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/Spigot-Server-Patches/0408-Fix-AssertionError-when-player-hand-set-to-empty-typ.patch
Spottedleaf bb4002d82e
Handle CraftPlayer#setSpectatorTarget better
Use a proper teleport for teleporting to entities in different
worlds.

Validate that the target entity is valid and deny spectate
requests from frozen players.

Also, make sure the entity is spawned to the client before
sending the camera packet. If the entity isn't spawned clientside
when it receives the camera packet, then the client will not
spectate the target entity.
2020-05-14 18:05:00 -05:00

36 Zeilen
1.9 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/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 24594aa0e9b8741811acfc9f84f4db7552832bd2..aada8d3b08b437f81f68f8e988412c1071287d54 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1891,6 +1891,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 6ba6fd6157985ae9d7bb048c2d42b268d08697bc..c2820d45b1b0b95dff5112105f33cf423fb858cb 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1438,6 +1438,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