-
Notifications
You must be signed in to change notification settings - Fork 0
Value Exporter Registry
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.
Like the importer, you utilize ValueExporterRegistry.bindCodecs() to bridge the dynamic and static states seamlessly.
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.
Want to learn more about the configuration engine powering Enchantment Core?
Check out Config Understood, the official wiki for Config Overhauled, for a deep dive into dynamic property generation and state synchronization!