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 72b9c50024e82356491a3d35bf248223f3088b5c..5c63a7719b2a4a4bb2c64d460b007d2976cbdbf9 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -597,6 +597,14 @@ public abstract class PlayerList { } // Paper end + // Paper - Drop carried item when player has disconnected + if (!entityplayer.containerMenu.getCarried().isEmpty()) { + net.minecraft.world.item.ItemStack carried = entityplayer.containerMenu.getCarried(); + entityplayer.containerMenu.setCarried(net.minecraft.world.item.ItemStack.EMPTY); + entityplayer.drop(carried, false); + } + // Paper end - Drop carried item when player has disconnected + this.save(entityplayer); if (entityplayer.isPassenger()) { Entity entity = entityplayer.getRootVehicle();