Paper/patches/server/0136-Item-canEntityPickup.patch

58 lines
2.6 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
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 3500fd0045ad670de818dc170d9c68da643592e0..1f050f1c133e116e861e4e5f7e59875387543659 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
2023-06-07 21:19:26 +02:00
@@ -668,6 +668,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
2021-06-11 14:02:28 +02:00
ItemEntity entityitem = (ItemEntity) iterator.next();
2021-06-12 12:26:21 +02:00
if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(entityitem.getItem())) {
2021-06-11 14:02:28 +02:00
+ // Paper Start
+ if (!entityitem.canMobPickup) {
+ continue;
+ }
+ // Paper End
this.pickUpItem(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
2023-06-07 21:19:26 +02:00
index dbe07ffbc6310828370be69081ac6d6f3085e4ac..1503d143429f0b73935004a7061d0409dcb24c2c 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
2023-03-14 19:36:39 +01:00
@@ -51,6 +51,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
public UUID target;
2021-06-11 14:02:28 +02:00
public final float bobOffs;
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
+ public boolean canMobPickup = true; // Paper
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
2023-03-14 19:36:39 +01:00
index d08869c92f15a63f857d88e506f744f5ff9eb15e..5f36b0fd12ccd0e7ec9a7f61c56f08307844935f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
@@ -66,6 +66,18 @@ public class CraftItem extends CraftEntity implements Item {
}
2021-06-11 14:02:28 +02:00
}
+ // Paper Start
2021-06-12 12:26:21 +02:00
+ @Override
2021-06-11 14:02:28 +02:00
+ public boolean canMobPickup() {
+ return item.canMobPickup;
+ }
+
2021-06-12 12:26:21 +02:00
+ @Override
2021-06-11 14:02:28 +02:00
+ public void setCanMobPickup(boolean canMobPickup) {
+ item.canMobPickup = canMobPickup;
+ }
+ // Paper End
+
@Override
public void setOwner(UUID uuid) {
2023-03-14 19:36:39 +01:00
this.item.setTarget(uuid);