mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 21:44:40 +01:00
d219fd642f
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 6bff9d09 #508: Add PlayerBucketFishEvent CraftBukkit Changes: a8d7c94a5 SPIGOT-6434: Smithing Table and Anvil inventories .getType() returns CRAFTING c5494d195 #683: Add PlayerBucketFishEvent
44 lines
1.9 KiB
Diff
44 lines
1.9 KiB
Diff
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
|
|
index 1c018288927fc142ed094a911d710b13a4a30919..ac89b7f0de0e5015c599648dc93cbcae760744f2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -397,13 +397,30 @@ public class CraftEventFactory {
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|