Paper/Spigot-Server-Patches/0149-Item-canEntityPickup.patch
2020-06-25 06:11:48 -07:00

56 lines
2.5 KiB
Diff

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/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index f2cd6824790d7e76f8f10e2630bcd5ebbf2a4238..3997dc6d979bf5a027861397b948aa4e8486fc58 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -539,6 +539,11 @@ public abstract class EntityInsentient extends EntityLiving {
EntityItem entityitem = (EntityItem) iterator.next();
if (!entityitem.dead && !entityitem.getItemStack().isEmpty() && !entityitem.p() && this.i(entityitem.getItemStack())) {
+ // Paper Start
+ if (!entityitem.canMobPickup) {
+ continue;
+ }
+ // Paper End
this.b(entityitem);
}
}
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index ca1cc67fea6f1607a2d3d7869a0a023616c02ff7..159552192c2a6d62fb205ed5973f89a16e619d94 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -20,6 +20,7 @@ public class EntityItem extends Entity {
private UUID owner;
public final float b;
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
+ public boolean canMobPickup = true; // Paper
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
super(entitytypes, world);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
index cc593fbc995dfc11f8006588059d67c42a7429cd..3f552b5905e5ed51c887ad02410297dd5e2e165f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -48,6 +48,16 @@ public class CraftItem extends CraftEntity implements Item {
item.age = value;
}
+ // Paper Start
+ public boolean canMobPickup() {
+ return item.canMobPickup;
+ }
+
+ public void setCanMobPickup(boolean canMobPickup) {
+ item.canMobPickup = canMobPickup;
+ }
+ // Paper End
+
@Override
public String toString() {
return "CraftItem";