testserver/patches/server/0139-Item-canEntityPickup.p...

58 lines
2.6 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00: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
2021-06-12 10:26:21 +00:00
index b13774873f795b149c15fddb8053d9419f1841ca..2ed756c73b0cfddb559126d85316f37c3f958c0c 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
2021-06-12 10:26:21 +00:00
@@ -614,6 +614,11 @@ public abstract class Mob extends LivingEntity {
2021-06-11 12:02:28 +00:00
ItemEntity entityitem = (ItemEntity) iterator.next();
2021-06-12 10:26:21 +00:00
if (!entityitem.isRemoved() && !entityitem.getItem().isEmpty() && !entityitem.hasPickUpDelay() && this.wantsToPickUp(entityitem.getItem())) {
2021-06-11 12:02:28 +00: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
2021-06-12 10:26:21 +00:00
index bf6daeefef5a60ebc612c0347eb34d581fb8851a..9611388a6aeebb86b19d89c526f53dfed4d3ed27 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
2021-06-12 10:26:21 +00:00
@@ -51,6 +51,7 @@ public class ItemEntity extends Entity {
2021-06-11 12:02:28 +00:00
private UUID owner;
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
2021-06-12 10:26:21 +00:00
index b9044654d22a47cfa952dcf25754ad0d87fc0844..0d262c99c7e9ef06e297612b1802c493700f64ae 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
2021-06-12 10:26:21 +00:00
@@ -49,6 +49,18 @@ public class CraftItem extends CraftEntity implements Item {
2021-06-11 12:02:28 +00:00
item.age = value;
}
+ // Paper Start
2021-06-12 10:26:21 +00:00
+ @Override
2021-06-11 12:02:28 +00:00
+ public boolean canMobPickup() {
+ return item.canMobPickup;
+ }
+
2021-06-12 10:26:21 +00:00
+ @Override
2021-06-11 12:02:28 +00:00
+ public void setCanMobPickup(boolean canMobPickup) {
+ item.canMobPickup = canMobPickup;
+ }
+ // Paper End
+
@Override
public void setOwner(UUID uuid) {
2021-06-12 10:26:21 +00:00
this.item.setOwner(uuid);