Interface Rechargeable

All Superinterfaces:
ItemAttribute
All Known Implementing Classes:
JetBoots, Jetpack, MultiTool, PortableTeleporter

public interface Rechargeable extends ItemAttribute
A Rechargeable SlimefunItem can hold energy and is able to be recharged using a ChargingBench. Any SlimefunItem which is supposed to be chargeable must implement this interface.
Author:
TheBusyBiscuit
See Also:
  • Method Details

    • getMaxItemCharge

      float getMaxItemCharge(ItemStack item)
      This method returns the maximum charge the given ItemStack is capable of holding.
      Parameters:
      item - The ItemStack for which to determine the maximum charge
      Returns:
      The maximum energy charge for this ItemStack
    • setItemCharge

      default void setItemCharge(ItemStack item, float charge)
      This method sets the stored energy charge for a given ItemStack. The charge must be at least zero and at most getMaxItemCharge(ItemStack).
      Parameters:
      item - The ItemStack to charge
      charge - The amount of charge to store
    • getItemCharge

      default float getItemCharge(ItemStack item)
      This method returns the currently stored energy charge on the provided ItemStack.
      Parameters:
      item - The ItemStack to get the charge from
      Returns:
      The charge stored on this ItemStack
    • addItemCharge

      default boolean addItemCharge(ItemStack item, float charge)
      This method adds the given charge to the provided ItemStack. The method will also return whether this operation was successful. If the ItemStack is already at maximum charge, the method will return false.
      Parameters:
      item - The ItemStack to charge
      charge - The amount of charge to add
      Returns:
      Whether the given charge could be added successfully
    • removeItemCharge

      default boolean removeItemCharge(ItemStack item, float charge)
      This method removes the given charge to the provided ItemStack. The method will also return whether this operation was successful. If the ItemStack does not have enough charge, the method will return false.
      Parameters:
      item - The ItemStack to remove the charge from
      charge - The amount of charge to remove
      Returns:
      Whether the given charge could be removed successfully