package fr.koka99cab.sanctuary.worldgen.feature;

import fr.koka99cab.sanctuary.SanctuaryMod;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;

final class SanctuaryWorldgenChecks {
	private static final ResourceKey<NoiseGeneratorSettings> SANCTUARY_NOISE_SETTINGS =
		ResourceKey.create(Registries.NOISE_SETTINGS, Identifier.fromNamespaceAndPath(SanctuaryMod.MOD_ID, "sanctuary"));

	private SanctuaryWorldgenChecks() {
	}

	static boolean isSanctuaryGenerator(FeaturePlaceContext<?> context) {
		if (!(context.chunkGenerator() instanceof NoiseBasedChunkGenerator generator)) {
			return false;
		}

		return generator.generatorSettings().unwrapKey()
			.filter(SANCTUARY_NOISE_SETTINGS::equals)
			.isPresent();
	}
}
