Record Class SingleEnchantment
java.lang.Object
java.lang.Record
net.minecraft.world.item.enchantment.providers.SingleEnchantment
- All Implemented Interfaces:
EnchantmentProvider
public record SingleEnchantment(Holder<Enchantment> enchantment, IntProvider level)
extends Record
implements EnchantmentProvider
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec
<SingleEnchantment> private final Holder
<Enchantment> The field for theenchantment
record component.private final IntProvider
The field for thelevel
record component.Fields inherited from interface net.minecraft.world.item.enchantment.providers.EnchantmentProvider
DIRECT_CODEC
-
Constructor Summary
ConstructorDescriptionSingleEnchantment
(Holder<Enchantment> enchantment, IntProvider level) Creates an instance of aSingleEnchantment
record class. -
Method Summary
Modifier and TypeMethodDescriptioncom.mojang.serialization.MapCodec
<SingleEnchantment> codec()
void
enchant
(ItemStack p_346218_, ItemEnchantments.Mutable p_345570_, RandomSource p_345742_, DifficultyInstance p_348562_) Returns the value of theenchantment
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.level()
Returns the value of thelevel
record component.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
enchantment
The field for theenchantment
record component. -
level
The field for thelevel
record component. -
CODEC
-
-
Constructor Details
-
SingleEnchantment
Creates an instance of aSingleEnchantment
record class.- Parameters:
enchantment
- the value for theenchantment
record componentlevel
- the value for thelevel
record component
-
-
Method Details
-
enchant
public void enchant(ItemStack p_346218_, ItemEnchantments.Mutable p_345570_, RandomSource p_345742_, DifficultyInstance p_348562_) - 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)
. -
enchantment
Returns the value of theenchantment
record component.- Returns:
- the value of the
enchantment
record component
-
level
Returns the value of thelevel
record component.- Returns:
- the value of the
level
record component
-