mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item
This commit is contained in:
parent
a4ea7eef0b
commit
b513a8369d
1 changed files with 16 additions and 0 deletions
|
@ -670,5 +670,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||||
public String getI18NDisplayName() {
|
public String getI18NDisplayName() {
|
||||||
return Bukkit.getServer().getItemFactory().getI18NDisplayName(this);
|
return Bukkit.getServer().getItemFactory().getI18NDisplayName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getMaxItemUseDuration(org.bukkit.entity.LivingEntity)}; crossbows, later possibly more items require an entity parameter
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
public int getMaxItemUseDuration() {
|
||||||
|
return getMaxItemUseDuration(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxItemUseDuration(@NotNull final org.bukkit.entity.LivingEntity entity) {
|
||||||
|
if (type == null || type == Material.AIR || !type.isItem()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Requires access to NMS
|
||||||
|
return ensureServerConversions().getMaxItemUseDuration(entity);
|
||||||
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue