mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
cc6fd371b2
Fixes #6357 Closes #6508 Closes #6358
52 lines
3 KiB
Diff
52 lines
3 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/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 1b13c67441c46208a9b2adde5ca109f90bbb92e2..3563690e404a68b8940d9c06a0198dd0a4b2d220 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1252,6 +1252,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
// WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // 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
|
|
+
|
|
if (!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 784e6c2db5bb346408948cff8ac3cc9b964dd6d8..0b274a5b9e0bf68769637f10e43dbff6d909512b 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
|
@@ -7,6 +7,7 @@ import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.InteractionResultHolder;
|
|
import net.minecraft.world.MenuProvider;
|
|
import net.minecraft.world.entity.EquipmentSlot;
|
|
+import net.minecraft.world.entity.item.ItemEntity;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.item.DoubleHighBlockItem;
|
|
import net.minecraft.world.item.ItemStack;
|
|
@@ -424,10 +425,12 @@ public class ServerPlayerGameMode {
|
|
// return true; // CraftBukkit
|
|
}
|
|
// CraftBukkit start
|
|
+ java.util.List<ItemEntity> 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) {
|