mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item
This commit is contained in:
parent
b64e7f96d3
commit
0efee74644
1 changed files with 15 additions and 0 deletions
|
@ -225,6 +225,21 @@ public final class CraftItemStack extends ItemStack {
|
|||
return (this.handle == null) ? Material.AIR.getMaxStackSize() : this.handle.getMaxStackSize();
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public int getMaxItemUseDuration(final org.bukkit.entity.LivingEntity entity) {
|
||||
if (handle == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure plugins calling the old method don't blow up
|
||||
if (entity == null && (handle.is(net.minecraft.world.item.Items.CROSSBOW) || handle.is(net.minecraft.world.item.Items.GOAT_HORN))) {
|
||||
throw new UnsupportedOperationException("This item requires an entity to determine the max use duration");
|
||||
}
|
||||
return handle.getUseDuration(entity != null ? ((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity).getHandle() : null);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public void addUnsafeEnchantment(Enchantment ench, int level) {
|
||||
Preconditions.checkArgument(ench != null, "Enchantment cannot be null");
|
||||
|
|
Loading…
Reference in a new issue