Class DataTransformerRegistry

java.lang.Object
johnsmith.enchantmentcore.api.registry.DataTransformerRegistry

public class DataTransformerRegistry extends Object
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.

  • Field Details

    • KEY_MAX_LEVEL

      public static final String KEY_MAX_LEVEL
      JSON key for the enchantment's maximum level definition.
      See Also:
    • KEY_WEIGHT

      public static final String KEY_WEIGHT
      JSON key for the enchantment's rarity weight definition.
      See Also:
    • KEY_ANVIL_COST

      public static final String KEY_ANVIL_COST
      JSON key for the enchantment's anvil combination cost definition.
      See Also:
    • KEY_SUPPORTED_ITEMS

      public static final String KEY_SUPPORTED_ITEMS
      JSON key for the enchantment's supported item set definition.
      See Also:
    • KEY_PRIMARY_ITEMS

      public static final String KEY_PRIMARY_ITEMS
      JSON key for the enchantment's primary enchanting-table item set definition.
      See Also:
    • KEY_SLOTS

      public static final String KEY_SLOTS
      JSON key for the enchantment's active equipment slot groups definition.
      See Also:
    • KEY_MIN_COST

      public static final String KEY_MIN_COST
      JSON key for the enchantment's minimum enchanting-table cost definition.
      See Also:
    • KEY_MAX_COST

      public static final String KEY_MAX_COST
      JSON key for the enchantment's maximum enchanting-table cost definition.
      See Also:
  • Constructor Details

    • DataTransformerRegistry

      public DataTransformerRegistry()
  • Method Details

    • registerTransformer

      public static void registerTransformer(DataTransformerRegistry.Transformer transformer)
      Registers a structural DataTransformerRegistry.Transformer to the import/export execution pipeline.
      Parameters:
      transformer - The DataTransformerRegistry.Transformer implementation to add.
    • registerEffectProperty

      public static void registerEffectProperty(String propertyKey)
      Registers a JSON property key identifying a field that holds LevelBasedValue data.
      Parameters:
      propertyKey - The exact JSON key string to target during recursive effect scanning.
    • registerTypeExclusion

      public static void registerTypeExclusion(String typeId)
      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-LevelBasedValue types like FloatProvider.

      Parameters:
      typeId - The resource location string of the effect type to exclude.
    • registerTypeExclusions

      public static void registerTypeExclusions(Collection<String> typeIds)
      Registers multiple effect "type" identifiers to bypass recursive transformation.
      Parameters:
      typeIds - A collection of effect type resource location strings to exclude.
    • registerDynamicTypeExclusions

      public static void registerDynamicTypeExclusions(Supplier<? extends Collection<String>> supplier)
      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

      public static void registerStructuralExclusion(String nodeKey)
      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

      public static void registerStructuralExclusions(Collection<String> nodeKeys)
      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

      public static List<DataTransformerRegistry.Transformer> getTransformers()
      Retrieves the list of registered structural DataTransformerRegistry.Transformers.
      Returns:
      The active list of transformers.
    • getEffectProperties

      public static Set<String> getEffectProperties()
      Retrieves the set of registered JSON property keys targeted for LevelBasedValue transformation.
      Returns:
      The set of effect property keys.
    • getTypeExclusions

      public static Set<String> getTypeExclusions()
      Retrieves the consolidated set of effect type exclusions, combining static registrations with all dynamic exclusion suppliers.
      Returns:
      The consolidated set of excluded effect type identifiers.
    • getStructuralExclusions

      public static Set<String> getStructuralExclusions()
      Retrieves the consolidated set of structural node exclusions, combining static registrations with all dynamic exclusion suppliers.
      Returns:
      The consolidated set of excluded structural JSON keys.
    • 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.