From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shane Freeder 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/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 15a0bbc4e3bafb754b3de03f63b19ab848fe6635..720568b34c903c80d916a5915c9733c4ed565dcf 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1275,6 +1275,12 @@ public class ServerLevel extends Level implements WorldGenLevel { // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getKey(entity.getType())); // CraftBukkit return false; } else { + // Paper start - capture all item additions to the world + if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) { + captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity); + return true; + } + // Paper end // SPIGOT-6415: Don't call spawn event when reason is null. For example when an entity teleports to a new world. if (spawnReason != null && !CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) { return false; diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java index 3622708c453feb6da3d5be192291d63abbe83068..89f0c3d6e4dc9701f02fa7ed5331c3969de81ffc 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -434,10 +434,12 @@ public class ServerPlayerGameMode { // return true; // CraftBukkit } // CraftBukkit start + java.util.List itemsToDrop = level.captureDrops; // Paper - store current list + level.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, level.captureDrops); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - use stored ref } - level.captureDrops = null; + //world.captureDrops = null; // Paper - move up // Drop event experience if (flag && event != null) {