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 void
damageItem
(Player p, ItemStack item) This method will damage the givenItemStack
once.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 valueboolean
Implement 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 aConfig
option to toggle the behaviour for example.- Returns:
- Whether this
SlimefunItem
is damageable
-
damageItem
This method will damage the givenItemStack
once. It also takes into account theEnchantment
Unbreaking
. 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
- TheInteger
level of the unbreakingEnchantment
- Returns:
- Whether to save the item from taking damage
-