Package net.minecraft.enchantment
Record Class EnchantmentLevelEntry
java.lang.Object
java.lang.Record
net.minecraft.enchantment.EnchantmentLevelEntry
- Record Components:
enchantment-level-
public record EnchantmentLevelEntry(RegistryEntry<Enchantment> enchantment, int level)
extends Record
Represents an entry in an enchantments array, i.e. a pair between
enchantment and level. This is also a weighted entry and is available
for the weighted picker to pick from a list.
This is usually used where multiple enchantment to level mappings can
exist, such as in enchanting logic. In other cases, vanilla prefers
Map<Enchantment, Integer> over List<EnchantmentLevelEntry>.
This class is immutable. It does not override hashCode or equals.
- Mappings:
Namespace Name named net/minecraft/enchantment/EnchantmentLevelEntryintermediary net/minecraft/class_1889official dhanamed enchantmentintermediary comp_3486official anamed levelintermediary comp_3487official b
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RegistryEntry<Enchantment> The field for theenchantmentrecord component.private final intThe field for thelevelrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionEnchantmentLevelEntry(RegistryEntry<Enchantment> enchantment, int level) Creates an instance of aEnchantmentLevelEntryrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theenchantmentrecord component.final booleanIndicates whether some other object is "equal to" this one.intfinal inthashCode()Returns a hash code value for this object.intlevel()Returns the value of thelevelrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
enchantment
The field for theenchantmentrecord component. -
level
private final int levelThe field for thelevelrecord component.
-
-
Constructor Details
-
EnchantmentLevelEntry
Creates an instance of aEnchantmentLevelEntryrecord class.- Parameters:
enchantment- the value for theenchantmentrecord componentlevel- the value for thelevelrecord component
-
-
Method Details
-
getWeight
public int getWeight()- Mappings:
Namespace Name Mixin selector named getWeightLnet/minecraft/enchantment/EnchantmentLevelEntry;getWeight()Iintermediary method_66344Lnet/minecraft/class_1889;method_66344()Iofficial aLdha;a()I
-
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 '=='. -
enchantment
Returns the value of theenchantmentrecord component.- Returns:
- the value of the
enchantmentrecord component
-
level
public int level()Returns the value of thelevelrecord component.- Returns:
- the value of the
levelrecord component
-