mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-31 03:50:36 +01:00
Call EntityDropItemEvent when a container item drops its contents (#11441)
This commit is contained in:
parent
4ffc9d9c0c
commit
fb91090522
1 changed files with 21 additions and 0 deletions
|
@ -86,3 +86,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemUtils.java b/src/main/java/net/minecraft/world/item/ItemUtils.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemUtils.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemUtils.java
|
||||
@@ -0,0 +0,0 @@ public class ItemUtils {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue