Record Class PendingEnchantment
java.lang.Object
java.lang.Record
johnsmith.enchantingoverhauled.menu.enchant.model.PendingEnchantment
- Record Components:
enchantment- The proposed enchantment instance.source- The origin source of the enchantment.
public record PendingEnchantment(Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantment, EnchantmentSource source)
extends Record
A data record that pairs a potential
EnchantmentInstance with the
EnchantmentSource origin from which it was derived.
Used during the context building pipeline to track where an incoming enchantment originated (e.g., generated by the Table vs. supplied by a Tome) so the conflict resolution logic can determine the appropriate action.
-
Constructor Summary
ConstructorsConstructorDescriptionPendingEnchantment(Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantment, EnchantmentSource source) Creates an instance of aPendingEnchantmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionOptional<net.minecraft.world.item.enchantment.EnchantmentInstance> Returns the value of theenchantmentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.source()Returns the value of thesourcerecord component.toString()Returns a string representation of this pending enchantment, unwrapping the optional for clarity in logs.
-
Constructor Details
-
PendingEnchantment
public PendingEnchantment(Optional<net.minecraft.world.item.enchantment.EnchantmentInstance> enchantment, EnchantmentSource source) Creates an instance of aPendingEnchantmentrecord class.- Parameters:
enchantment- the value for theenchantmentrecord componentsource- the value for thesourcerecord component
-
-
Method Details
-
toString
Returns a string representation of this pending enchantment, unwrapping the optional for clarity in logs. -
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 theenchantmentrecord component.- Returns:
- the value of the
enchantmentrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-