Record Class EnchantmentsByCostWithDifficulty
java.lang.Object
java.lang.Record
net.minecraft.world.item.enchantment.providers.EnchantmentsByCostWithDifficulty
- All Implemented Interfaces:
EnchantmentProvider
public record EnchantmentsByCostWithDifficulty(HolderSet<Enchantment> enchantments, int minCost, int maxCostSpan)
extends Record
implements EnchantmentProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<EnchantmentsByCostWithDifficulty> private final HolderSet<Enchantment> The field for theenchantmentsrecord component.static final intprivate final intThe field for themaxCostSpanrecord component.private final intThe field for theminCostrecord component.Fields inherited from interface net.minecraft.world.item.enchantment.providers.EnchantmentProvider
DIRECT_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionEnchantmentsByCostWithDifficulty(HolderSet<Enchantment> enchantments, int minCost, int maxCostSpan) Creates an instance of aEnchantmentsByCostWithDifficultyrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<EnchantmentsByCostWithDifficulty> codec()voidenchant(ItemStack p_344973_, ItemEnchantments.Mutable p_344834_, RandomSource p_343505_, DifficultyInstance p_342467_) Returns the value of theenchantmentsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxCostSpanrecord component.intminCost()Returns the value of theminCostrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
enchantments
The field for theenchantmentsrecord component. -
minCost
private final int minCostThe field for theminCostrecord component. -
maxCostSpan
private final int maxCostSpanThe field for themaxCostSpanrecord component. -
MAX_ALLOWED_VALUE_PART
public static final int MAX_ALLOWED_VALUE_PART- See Also:
-
CODEC
-
-
Constructor Details
-
EnchantmentsByCostWithDifficulty
public EnchantmentsByCostWithDifficulty(HolderSet<Enchantment> enchantments, int minCost, int maxCostSpan) Creates an instance of aEnchantmentsByCostWithDifficultyrecord class.- Parameters:
enchantments- the value for theenchantmentsrecord componentminCost- the value for theminCostrecord componentmaxCostSpan- the value for themaxCostSpanrecord component
-
-
Method Details
-
enchant
public void enchant(ItemStack p_344973_, ItemEnchantments.Mutable p_344834_, RandomSource p_343505_, DifficultyInstance p_342467_) - Specified by:
enchantin interfaceEnchantmentProvider
-
codec
- Specified by:
codecin interfaceEnchantmentProvider
-
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 '=='. -
enchantments
Returns the value of theenchantmentsrecord component.- Returns:
- the value of the
enchantmentsrecord component
-
minCost
public int minCost()Returns the value of theminCostrecord component.- Returns:
- the value of the
minCostrecord component
-
maxCostSpan
public int maxCostSpan()Returns the value of themaxCostSpanrecord component.- Returns:
- the value of the
maxCostSpanrecord component
-