Record Class DataTransformerRegistry.CostTransformer
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.registry.DataTransformerRegistry.CostTransformer
- Record Components:
key- The top-level cost JSON key ("min_cost"or"max_cost").
- All Implemented Interfaces:
DataTransformerRegistry.Transformer
- Enclosing class:
DataTransformerRegistry
public static record DataTransformerRegistry.CostTransformer(String key)
extends Record
implements DataTransformerRegistry.Transformer
Specialized
DataTransformerRegistry.Transformer implementation for wrapping and unwrapping the base
and per_level_above_first sub-fields of an enchantment cost block (min_cost or max_cost).-
Constructor Summary
ConstructorsConstructorDescriptionCostTransformer(String key) Creates an instance of aCostTransformerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyExport(com.google.gson.JsonObject root) Mutates the enchantment JSON tree during the export phase, unwrapping dynamic configuration structures back into their static fallback representations.voidapplyImport(com.google.gson.JsonObject root, String targetNamespace, String enchantmentName) Mutates the enchantment JSON tree during the import phase, wrapping static values into dynamic configuration structures bound totargetNamespace.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.key()Returns the value of thekeyrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
CostTransformer
Creates an instance of aCostTransformerrecord class.- Parameters:
key- the value for thekeyrecord component
-
-
Method Details
-
applyImport
public void applyImport(com.google.gson.JsonObject root, String targetNamespace, String enchantmentName) Description copied from interface:DataTransformerRegistry.TransformerMutates the enchantment JSON tree during the import phase, wrapping static values into dynamic configuration structures bound totargetNamespace.- Specified by:
applyImportin interfaceDataTransformerRegistry.Transformer- Parameters:
root- The root enchantmentJsonObjectbeing mutated.targetNamespace- The mod namespace assigned to the generated configuration properties.enchantmentName- The path identifier of the target enchantment (used as the config group name).
-
applyExport
public void applyExport(com.google.gson.JsonObject root) Description copied from interface:DataTransformerRegistry.TransformerMutates the enchantment JSON tree during the export phase, unwrapping dynamic configuration structures back into their static fallback representations.- Specified by:
applyExportin interfaceDataTransformerRegistry.Transformer- Parameters:
root- The root enchantmentJsonObjectbeing mutated.
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
key
Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-