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
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec
<EnchantmentsByCost> private final IntProvider
The field for thecost
record component.private final HolderSet
<Enchantment> The field for theenchantments
record component.Fields inherited from interface net.minecraft.world.item.enchantment.providers.EnchantmentProvider
DIRECT_CODEC
-
Constructor Summary
ConstructorDescriptionEnchantmentsByCost
(HolderSet<Enchantment> enchantments, IntProvider cost) Creates an instance of aEnchantmentsByCost
record class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec
<EnchantmentsByCost> codec()
cost()
Returns the value of thecost
record component.void
enchant
(ItemStack p_345483_, ItemEnchantments.Mutable p_346331_, RandomSource p_344794_, DifficultyInstance p_348577_) Returns the value of theenchantments
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
enchantments
The field for theenchantments
record component. -
cost
The field for thecost
record component. -
CODEC
-
-
Constructor Details
-
EnchantmentsByCost
Creates an instance of aEnchantmentsByCost
record class.- Parameters:
enchantments
- the value for theenchantments
record componentcost
- the value for thecost
record component
-
-
Method Details
-
enchant
public void enchant(ItemStack p_345483_, ItemEnchantments.Mutable p_346331_, RandomSource p_344794_, DifficultyInstance p_348577_) - Specified by:
enchant
in interfaceEnchantmentProvider
-
codec
- Specified by:
codec
in 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 theenchantments
record component.- Returns:
- the value of the
enchantments
record component
-
cost
Returns the value of thecost
record component.- Returns:
- the value of the
cost
record component
-