Paper/Spigot-Server-Patches/0571-Extend-block-drop-capture-to-capture-all-items-added.patch
Mariell Hoversholm 0f78e95250 More work
2021-03-18 18:03:22 +01:00

53 Zeilen
3.0 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/level/PlayerInteractManager.java b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
index 8b6367d3bb4cbb007bf68d957a6c1f701f5643b6..86d1a7625bb3016093ee8a46f91fd657d8bc2546 100644
--- a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
@@ -416,10 +416,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/level/WorldServer.java b/src/main/java/net/minecraft/server/level/WorldServer.java
index 7f5d3bcf8be30a6bcdd077bfbc416079e3d969c1..595194e0a0e746c45e3766433bb827b7b51129b5 100644
--- a/src/main/java/net/minecraft/server/level/WorldServer.java
+++ b/src/main/java/net/minecraft/server/level/WorldServer.java
@@ -99,6 +99,7 @@ import net.minecraft.world.entity.animal.EntityWaterAnimal;
import net.minecraft.world.entity.animal.horse.EntityHorseSkeleton;
import net.minecraft.world.entity.boss.EntityComplexPart;
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
+import net.minecraft.world.entity.item.EntityItem;
import net.minecraft.world.entity.npc.NPC;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.entity.raid.PersistentRaid;
@@ -1289,6 +1290,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;
}