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
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec
<EnchantmentsByCostWithDifficulty> private final HolderSet
<Enchantment> The field for theenchantments
record component.static final int
private final int
The field for themaxCostSpan
record component.private final int
The field for theminCost
record component.Fields inherited from interface net.minecraft.world.item.enchantment.providers.EnchantmentProvider
DIRECT_CODEC
-
Constructor Summary
ConstructorDescriptionEnchantmentsByCostWithDifficulty
(HolderSet<Enchantment> enchantments, int minCost, int maxCostSpan) Creates an instance of aEnchantmentsByCostWithDifficulty
record class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec
<EnchantmentsByCostWithDifficulty> codec()
void
enchant
(ItemStack p_344777_, ItemEnchantments.Mutable p_344895_, RandomSource p_346012_, DifficultyInstance p_348635_) 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.int
Returns the value of themaxCostSpan
record component.int
minCost()
Returns the value of theminCost
record component.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
enchantments
The field for theenchantments
record component. -
minCost
private final int minCostThe field for theminCost
record component. -
maxCostSpan
private final int maxCostSpanThe field for themaxCostSpan
record 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 aEnchantmentsByCostWithDifficulty
record class.- Parameters:
enchantments
- the value for theenchantments
record componentminCost
- the value for theminCost
record componentmaxCostSpan
- the value for themaxCostSpan
record component
-
-
Method Details
-
enchant
public void enchant(ItemStack p_344777_, ItemEnchantments.Mutable p_344895_, RandomSource p_346012_, DifficultyInstance p_348635_) - 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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
enchantments
Returns the value of theenchantments
record component.- Returns:
- the value of the
enchantments
record component
-
minCost
public int minCost()Returns the value of theminCost
record component.- Returns:
- the value of the
minCost
record component
-
maxCostSpan
public int maxCostSpan()Returns the value of themaxCostSpan
record component.- Returns:
- the value of the
maxCostSpan
record component
-