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 Classes
    Modifier and Type
    Interface
    Description
    static final class 
    A map containing values of a specified currency type.
    static interface 
    A type that has an associated item representation.
    static final record 
    An item given as a reward for converting currency.
    static final record 
    An item created using multiple reward items.
    static final record 
    A base unit of currency.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The NBT key used to determine whether a given item stack may be exchanged.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static boolean
    canExchange(net.minecraft.item.ItemStack stack)
    Returns whether the given item stack may be automatically exchanged.
    static void
    dropRewards(net.minecraft.entity.player.PlayerEntity player, int rolls)
    Drops rewards to the provided player entity.
    static void
    tryExchange(net.minecraft.entity.player.PlayerEntity player)
    Automatically exchanges currency items within a player's inventory.
    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.
    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.
  • Field Details

    • EXCHANGE_KEY

      static final String 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