Item no age & no player pickup
This commit is contained in:
parent
1b3c20f94f
commit
068313fa2e
45
Spigot-API-Patches/0232-Item-no-age-no-player-pickup.patch
Normal file
45
Spigot-API-Patches/0232-Item-no-age-no-player-pickup.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alfie Smith <alfie@alfiesmith.net>
|
||||
Date: Sat, 7 Nov 2020 01:20:27 +0000
|
||||
Subject: [PATCH] Item no age & no player pickup
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Item.java b/src/main/java/org/bukkit/entity/Item.java
|
||||
index c404a5b8efea7c780db5ddae19456753808abb3d..5acbe1504fcdb93540acde0dcb00a9a6362dfc1e 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Item.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Item.java
|
||||
@@ -90,5 +90,34 @@ public interface Item extends Entity {
|
||||
* @param canMobPickup True to allow non-player entity pickup
|
||||
*/
|
||||
public void setCanMobPickup(boolean canMobPickup);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether the player can pickup the item or not
|
||||
+ *
|
||||
+ * @return True if a player can pickup the item
|
||||
+ */
|
||||
+ public boolean canPlayerPickup();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether the item can be picked up or not. Modifies the pickup delay value to do so.
|
||||
+ *
|
||||
+ * @param canPlayerPickup True if the player can pickup the item
|
||||
+ */
|
||||
+ public void setCanPlayerPickup(boolean canPlayerPickup);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether the item will age and despawn from being on the ground too long
|
||||
+ *
|
||||
+ * @return True if the item will age
|
||||
+ */
|
||||
+ public boolean willAge();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether the item will age or not. If the item is not ageing, it will not despawn
|
||||
+ * by being on the ground for too long.
|
||||
+ *
|
||||
+ * @param willAge True if the item should age
|
||||
+ */
|
||||
+ public void setWillAge(boolean willAge);
|
||||
// Paper end
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alfie Smith <alfie@alfiesmith.net>
|
||||
Date: Sat, 7 Nov 2020 01:20:33 +0000
|
||||
Subject: [PATCH] Item no age & no player pickup
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
index d6a64e4ecf9225f9a93523c50b2f1375296b406e..bcbaad11852a51436a00c8e172bdd841ba93ec3c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
@@ -10,6 +10,12 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftItem extends CraftEntity implements Item {
|
||||
+
|
||||
+ // Paper start
|
||||
+ private final static int NO_AGE_TIME = (int) Short.MIN_VALUE;
|
||||
+ private final static int NO_PICKUP_TIME = (int) Short.MAX_VALUE;
|
||||
+ // Paper end
|
||||
+
|
||||
private final EntityItem item;
|
||||
|
||||
public CraftItem(CraftServer server, Entity entity, EntityItem item) {
|
||||
@@ -57,6 +63,26 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
public void setCanMobPickup(boolean canMobPickup) {
|
||||
item.canMobPickup = canMobPickup;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canPlayerPickup() {
|
||||
+ return item.pickupDelay != NO_PICKUP_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCanPlayerPickup(boolean canPlayerPickup) {
|
||||
+ item.pickupDelay = canPlayerPickup ? 0 : NO_PICKUP_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean willAge() {
|
||||
+ return item.age != NO_AGE_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWillAge(boolean willAge) {
|
||||
+ item.age = willAge ? 0 : NO_AGE_TIME;
|
||||
+ }
|
||||
// Paper End
|
||||
|
||||
@Override
|
Loading…
Reference in a new issue