Interface Rechargeable
- All Superinterfaces:
ItemAttribute
- All Known Implementing Classes:
JetBoots
,Jetpack
,MultiTool
,PortableTeleporter
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 Summary
Modifier and TypeMethodDescriptiondefault boolean
addItemCharge
(ItemStack item, float charge) This method adds the given charge to the providedItemStack
.default float
getItemCharge
(ItemStack item) This method returns the currently stored energy charge on the providedItemStack
.float
getMaxItemCharge
(ItemStack item) This method returns the maximum charge the givenItemStack
is capable of holding.default boolean
removeItemCharge
(ItemStack item, float charge) This method removes the given charge to the providedItemStack
.default void
setItemCharge
(ItemStack item, float charge) This method sets the stored energy charge for a givenItemStack
.Methods inherited from interface io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute
getId
-
Method Details
-
getMaxItemCharge
This method returns the maximum charge the givenItemStack
is capable of holding. -
setItemCharge
This method sets the stored energy charge for a givenItemStack
. The charge must be at least zero and at mostgetMaxItemCharge(ItemStack)
.- Parameters:
item
- TheItemStack
to chargecharge
- The amount of charge to store
-
getItemCharge
This method returns the currently stored energy charge on the providedItemStack
. -
addItemCharge
This method adds the given charge to the providedItemStack
. The method will also return whether this operation was successful. If theItemStack
is already at maximum charge, the method will returnfalse
.- Parameters:
item
- TheItemStack
to chargecharge
- The amount of charge to add- Returns:
- Whether the given charge could be added successfully
-
removeItemCharge
This method removes the given charge to the providedItemStack
. The method will also return whether this operation was successful. If theItemStack
does not have enough charge, the method will returnfalse
.- Parameters:
item
- TheItemStack
to remove the charge fromcharge
- The amount of charge to remove- Returns:
- Whether the given charge could be removed successfully
-