-
Notifications
You must be signed in to change notification settings - Fork 0
Spell Field Registrar
The Spell Field API is entirely modular, allowing you to create custom SpellFieldShape geometries, DistanceScalingFunction mathematics, and operational SpellFieldEffects (Block, Entity, Volume, or Visual).
The SpellFieldRegistrar is a specialized registration utility designed to safely bind these components to their internal dispatch codecs while guaranteeing that any dynamic JSON keys they introduce are properly logged with the DataTransformerRegistry.
Instead of accessing the dynamic Spell Field registries directly, you utilize the static helper methods provided by the SpellFieldRegistrar. These methods accept a BiConsumer, allowing you to dictate exactly where the codec maps while the registrar handles the background key extraction.
If you write a custom SpellFieldBlockEffect (or Entity/Volume/Visual effect), use registerEffects.
If your effect provides a LevelBasedKeyProvider interface, the registrar automatically pushes your properties to the transformer.
import johnsmith.enchantmentcore.registry.SpellFieldRegistrar;
import johnsmith.enchantmentcore.registry.EnchantmentCoreRegistries;
import net.minecraft.core.Registry;
public class MySpellFieldAddons {
public static void init() {
SpellFieldRegistrar.registerEffects((id, codec) -> {
Registry.register(EnchantmentCoreRegistries.SPELL_FIELD_EFFECTS.get(), id, codec);
});
// Example execution inside the registrar:
// registerEffect(registrar, CustomWaterEffect.KEY, CustomWaterEffect.CODEC, CustomWaterEffect.KEY_PROVIDER);
}
}(Note: Because the Spell Field API uses its own custom registries wrapped by EnchantmentCore, you map them using the suppliers found in EnchantmentCoreRegistries.)
Similarly, you can register custom geometric shapes (e.g., Pyramids, Cylinders) or new mathematical falloff curves:
// Shapes
SpellFieldRegistrar.registerShapes((id, codec) -> {
Registry.register(EnchantmentCoreRegistries.SPELL_FIELD_SHAPES.get(), id, codec);
});
// Distance Scaling Functions
SpellFieldRegistrar.registerFunctions((id, codec) -> {
Registry.register(EnchantmentCoreRegistries.DISTANCE_SCALING_FUNCTIONS.get(), id, codec);
});By strictly utilizing the SpellFieldRegistrar and KEY_PROVIDER architecture, your custom Spell Field modules gain the exact same level of data-driven configurability as the core library features.
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!