summaryrefslogtreecommitdiffhomepage
path: root/patches/server/0502-Drop-carried-item-when-player-has-disconnected.patch
blob: ababb3984cb627d62e9947ac13ad66d7624e8e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dmitry Sidorov <jonmagon@gmail.com>
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 123fe4f5b98a7483af86695ec82987abd45eafb2..bbc6f64a3b2c0702a0a752acd48145cdcafd742e 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -588,6 +588,14 @@ public abstract class PlayerList {
         }
         // Paper end - Configurable player collision
 
+        // 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();