Package dev.jaxydog.astral.utility
Interface CurrencyHelper
@NonExtendable
public interface CurrencyHelper
Provides types, fields, and methods for the mod's currency system.
- Since:
- 2.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classA map containing values of a specified currency type.static interfaceA type that has an associated item representation.static final recordAn item given as a reward for converting currency.static final recordAn item created using multiple reward items.static final recordA base unit of currency. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe NBT key used to determine whether a given item stack may be exchanged. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic booleancanExchange(net.minecraft.item.ItemStack stack) Returns whether the given item stack may be automatically exchanged.static voiddropRewards(net.minecraft.entity.player.PlayerEntity player, int rolls) Drops rewards to the provided player entity.static voidtryExchange(net.minecraft.entity.player.PlayerEntity player) Automatically exchanges currency items within a player's inventory.static booleantryExchangeRewards(net.minecraft.entity.player.PlayerEntity player, List<net.minecraft.util.Pair<net.minecraft.item.ItemStack, CurrencyHelper.Reward>> pairs) Automatically exchanges currency rewards within a player's inventory.static booleantryExchangeUnits(net.minecraft.entity.player.PlayerEntity player, List<net.minecraft.util.Pair<net.minecraft.item.ItemStack, CurrencyHelper.Unit>> pairs) Automatically exchanges currency units within a player's inventory.
-
Field Details
-
EXCHANGE_KEY
The NBT key used to determine whether a given item stack may be exchanged.- Since:
- 2.0.0
- See Also:
-
-
Method Details
-
canExchange
static boolean canExchange(net.minecraft.item.ItemStack stack) Returns whether the given item stack may be automatically exchanged.This is checked using the "Exchange" NBT tag. If this tag is not present, this method will always return true.
- Parameters:
stack- The item stack.- Returns:
- Whether the given item stack may be automatically exchanged.
- Since:
- 2.0.0
-
dropRewards
static void dropRewards(net.minecraft.entity.player.PlayerEntity player, int rolls) Drops rewards to the provided player entity.- Parameters:
player- The target player entity.rolls- The attempts at rolling a reward.- Since:
- 2.0.0
-
tryExchange
static void tryExchange(net.minecraft.entity.player.PlayerEntity player) Automatically exchanges currency items within a player's inventory.- Parameters:
player- The target player entity.- Since:
- 2.0.0
-
tryExchangeUnits
static boolean tryExchangeUnits(net.minecraft.entity.player.PlayerEntity player, List<net.minecraft.util.Pair<net.minecraft.item.ItemStack, CurrencyHelper.Unit>> pairs) Automatically exchanges currency units within a player's inventory.- Parameters:
player- The target player entity.pairs- Pairs of item stacks, and their associated units.- Returns:
- Whether the player's inventory was modified.
- Since:
- 2.0.0
-
tryExchangeRewards
static boolean tryExchangeRewards(net.minecraft.entity.player.PlayerEntity player, List<net.minecraft.util.Pair<net.minecraft.item.ItemStack, CurrencyHelper.Reward>> pairs) Automatically exchanges currency rewards within a player's inventory.- Parameters:
player- The target player entity.pairs- Pairs of item stacks, and their associated rewards.- Returns:
- Whether the player's inventory was modified.
- Since:
- 2.0.0
-