aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/unapplied/server/0131-Item-canEntityPickup.patch
blob: d68202e1be15d7514696c16e5f18e4a19f444dba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 5 May 2017 03:57:17 -0500
Subject: [PATCH] Item#canEntityPickup


diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 03d289abc30927793aa00f6758ed9db6fb765999..51381c32c8650400331a122a4b6c8d95c9d0632b 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -672,6 +672,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
                     ItemEntity entityitem = (ItemEntity) iterator.next();
 
                     if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(worldserver, entityitem.getItem())) {
+                        // Paper start - Item#canEntityPickup
+                        if (!entityitem.canMobPickup) {
+                            continue;
+                        }
+                        // Paper end - Item#canEntityPickup
                         this.pickUpItem(worldserver, entityitem);
                     }
                 }
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index c1859488af5a3a5c7a5a70e6789b40ee44e1d01e..95d43e451f3343a9a9488b23695908235b55d6c5 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -60,6 +60,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
     public UUID target;
     public final float bobOffs;
     private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
+    public boolean canMobPickup = true; // Paper - Item#canEntityPickup
 
     public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
         super(type, world);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
index fb3738f4c558796f41e3327dd41b8aec68007a8a..5620a0849fda49313c68edfd747fedd09641a3d5 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -63,6 +63,18 @@ public class CraftItem extends CraftEntity implements Item {
         }
     }
 
+    // Paper start
+    @Override
+    public boolean canMobPickup() {
+        return this.getHandle().canMobPickup;
+    }
+
+    @Override
+    public void setCanMobPickup(boolean canMobPickup) {
+        this.getHandle().canMobPickup = canMobPickup;
+    }
+    // Paper end
+
     @Override
     public void setOwner(UUID uuid) {
         this.getHandle().setTarget(uuid);