2021-01-30 16:09:13 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: BillyGalbreath <blake.galbreath@gmail.com>
|
|
|
|
Date: Wed, 20 Jan 2021 14:23:37 -0600
|
|
|
|
Subject: [PATCH] Allow adding items to BlockDropItemEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2021-03-16 07:19:45 +00:00
|
|
|
index c0a66ca6c8f32cbd04cebfbb0e6f2ea668295cf0..9687d864311d6fb98c5c5b535073e0bc0601112a 100644
|
2021-01-30 16:09:13 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -380,13 +380,30 @@ public class CraftEventFactory {
|
2021-01-30 16:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void handleBlockDropItemEvent(Block block, BlockState state, EntityPlayer player, List<EntityItem> items) {
|
|
|
|
- BlockDropItemEvent event = new BlockDropItemEvent(block, state, player.getBukkitEntity(), Lists.transform(items, (item) -> (org.bukkit.entity.Item) item.getBukkitEntity()));
|
|
|
|
+ // Paper start
|
|
|
|
+ List<Item> list = new ArrayList<>();
|
|
|
|
+ for (EntityItem item : items) {
|
|
|
|
+ list.add((Item) item.getBukkitEntity());
|
|
|
|
+ }
|
|
|
|
+ BlockDropItemEvent event = new BlockDropItemEvent(block, state, player.getBukkitEntity(), list);
|
|
|
|
+ // Paper end
|
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
|
|
|
- for (EntityItem item : items) {
|
|
|
|
- item.world.addEntity(item);
|
|
|
|
+ // Paper start
|
|
|
|
+ for (Item bukkit : list) {
|
|
|
|
+ if (!bukkit.isValid()) {
|
|
|
|
+ Entity item = ((org.bukkit.craftbukkit.entity.CraftItem) bukkit).getHandle();
|
|
|
|
+ item.world.addEntity(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (Item bukkit : list) {
|
|
|
|
+ if (bukkit.isValid()) {
|
|
|
|
+ bukkit.remove();
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|