Skip to content

Value Exporter Registry

JohnSmith474 edited this page Sep 21, 2026 · 2 revisions

The ValueExporterRegistry is the inverse of the Importer Registry. It manages the reverse transformation of dynamic, configurable LevelBasedValue objects back into standard, static vanilla JSON structures during the /enchantment_core export command phase.

If you registered a dynamic value codec (e.g., my_mod:configurable_sine_wave), you must provide an exporter so modpack creators can safely strip your configurations out and flatten the datapack.

The Codec Exporter

Like the importer, you utilize ValueExporterRegistry.bindCodecs() to bridge the dynamic and static states seamlessly.

Example: Flattening a Custom Configurable Curve

import johnsmith.enchantmentcore.registry.ValueExporterRegistry;

public class MyModExporters {
    public static void init() {
        ValueExporterRegistry.register("my_mod:configurable_sine_wave", ValueExporterRegistry.bindCodecs(
            ConfigurableSineWaveValue.CODEC, 
            SineWaveValue.CODEC, 
            "my_mod:sine_wave", 
            (source) -> {
                // 'source' is the dynamically configured object.
                // We extract its hardcoded default/fallback properties to construct a static version.
                
                return new SineWaveValue(source.getDefaultAmplitude());
            }
        ));
    }
}

When the export command runs, any "type": "my_mod:configurable_sine_wave" blocks will be cleanly reverted to "type": "my_mod:sine_wave" using the fallback defaults defined within the config wrappers.

Clone this wiki locally