0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-25 13:56:14 +00:00
craftbukkit/nms-patches/net/minecraft/world/entity/npc/InventoryCarrier.patch
2024-10-23 02:15:00 +11:00

36 lines
1.4 KiB
Diff

--- a/net/minecraft/world/entity/npc/InventoryCarrier.java
+++ b/net/minecraft/world/entity/npc/InventoryCarrier.java
@@ -8,6 +8,10 @@
import net.minecraft.world.entity.item.EntityItem;
import net.minecraft.world.item.ItemStack;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public interface InventoryCarrier {
String TAG_INVENTORY = "Inventory";
@@ -25,13 +29,20 @@
return;
}
+ // CraftBukkit start
+ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).addItem(itemstack);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entityinsentient, entityitem, remaining.getCount(), false).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
entityinsentient.onItemPickup(entityitem);
int i = itemstack.getCount();
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
entityinsentient.take(entityitem, i - itemstack1.getCount());
if (itemstack1.isEmpty()) {
- entityitem.discard();
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
} else {
itemstack.setCount(itemstack1.getCount());
}