From 1a2fd12a5f15761dee2f3add4488ca120e6ee336 Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Fri, 26 Mar 2021 07:21:24 +0300 Subject: [PATCH] Drop carried item when player has disconnected (#5036) (#5166) --- ...ed-item-when-player-has-disconnected.patch | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Spigot-Server-Patches/0697-Drop-carried-item-when-player-has-disconnected.patch diff --git a/Spigot-Server-Patches/0697-Drop-carried-item-when-player-has-disconnected.patch b/Spigot-Server-Patches/0697-Drop-carried-item-when-player-has-disconnected.patch new file mode 100644 index 0000000000..035581c26d --- /dev/null +++ b/Spigot-Server-Patches/0697-Drop-carried-item-when-player-has-disconnected.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Dmitry Sidorov +Date: Thu, 4 Feb 2021 20:32:01 +0300 +Subject: [PATCH] Drop carried item when player has disconnected + +Fixes disappearance of held items, when a player gets disconnected and PlayerDropItemEvent is cancelled. +Closes #5036 + +diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java +index 92ed4938d5fe6b76e3a9ac5491d6e9c004ade843..2df8e914f66176e22aeddf8b94a83af5ea921d88 100644 +--- a/src/main/java/net/minecraft/server/players/PlayerList.java ++++ b/src/main/java/net/minecraft/server/players/PlayerList.java +@@ -79,6 +79,7 @@ import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityTypes; + import net.minecraft.world.entity.npc.EntityVillagerAbstract; + import net.minecraft.world.entity.player.EntityHuman; ++import net.minecraft.world.item.ItemStack; + import net.minecraft.world.level.ChunkCoordIntPair; + import net.minecraft.world.level.EnumGamemode; + import net.minecraft.world.level.GameRules; +@@ -609,6 +610,14 @@ public abstract class PlayerList { + } + // Paper end + ++ // Paper - Drop carried item when player has disconnected ++ if (!entityplayer.inventory.getCarried().isEmpty()) { ++ ItemStack carried = entityplayer.inventory.getCarried(); ++ entityplayer.inventory.setCarried(ItemStack.NULL_ITEM); ++ entityplayer.drop(carried, false); ++ } ++ // Paper end ++ + this.savePlayerFile(entityplayer); + if (entityplayer.isPassenger()) { + Entity entity = entityplayer.getRootVehicle();