PaperMC/patches/server/0507-Drop-carried-item-when-player-has-disconnected.patch
2024-06-14 14:07:44 -07:00

27 lines
1.4 KiB
Diff

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 6ef0e5c607c1b7ef9ba6a9f5c7bc452ce9a84250..7ef760cb1c88f557947e9b88409a2935666f86f0 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();