Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/patches/server-unmapped/0694-Drop-carried-item-when-player-has-disconnected.patch
2021-06-11 14:02:28 +02:00

36 Zeilen
1.7 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 484c7cea458dda38e4816fe5f1c05c6836fa38b9..b257d58a298e82f255b09e9575ee42a56a4b7cee 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();