Record Class EnchantmentsByCost
java.lang.Object
java.lang.Record
net.minecraft.world.item.enchantment.providers.EnchantmentsByCost
- All Implemented Interfaces:
EnchantmentProvider
public record EnchantmentsByCost(HolderSet<Enchantment> enchantments, IntProvider cost)
extends Record
implements EnchantmentProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<EnchantmentsByCost> private final IntProviderThe field for thecostrecord component.private final HolderSet<Enchantment> The field for theenchantmentsrecord component.Fields inherited from interface net.minecraft.world.item.enchantment.providers.EnchantmentProvider
DIRECT_CODEC -
Constructor Summary
ConstructorsConstructorDescriptionEnchantmentsByCost(HolderSet<Enchantment> enchantments, IntProvider cost) Creates an instance of aEnchantmentsByCostrecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec<EnchantmentsByCost> codec()cost()Returns the value of thecostrecord component.voidenchant(ItemStack p_344059_, ItemEnchantments.Mutable p_344702_, RandomSource p_344509_, DifficultyInstance p_345381_) 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.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
enchantments
The field for theenchantmentsrecord component. -
cost
The field for thecostrecord component. -
CODEC
-
-
Constructor Details
-
EnchantmentsByCost
Creates an instance of aEnchantmentsByCostrecord class.- Parameters:
enchantments- the value for theenchantmentsrecord componentcost- the value for thecostrecord component
-
-
Method Details
-
enchant
public void enchant(ItemStack p_344059_, ItemEnchantments.Mutable p_344702_, RandomSource p_344509_, DifficultyInstance p_345381_) - 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. All components in this record class are compared withObjects::equals(Object,Object). -
enchantments
Returns the value of theenchantmentsrecord component.- Returns:
- the value of the
enchantmentsrecord component
-
cost
Returns the value of thecostrecord component.- Returns:
- the value of the
costrecord component
-