Package dev.jaxydog.astral.utility
Record Class CurrencyHelper.Reward
java.lang.Object
java.lang.Record
dev.jaxydog.astral.utility.CurrencyHelper.Reward
- Record Components:
itemId- The representing item's identifier.weight- The randomness weight used for reward drops.
- All Implemented Interfaces:
CurrencyHelper.ItemRepresentable
- Enclosing interface:
CurrencyHelper
public static record CurrencyHelper.Reward(net.minecraft.util.Identifier itemId, int weight)
extends Record
implements CurrencyHelper.ItemRepresentable
An item given as a reward for converting currency.
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CurrencyHelper.CurrencyMap<CurrencyHelper.Reward> A map containing all currently active currency rewards. -
Constructor Summary
ConstructorsConstructorDescriptionReward(net.minecraft.util.Identifier itemId, int weight) Creates an instance of aRewardrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.net.minecraft.util.IdentifierReturns the associated item identifier, orminecraft:airif the referenced identifier is invalid.static List<CurrencyHelper.Reward> getRandom(int count) Returns a list of randomly generated rewards.final inthashCode()Returns a hash code value for this object.net.minecraft.util.IdentifieritemId()Returns the value of theitemIdrecord component.static CurrencyHelper.Rewardparse(net.minecraft.util.Identifier itemId, com.google.gson.JsonObject object) Parses a JSON object and creates a newCurrencyHelper.Rewardfrom the resolved data.final StringtoString()Returns a string representation of this record class.intweight()Returns the value of theweightrecord component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.jaxydog.astral.utility.CurrencyHelper.ItemRepresentable
getItem
-
Field Details
-
REWARDS
A map containing all currently active currency rewards.- Since:
- 2.0.0
-
-
Constructor Details
-
Method Details
-
parse
public static CurrencyHelper.Reward parse(net.minecraft.util.Identifier itemId, com.google.gson.JsonObject object) throws com.google.gson.JsonSyntaxException Parses a JSON object and creates a newCurrencyHelper.Rewardfrom the resolved data.- Parameters:
itemId- The representing item's identifier.object- The JSON object.- Returns:
- A new reward.
- Throws:
com.google.gson.JsonSyntaxException- If a field is invalid or missing from the given object.- Since:
- 2.0.0
-
getRandom
Returns a list of randomly generated rewards.- Parameters:
count- The number of rewards to generate.- Returns:
- A list of randomly generated rewards.
- Since:
- 2.0.0
-
getItemId
public net.minecraft.util.Identifier getItemId()Description copied from interface:CurrencyHelper.ItemRepresentableReturns the associated item identifier, orminecraft:airif the referenced identifier is invalid.- Specified by:
getItemIdin interfaceCurrencyHelper.ItemRepresentable- Returns:
- The associated item identifier, or
minecraft:airif the referenced identifier is invalid.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
itemId
public net.minecraft.util.Identifier itemId()Returns the value of theitemIdrecord component.- Returns:
- the value of the
itemIdrecord component
-
weight
public int weight()Returns the value of theweightrecord component.- Returns:
- the value of the
weightrecord component
-