aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches-Unmapped/0595-Item-no-age-no-player-pickup.patch
blob: 84124da98a54761f1bf7dfbe8d3e19671353473f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 5988cdd18b7e4bfca0075fd2356cfe9c4e673954..7a78ef2f6f673568c0528fa46168c69d21f51a66 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