PaperMC/paper-server/patches/sources/net/minecraft/world/item/ItemUtils.java.patch
2021-07-20 21:35:47 -07:00

19 lines
1.1 KiB
Diff

--- a/net/minecraft/world/item/ItemUtils.java
+++ b/net/minecraft/world/item/ItemUtils.java
@@ -41,7 +41,15 @@
public static void onContainerDestroyed(ItemEntity itemEntity, Iterable<ItemStack> contents) {
Level level = itemEntity.level();
if (!level.isClientSide) {
- contents.forEach(stack -> level.addFreshEntity(new ItemEntity(level, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), stack)));
+ // Paper start - call EntityDropItemEvent
+ contents.forEach(stack -> {
+ ItemEntity droppedItem = new ItemEntity(level, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), stack);
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(itemEntity.getBukkitEntity(), (org.bukkit.entity.Item) droppedItem.getBukkitEntity());
+ if (event.callEvent()) {
+ level.addFreshEntity(droppedItem);
+ }
+ });
+ // Paper end - call EntityDropItemEvent
}
}
}