Record Class CostPropertyWrapper
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.config.wrapper.CostPropertyWrapper
- Record Components:
baseWrapper- The integer property wrapper governing the base enchanting cost, ornull.perLevelWrapper- The integer property wrapper governing the cost increment per level above the first, ornull.
public record CostPropertyWrapper(IntPropertyWrapper baseWrapper, IntPropertyWrapper perLevelWrapper)
extends Record
Composite configuration wrapper for dynamically evaluating an
Enchantment.Cost structure
(min_cost or max_cost), encapsulating independent IntPropertyWrapper instances
for the base cost and the per_level_above_first increment.-
Constructor Summary
ConstructorsConstructorDescriptionCostPropertyWrapper(IntPropertyWrapper baseWrapper, IntPropertyWrapper perLevelWrapper) Creates an instance of aCostPropertyWrapperrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebaseWrapperrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanDetermines whether either the base cost wrapper or the per-level cost wrapper holds an active configuration.booleanisDifferent(net.minecraft.world.item.enchantment.Enchantment.Cost original) Checks whether the currently configured cost parameters differ from the provided baselineEnchantment.Cost.Returns the value of theperLevelWrapperrecord component.net.minecraft.world.item.enchantment.Enchantment.Costresolve(net.minecraft.world.item.enchantment.Enchantment.Cost original) Constructs an updatedEnchantment.Costusing the active configuration values, or returnsoriginalif neither sub-property is configured.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CostPropertyWrapper
Creates an instance of aCostPropertyWrapperrecord class.- Parameters:
baseWrapper- the value for thebaseWrapperrecord componentperLevelWrapper- the value for theperLevelWrapperrecord component
-
-
Method Details
-
isConfigured
public boolean isConfigured()Determines whether either the base cost wrapper or the per-level cost wrapper holds an active configuration.- Returns:
trueif at least one sub-wrapper is non-null and configured,falseotherwise.
-
isDifferent
public boolean isDifferent(net.minecraft.world.item.enchantment.Enchantment.Cost original) Checks whether the currently configured cost parameters differ from the provided baselineEnchantment.Cost.- Parameters:
original- The original baselineEnchantment.Costfrom the enchantment definition.- Returns:
trueif the resolved base or per-level cost differs fromoriginal,falseotherwise.
-
resolve
public net.minecraft.world.item.enchantment.Enchantment.Cost resolve(net.minecraft.world.item.enchantment.Enchantment.Cost original) Constructs an updatedEnchantment.Costusing the active configuration values, or returnsoriginalif neither sub-property is configured.- Parameters:
original- The original baselineEnchantment.Costused for fallback values.- Returns:
- A new
Enchantment.Costreflecting the active configuration, ororiginalif unconfigured.
-
toString
-
hashCode
-
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). -
baseWrapper
Returns the value of thebaseWrapperrecord component.- Returns:
- the value of the
baseWrapperrecord component
-
perLevelWrapper
Returns the value of theperLevelWrapperrecord component.- Returns:
- the value of the
perLevelWrapperrecord component
-