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/EnchantmentLevelEntry
intermediary net/minecraft/class_1889
official dha
named enchantment
intermediary comp_3486
official a
named level
intermediary comp_3487
official b
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RegistryEntry
<Enchantment> The field for theenchantment
record component.private final int
The field for thelevel
record component. -
Constructor Summary
ConstructorsConstructorDescriptionEnchantmentLevelEntry
(RegistryEntry<Enchantment> enchantment, int level) Creates an instance of aEnchantmentLevelEntry
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theenchantment
record component.final boolean
Indicates whether some other object is "equal to" this one.int
final int
hashCode()
Returns a hash code value for this object.int
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
private final int levelThe field for thelevel
record component.
-
-
Constructor Details
-
EnchantmentLevelEntry
Creates an instance of aEnchantmentLevelEntry
record class.- Parameters:
enchantment
- the value for theenchantment
record componentlevel
- the value for thelevel
record component
-
-
Method Details
-
getWeight
public int getWeight()- Mappings:
Namespace Name Mixin selector named getWeight
Lnet/minecraft/enchantment/EnchantmentLevelEntry;getWeight()I
intermediary method_66344
Lnet/minecraft/class_1889;method_66344()I
official a
Ldha;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 theenchantment
record component.- Returns:
- the value of the
enchantment
record component
-
level
public int level()Returns the value of thelevel
record component.- Returns:
- the value of the
level
record component
-