Interface DamageableItem

All Superinterfaces:
ItemAttribute
All Known Implementing Classes:
ClimbingPick, ElytraCap, ExplosivePickaxe, ExplosiveShovel, ExplosiveTool, PickaxeOfTheSeeker, SeismicAxe, SmeltersPickaxe

public interface DamageableItem extends ItemAttribute
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 Type
    Method
    Description
    default void
    This method will damage the given ItemStack 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 by damageItem(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
    boolean
    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 a Config option to toggle the behaviour for example.
      Returns:
      Whether this SlimefunItem is damageable
    • damageItem

      default void damageItem(@Nonnull Player p, @Nullable ItemStack item)
      This method will damage the given ItemStack once. It also takes into account the Enchantment Unbreaking. It will only apply the damage if isDamageable() returned true.
      Parameters:
      p - The Player to which the item belongs
      item - The ItemStack to damage
    • 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 by damageItem(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 - The Integer level of the unbreaking Enchantment
      Returns:
      Whether to save the item from taking damage