Interface DamageableItem
- All Superinterfaces:
ItemAttribute
- All Known Implementing Classes:
ClimbingPick,ElytraCap,ExplosivePickaxe,ExplosiveShovel,ExplosiveTool,PickaxeOfTheSeeker,SeismicAxe,SmeltersPickaxe
This interface, when attached to a
SlimefunItem, provides an easy method for damaging
an ItemStack, see damageItem(Player, ItemStack).
It also provides a simple isDamageable() method, in case you wanna add a config
option that decides whether or not this SlimefunItem shall be damageable.- Author:
- TheBusyBiscuit, RobotHanzo
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voiddamageItem(Player p, ItemStack item) This method will damage the givenItemStackonce.default booleanevaluateUnbreakingEnchantment(int unbreakingLevel) This method will randomly decide if the item should be damaged or not This does not damage the item, it is called bydamageItem(Player, ItemStack)to randomly generate a boolean This function should be overridden when the item type is not a tool which is the default valuebooleanImplement this method to make the behaviour of this interface dependent on the state of your object.Methods inherited from interface io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute
getId
-
Method Details
-
isDamageable
boolean isDamageable()Implement this method to make the behaviour of this interface dependent on the state of your object. You could add aConfigoption to toggle the behaviour for example.- Returns:
- Whether this
SlimefunItemis damageable
-
damageItem
This method will damage the givenItemStackonce. It also takes into account theEnchantmentUnbreaking. It will only apply the damage ifisDamageable()returned true. -
evaluateUnbreakingEnchantment
default boolean evaluateUnbreakingEnchantment(int unbreakingLevel) This method will randomly decide if the item should be damaged or not This does not damage the item, it is called bydamageItem(Player, ItemStack)to randomly generate a boolean This function should be overridden when the item type is not a tool which is the default value- Parameters:
unbreakingLevel- TheIntegerlevel of the unbreakingEnchantment- Returns:
- Whether to save the item from taking damage
-