Class DataTransformerRegistry
java.lang.Object
johnsmith.enchantmentcore.api.registry.DataTransformerRegistry
Centralized registry managing the bidirectional transformation of enchantment JSON definitions
between static datapack formats and dynamic Config Overhauled configuration wrappers.
During the /enchantment_core import phase, registered DataTransformerRegistry.Transformers intercept static
primitive fields and LevelBasedValue nodes and wrap them
in configuration-bound JSON objects. During the /enchantment_core export phase, the transformers
strip those dynamic wrappers and restore standard vanilla-compatible JSON structures.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordSpecializedDataTransformerRegistry.Transformerimplementation for wrapping and unwrapping thebaseandper_level_above_firstsub-fields of an enchantment cost block (min_costormax_cost).static classRecursiveDataTransformerRegistry.Transformerimplementation that traverses the"effects"tree of an enchantment JSON object, converting registeredgetEffectProperties()nodes viaValueImporterRegistryandValueExporterRegistrywhile respecting type and structural exclusions.static final recordStandardDataTransformerRegistry.Transformerimplementation for wrapping and unwrapping top-level enchantment definition fields into{"config": ..., "fallback": ...}objects.static interfaceContract for executing targeted bidirectional JSON transformations on an enchantment root object. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringJSON key for the enchantment's anvil combination cost definition.static final StringJSON key for the enchantment's maximum enchanting-table cost definition.static final StringJSON key for the enchantment's maximum level definition.static final StringJSON key for the enchantment's minimum enchanting-table cost definition.static final StringJSON key for the enchantment's primary enchanting-table item set definition.static final StringJSON key for the enchantment's active equipment slot groups definition.static final StringJSON key for the enchantment's supported item set definition.static final StringJSON key for the enchantment's rarity weight definition. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidflattenExportedConstants(com.google.gson.JsonElement element) Recursively traverses an exported JSON tree and collapses verbose constant objects ({"type": "minecraft:constant", "value": X}) into compact numeric JSON primitives.Retrieves the set of registered JSON property keys targeted forLevelBasedValuetransformation.Retrieves the consolidated set of structural node exclusions, combining static registrations with all dynamic exclusion suppliers.Retrieves the list of registered structuralDataTransformerRegistry.Transformers.Retrieves the consolidated set of effect type exclusions, combining static registrations with all dynamic exclusion suppliers.static voidregisterDynamicStructuralExclusions(Supplier<? extends Collection<String>> supplier) Registers a dynamic supplier of structural node exclusions (such as a live configuration list property).static voidregisterDynamicTypeExclusions(Supplier<? extends Collection<String>> supplier) Registers a dynamic supplier of effect type exclusions (such as a live configuration list property).static voidregisterEffectProperty(String propertyKey) Registers a JSON property key identifying a field that holdsLevelBasedValuedata.static voidregisterStructuralExclusion(String nodeKey) Registers a JSON key identifying a structural object or array node to bypass during recursive traversal.static voidregisterStructuralExclusions(Collection<String> nodeKeys) Registers multiple JSON keys identifying structural nodes to bypass during recursive traversal.static voidregisterTransformer(DataTransformerRegistry.Transformer transformer) Registers a structuralDataTransformerRegistry.Transformerto the import/export execution pipeline.static voidregisterTypeExclusion(String typeId) Registers an effect"type"identifier to bypass recursive transformation.static voidregisterTypeExclusions(Collection<String> typeIds) Registers multiple effect"type"identifiers to bypass recursive transformation.
-
Field Details
-
KEY_MAX_LEVEL
JSON key for the enchantment's maximum level definition.- See Also:
-
KEY_WEIGHT
JSON key for the enchantment's rarity weight definition.- See Also:
-
KEY_ANVIL_COST
JSON key for the enchantment's anvil combination cost definition.- See Also:
-
KEY_SUPPORTED_ITEMS
JSON key for the enchantment's supported item set definition.- See Also:
-
KEY_PRIMARY_ITEMS
JSON key for the enchantment's primary enchanting-table item set definition.- See Also:
-
KEY_SLOTS
JSON key for the enchantment's active equipment slot groups definition.- See Also:
-
KEY_MIN_COST
JSON key for the enchantment's minimum enchanting-table cost definition.- See Also:
-
KEY_MAX_COST
JSON key for the enchantment's maximum enchanting-table cost definition.- See Also:
-
-
Constructor Details
-
DataTransformerRegistry
public DataTransformerRegistry()
-
-
Method Details
-
registerTransformer
Registers a structuralDataTransformerRegistry.Transformerto the import/export execution pipeline.- Parameters:
transformer- TheDataTransformerRegistry.Transformerimplementation to add.
-
registerEffectProperty
Registers a JSON property key identifying a field that holdsLevelBasedValuedata.- Parameters:
propertyKey- The exact JSON key string to target during recursive effect scanning.
-
registerTypeExclusion
Registers an effect"type"identifier to bypass recursive transformation.Prevents DataFixerUpper parse errors when an effect uses identically named keys (such as
"volume"or"pitch") for non-LevelBasedValuetypes likeFloatProvider.- Parameters:
typeId- The resource location string of the effect type to exclude.
-
registerTypeExclusions
Registers multiple effect"type"identifiers to bypass recursive transformation.- Parameters:
typeIds- A collection of effect type resource location strings to exclude.
-
registerDynamicTypeExclusions
Registers a dynamic supplier of effect type exclusions (such as a live configuration list property).- Parameters:
supplier- A supplier returning a collection of effect type identifiers to exclude.
-
registerStructuralExclusion
Registers a JSON key identifying a structural object or array node to bypass during recursive traversal.Isolates the transformation pipeline from independent subtrees (like loot condition
"requirements") that may contain identically named keys.- Parameters:
nodeKey- The exact JSON key string of the structural node to skip.
-
registerStructuralExclusions
Registers multiple JSON keys identifying structural nodes to bypass during recursive traversal.- Parameters:
nodeKeys- A collection of structural JSON key strings to skip.
-
registerDynamicStructuralExclusions
public static void registerDynamicStructuralExclusions(Supplier<? extends Collection<String>> supplier) Registers a dynamic supplier of structural node exclusions (such as a live configuration list property).- Parameters:
supplier- A supplier returning a collection of JSON node keys to exclude.
-
getTransformers
Retrieves the list of registered structuralDataTransformerRegistry.Transformers.- Returns:
- The active list of transformers.
-
getEffectProperties
-
getTypeExclusions
-
getStructuralExclusions
-
flattenExportedConstants
public static void flattenExportedConstants(com.google.gson.JsonElement element) Recursively traverses an exported JSON tree and collapses verbose constant objects ({"type": "minecraft:constant", "value": X}) into compact numeric JSON primitives.- Parameters:
element- The JSON element tree to process and mutate in place.
-