Paper/patches/unapplied/server/0141-Item-canEntityPickup.patch

58 Zeilen
2.7 KiB
Diff

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 2de1ad28d42d4beec69901bf985ac0be582f00b9..655dfa9113ca82dc56bc8f4b083ea049ee5b4bee 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
@@ -671,6 +671,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())) {
+ // Paper start - Item#canEntityPickup
2021-06-11 14:02:28 +02:00
+ if (!entityitem.canMobPickup) {
+ continue;
+ }
+ // Paper end - Item#canEntityPickup
2021-06-11 14:02:28 +02:00
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
index 270ae75863ff6e97e80641e94ce2ade07f683c5a..d1bd8b5e5b0873a526ae449986593867b10eec12 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
@@ -55,6 +55,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
2023-03-14 19:36:39 +01:00
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 - Item#canEntityPickup
2021-06-11 14:02:28 +02:00
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
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
@@ -63,6 +63,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 this.getHandle().canMobPickup;
2021-06-11 14:02:28 +02:00
+ }
+
2021-06-12 12:26:21 +02:00
+ @Override
2021-06-11 14:02:28 +02:00
+ public void setCanMobPickup(boolean canMobPickup) {
+ this.getHandle().canMobPickup = canMobPickup;
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
2021-06-11 14:02:28 +02:00
+
@Override
public void setOwner(UUID uuid) {
this.getHandle().setTarget(uuid);