#1011: Add Item Unlimited Lifetime APIs

By: Gero <gecam59@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2022-03-12 09:26:16 +11:00
parent 06bac38719
commit a429b2ad16

View File

@ -41,12 +41,29 @@ public class CraftItem extends CraftEntity implements Item {
item.pickupDelay = Math.min(delay, Short.MAX_VALUE);
}
@Override
public void setUnlimitedLifetime(boolean unlimited) {
if (unlimited) {
// See EntityItem#INFINITE_LIFETIME
item.age = Short.MIN_VALUE;
} else {
item.age = getTicksLived();
}
}
@Override
public boolean isUnlimitedLifetime() {
return item.age == Short.MIN_VALUE;
}
@Override
public void setTicksLived(int value) {
super.setTicksLived(value);
// Second field for EntityItem
item.age = value;
// Second field for EntityItem (don't set if lifetime is unlimited)
if (!isUnlimitedLifetime()) {
item.age = value;
}
}
@Override