Paper/Spigot-Server-Patches/0577-Extend-block-drop-capture-to-capture-all-items-added.patch
Mariell faf8eb035a
Updated Upstream (CraftBukkit) (#4622)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
1f4693a8 SPIGOT-6168: Fix error with Player.getBedSpawnLocation when world is unloaded while server running
2020-10-06 09:59:35 -04:00

45 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Thu, 17 Sep 2020 00:36:05 +0100
Subject: [PATCH] Extend block drop capture to capture all items added to the
world
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index 300fad4b4a2950e7e613f0ef97ac9e8740c09243..ac3bee9dfb29f8bfa1b8948e234cc8948dd38c24 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -385,10 +385,12 @@ public class PlayerInteractManager {
// return true; // CraftBukkit
}
// CraftBukkit start
+ java.util.List<EntityItem> itemsToDrop = world.captureDrops; // Paper - store current list
+ world.captureDrops = null; // Paper - Remove this earlier so that we can actually drop stuff
if (event.isDropItems()) {
- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref
}
- world.captureDrops = null;
+ //world.captureDrops = null; // Paper - move up
// Drop event experience
if (flag && event != null) {
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 25cdd7b0f71fcba1070a7ec4c8e3546c19073ad7..95da2a56028e448c3a41115501f25a20382961f7 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1172,6 +1172,13 @@ public class WorldServer extends World implements GeneratorAccessSeed {
} else if (this.isUUIDTaken(entity)) {
return false;
} else {
+ // Paper start - capture all item additions to the world
+ if (captureDrops != null && entity instanceof EntityItem) {
+ captureDrops.add((EntityItem) entity);
+ return true;
+ }
+ // Paper end
+
if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
return false;
}