package net.mcreator.customoregen.worldgen;

import com.mojang.serialization.MapCodec;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.biome.BiomeSource;
import net.neoforged.neoforge.common.world.BiomeModifier;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import net.neoforged.neoforge.registries.NeoForgeRegistries;

/**
 * Registration of custom worldgen codecs used by the mod.
 *
 * <ul>
 *   <li>{@code latitude} — the custom latitude {@link BiomeSource} codec
 *       referenced from world presets.</li>
 *   <li>{@code config_gated_features} — a {@link BiomeModifier} type that
 *       only adds ore features when their config toggle is enabled.</li>
 * </ul>
 */
public class WorldGenRegistration {

	public static final DeferredRegister<MapCodec<? extends BiomeSource>> BIOME_SOURCES =
			DeferredRegister.create(Registries.BIOME_SOURCE, "custom_ore_gen");

	public static final DeferredHolder<MapCodec<? extends BiomeSource>, MapCodec<? extends BiomeSource>> LATITUDE =
			BIOME_SOURCES.register("latitude", () -> LatitudeBiomeSource.CODEC);

	/** Serializer registry for config-gated biome modifiers (see {@link ConfigGatedFeaturesModifier}). */
	public static final DeferredRegister<MapCodec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS =
			DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, "custom_ore_gen");

	public static final DeferredHolder<MapCodec<? extends BiomeModifier>, MapCodec<? extends BiomeModifier>> CONFIG_GATED_FEATURES =
			BIOME_MODIFIER_SERIALIZERS.register("config_gated_features", () -> ConfigGatedFeaturesModifier.CODEC);
}
