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 Details Link icon

  • Constructor Details Link icon

    • EnchantmentLevelEntry Link icon

      public EnchantmentLevelEntry(RegistryEntry<Enchantment> enchantment, int level)
      Creates an instance of a EnchantmentLevelEntry record class.
      Parameters:
      enchantment - the value for the enchantment record component
      level - the value for the level record component
  • Method Details Link icon

    • getWeight Link icon

      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 Link icon

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode Link icon

      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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals Link icon

      public final boolean equals(Object object)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      object - the object with which to compare
      Returns:
      true if this object is the same as the object argument; false otherwise.
    • enchantment Link icon

      public RegistryEntry<Enchantment> enchantment()
      Returns the value of the enchantment record component.
      Returns:
      the value of the enchantment record component
    • level Link icon

      public int level()
      Returns the value of the level record component.
      Returns:
      the value of the level record component