--- a/net/minecraft/world/entity/npc/InventoryCarrier.java
+++ b/net/minecraft/world/entity/npc/InventoryCarrier.java
@@ -7,27 +7,38 @@
 import net.minecraft.world.item.ItemStack;
 
 public interface InventoryCarrier {
+
     String TAG_INVENTORY = "Inventory";
 
     SimpleContainer getInventory();
 
     static void pickUpItem(Mob entity, InventoryCarrier inventoryOwner, ItemEntity item) {
-        ItemStack itemStack = item.getItem();
-        if (entity.wantsToPickUp(itemStack)) {
-            SimpleContainer simpleContainer = inventoryOwner.getInventory();
-            boolean bl = simpleContainer.canAddItem(itemStack);
-            if (!bl) {
+        ItemStack itemstack = item.getItem();
+
+        if (entity.wantsToPickUp(itemstack)) {
+            SimpleContainer inventorysubcontainer = inventoryOwner.getInventory();
+            boolean flag = inventorysubcontainer.canAddItem(itemstack);
+
+            if (!flag) {
                 return;
             }
 
+            // CraftBukkit start
+            ItemStack remaining = new SimpleContainer(inventorysubcontainer).addItem(itemstack);
+            if (org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory.callEntityPickupItemEvent(entity, item, remaining.getCount(), false).isCancelled()) {
+                return;
+            }
+            // CraftBukkit end
+
             entity.onItemPickup(item);
-            int i = itemStack.getCount();
-            ItemStack itemStack2 = simpleContainer.addItem(itemStack);
-            entity.take(item, i - itemStack2.getCount());
-            if (itemStack2.isEmpty()) {
+            int i = itemstack.getCount();
+            ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
+
+            entity.take(item, i - itemstack1.getCount());
+            if (itemstack1.isEmpty()) {
                 item.discard();
             } else {
-                itemStack.setCount(itemStack2.getCount());
+                itemstack.setCount(itemstack1.getCount());
             }
         }
 
