package net.mcreator.customoregen.config;

import net.neoforged.neoforge.common.ModConfigSpec;

public class ModConfigs {
	public static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
	public static final ModConfigSpec SPEC;

	public static final OreGenConfig ORE_GEN;
	public static final ToolStatsConfig TOOL_STATS;
	public static final DropsConfig DROPS;
	public static final FeatureToggleConfig FEATURES;

	static {
		BUILDER.push("Custom Ore Gem Configuration");

		ORE_GEN = new OreGenConfig(BUILDER);
		TOOL_STATS = new ToolStatsConfig(BUILDER);
		DROPS = new DropsConfig(BUILDER);
		FEATURES = new FeatureToggleConfig(BUILDER);

		BUILDER.pop();
		SPEC = BUILDER.build();
	}

	public static boolean isLoaded() {
		return SPEC.isLoaded();
	}

	// Configuration pour la génération des minerais
	public static class OreGenConfig {
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMinHeight;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMaxHeight;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreCount;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreSize;

		public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreCount;
		public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreSize;

		public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreCount;
		public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMinHeight;
		public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMaxHeight;

		public final ModConfigSpec.ConfigValue<Integer> concentratedCoalOreCount;

		public final ModConfigSpec.ConfigValue<Integer> impureIronOreCount;
		public final ModConfigSpec.ConfigValue<Integer> impureGoldOreCount;

		public final ModConfigSpec.ConfigValue<Integer> highEmeraldOreCount;
		public final ModConfigSpec.ConfigValue<Integer> lowerEmeraldOreCount;

		public final ModConfigSpec.ConfigValue<Integer> highCopperOreCount;
		public final ModConfigSpec.ConfigValue<Integer> lowerCopperOreCount;

		public OreGenConfig(ModConfigSpec.Builder builder) {
			builder.push("ore_generation");

			builder.push("shard_diamond_ore");
			shardDiamondOreMinHeight = builder
					.comment("Minimum height for Shard Diamond Ore generation (default: 0)")
					.defineInRange("minHeight", 0, -64, 320);
			shardDiamondOreMaxHeight = builder
					.comment("Maximum height for Shard Diamond Ore generation (default: 15)")
					.defineInRange("maxHeight", 15, -64, 320);
			shardDiamondOreCount = builder
					.comment("Number of Shard Diamond Ore veins per chunk (default: 1)")
					.defineInRange("veinsPerChunk", 1, 0, 20);
			shardDiamondOreSize = builder
					.comment("Size of Shard Diamond Ore veins (default: 8)")
					.defineInRange("veinSize", 8, 1, 32);
			builder.pop();

			builder.push("concentrated_diamond_ore");
			concentratedDiamondOreCount = builder
					.comment("Number of Concentrated Diamond Ore veins per chunk (default: 1)")
					.defineInRange("veinsPerChunk", 1, 0, 20);
			concentratedDiamondOreSize = builder
					.comment("Size of Concentrated Diamond Ore veins (default: 8)")
					.defineInRange("veinSize", 8, 1, 32);
			builder.pop();

			builder.push("pure_golden_ore");
			pureGoldenOreCount = builder
					.comment("Number of Pure Golden Ore veins per chunk (default: 4)")
					.defineInRange("veinsPerChunk", 4, 0, 20);
			pureGoldenOreMinHeight = builder
					.comment("Minimum height for Pure Golden Ore generation (default: 0)")
					.defineInRange("minHeight", 0, -64, 320);
			pureGoldenOreMaxHeight = builder
					.comment("Maximum height for Pure Golden Ore generation (default: 320)")
					.defineInRange("maxHeight", 320, -64, 320);
			builder.pop();

			builder.push("concentrated_coal_ore");
			concentratedCoalOreCount = builder
					.comment("Number of Concentrated Coal Ore veins per chunk (default: 2)")
					.defineInRange("veinsPerChunk", 2, 0, 20);
			builder.pop();

			builder.push("impure_ores");
			impureIronOreCount = builder
					.comment("Number of Impure Iron Ore veins per chunk (default: 2)")
					.defineInRange("ironVeinsPerChunk", 2, 0, 20);
			impureGoldOreCount = builder
					.comment("Number of Impure Gold Ore veins per chunk (default: 2)")
					.defineInRange("goldVeinsPerChunk", 2, 0, 20);
			builder.pop();

			builder.push("emerald_ores");
			highEmeraldOreCount = builder
					.comment("Number of High Emerald Ore veins per chunk (default: 1)")
					.defineInRange("highVeinsPerChunk", 1, 0, 20);
			lowerEmeraldOreCount = builder
					.comment("Number of Lower Emerald Ore veins per chunk (default: 1)")
					.defineInRange("lowerVeinsPerChunk", 1, 0, 20);
			builder.pop();

			builder.push("copper_ores");
			highCopperOreCount = builder
					.comment("Number of High Copper Ore veins per chunk (default: 2)")
					.defineInRange("highVeinsPerChunk", 2, 0, 20);
			lowerCopperOreCount = builder
					.comment("Number of Lower Copper Ore veins per chunk (default: 2)")
					.defineInRange("lowerVeinsPerChunk", 2, 0, 20);
			builder.pop();

			builder.pop();
		}
	}

	// Configuration pour les stats des outils
	public static class ToolStatsConfig {
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondPickaxeDurability;
		public final ModConfigSpec.DoubleValue shardDiamondPickaxeSpeed;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondPickaxeAttackDamage;

		public final ModConfigSpec.ConfigValue<Integer> shardDiamondAxeDurability;
		public final ModConfigSpec.DoubleValue shardDiamondAxeSpeed;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondAxeAttackDamage;

		public final ModConfigSpec.ConfigValue<Integer> shardDiamondShovelDurability;
		public final ModConfigSpec.DoubleValue shardDiamondShovelSpeed;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondShovelAttackDamage;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondPaxelDurability;
		public final ModConfigSpec.DoubleValue shardDiamondPaxelSpeed;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondPaxelAttackDamage;

		public ToolStatsConfig(ModConfigSpec.Builder builder) {
			builder.push("tool_stats");

			builder.push("shard_diamond_tools");
			shardDiamondPickaxeDurability = builder
					.comment("Durability of Shard Diamond Pickaxe (default: 450)")
					.defineInRange("pickaxeDurability", 450, 1, 5000);
			shardDiamondPickaxeSpeed = builder
					.comment("Mining speed of Shard Diamond Pickaxe (default: 7.0)")
					.defineInRange("pickaxeSpeed", 7.0, 0.1, 20.0);
			shardDiamondPickaxeAttackDamage = builder
					.comment("Attack damage of Shard Diamond Pickaxe (default: 1)")
					.defineInRange("pickaxeAttackDamage", 1, 0, 20);

			shardDiamondAxeDurability = builder
					.comment("Durability of Shard Diamond Axe (default: 450)")
					.defineInRange("axeDurability", 450, 1, 5000);
			shardDiamondAxeSpeed = builder
					.comment("Mining speed of Shard Diamond Axe (default: 7.0)")
					.defineInRange("axeSpeed", 7.0, 0.1, 20.0);
			shardDiamondAxeAttackDamage = builder
					.comment("Attack damage of Shard Diamond Axe (default: 6)")
					.defineInRange("axeAttackDamage", 6, 0, 20);

			shardDiamondShovelDurability = builder
					.comment("Durability of Shard Diamond Shovel (default: 450)")
					.defineInRange("shovelDurability", 450, 1, 5000);
			shardDiamondShovelSpeed = builder
					.comment("Mining speed of Shard Diamond Shovel (default: 4.0)")
					.defineInRange("shovelSpeed", 4.0, 0.1, 20.0);
			shardDiamondShovelAttackDamage = builder
					.comment("Attack damage of Shard Diamond Shovel (default: 2)")
					.defineInRange("shovelAttackDamage", 2, 0, 20);

			shardDiamondPaxelDurability = builder
					.comment("Durability of Shard Diamond Paxel (default: 800)")
					.defineInRange("paxelDurability", 800, 1, 5000);
			shardDiamondPaxelSpeed = builder
					.comment("Mining speed of Shard Diamond Paxel (default: 6.5)")
					.defineInRange("paxelSpeed", 6.5, 0.1, 20.0);
			shardDiamondPaxelAttackDamage = builder
					.comment("Attack damage of Shard Diamond Paxel (default: 4)")
					.defineInRange("paxelAttackDamage", 4, 0, 20);
			builder.pop();

			builder.push("shard_diamond_armor");
			shardDiamondHelmetDurability = builder
					.comment("Durability of Shard Diamond Helmet (default: 250)")
					.defineInRange("helmetDurability", 250, 1, 5000);
			shardDiamondChestplateDurability = builder
					.comment("Durability of Shard Diamond Chestplate (default: 300)")
					.defineInRange("chestplateDurability", 300, 1, 5000);
			shardDiamondLeggingsDurability = builder
					.comment("Durability of Shard Diamond Leggings (default: 280)")
					.defineInRange("leggingsDurability", 280, 1, 5000);
			shardDiamondBootsDurability = builder
					.comment("Durability of Shard Diamond Boots (default: 230)")
					.defineInRange("bootsDurability", 230, 1, 5000);
			shardDiamondArmorToughness = builder
					.comment("Toughness of Shard Diamond Armor (default: 1.0)")
					.defineInRange("armorToughness", 1.0, 0.0, 10.0);
			shardDiamondArmorKnockbackResistance = builder
					.comment("Knockback resistance of Shard Diamond Armor (default: 0.0)")
					.defineInRange("armorKnockbackResistance", 0.0, 0.0, 1.0);
			builder.pop();

			builder.pop();
		}

		public final ModConfigSpec.ConfigValue<Integer> shardDiamondHelmetDurability;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondChestplateDurability;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondLeggingsDurability;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondBootsDurability;
		public final ModConfigSpec.DoubleValue shardDiamondArmorToughness;
		public final ModConfigSpec.DoubleValue shardDiamondArmorKnockbackResistance;
	}

	// Configuration pour les drops des minerais
	public static class DropsConfig {
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> shardDiamondOreMaxDrops;
		public final ModConfigSpec.ConfigValue<Boolean> shardDiamondOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> concentratedDiamondOreMaxDrops;
		public final ModConfigSpec.ConfigValue<Boolean> concentratedDiamondOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> concentratedCoalOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> concentratedCoalOreMaxDrops;
		public final ModConfigSpec.BooleanValue concentratedCoalOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> pureGoldenOreMaxDrops;
		public final ModConfigSpec.BooleanValue pureGoldenOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> impureIronOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> impureIronOreMaxDrops;
		public final ModConfigSpec.BooleanValue impureIronOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> impureGoldOreMaxDrops;

		public final ModConfigSpec.ConfigValue<Integer> lapisOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> lapisOreMaxDrops;
		public final ModConfigSpec.BooleanValue lapisOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> redstoneOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> redstoneOreMaxDrops;
		public final ModConfigSpec.BooleanValue redstoneOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> emeraldOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> emeraldOreMaxDrops;

		public final ModConfigSpec.ConfigValue<Integer> copperOreMinDrops;
		public final ModConfigSpec.ConfigValue<Integer> copperOreMaxDrops;
		public final ModConfigSpec.BooleanValue copperOreEnableFortune;

		public final ModConfigSpec.ConfigValue<Integer> oreExperienceDrops;


		public DropsConfig(ModConfigSpec.Builder builder) {
			builder.push("drops");

			builder.push("shard_diamond_ore");
			shardDiamondOreMinDrops = builder
					.comment("Minimum shards dropped by Shard Diamond Ore (default: 1)")
					.defineInRange("minDrops", 1, 0, 64);
			shardDiamondOreMaxDrops = builder
					.comment("Maximum shards dropped by Shard Diamond Ore (default: 2)")
					.defineInRange("maxDrops", 2, 0, 64);
			shardDiamondOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Shard Diamond Ore (default: true)")
					.define("enableFortune", true);
			builder.pop();

			builder.push("concentrated_diamond_ore");
			concentratedDiamondOreMinDrops = builder
					.comment("Minimum diamonds dropped by Deepslate Diamond Ore (default: 1) - vanilla equivalent")
					.defineInRange("minDrops", 1, 0, 64);
			concentratedDiamondOreMaxDrops = builder
					.comment("Maximum diamonds dropped by Deepslate Diamond Ore (default: 1) - vanilla equivalent")
					.defineInRange("maxDrops", 1, 0, 64);
			concentratedDiamondOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Deepslate Diamond Ore (default: true) - vanilla equivalent")
					.define("enableFortune", true);
			builder.pop();

			builder.push("concentrated_coal_ore");
			concentratedCoalOreMinDrops = builder
					.comment("Minimum coal dropped by Concentrated Coal Ore (default: 1) - vanilla equivalent")
					.defineInRange("minDrops", 1, 0, 64);
			concentratedCoalOreMaxDrops = builder
					.comment("Maximum coal dropped by Concentrated Coal Ore (default: 1) - vanilla equivalent")
					.defineInRange("maxDrops", 1, 0, 64);
			concentratedCoalOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Concentrated Coal Ore (default: true) - vanilla equivalent")
					.define("enableFortune", true);
			builder.pop();

			builder.push("pure_golden_ore");
			pureGoldenOreMinDrops = builder
					.comment("Minimum raw gold dropped by Pure Golden Ore (default: 1) - vanilla equivalent")
					.defineInRange("minDrops", 1, 0, 64);
			pureGoldenOreMaxDrops = builder
					.comment("Maximum raw gold dropped by Pure Golden Ore (default: 1) - vanilla equivalent")
					.defineInRange("maxDrops", 1, 0, 64);
			pureGoldenOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Pure Golden Ore (default: false) - vanilla iron/gold ores ignore Fortune")
					.define("enableFortune", false);
			builder.pop();

			builder.push("impure_ores");
			impureIronOreMinDrops = builder
					.comment("Minimum raw iron dropped by Iron Ore (default: 1) - vanilla equivalent")
					.defineInRange("ironMinDrops", 1, 0, 64);
			impureIronOreMaxDrops = builder
					.comment("Maximum raw iron dropped by Iron Ore (default: 1) - vanilla equivalent")
					.defineInRange("ironMaxDrops", 1, 0, 64);
			impureIronOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Iron Ore (default: false) - vanilla iron/gold ores ignore Fortune")
					.define("enableFortune", false);
			impureGoldOreMinDrops = builder
					.comment("Minimum raw gold dropped by Impure Gold Ore (default: 1)")
					.defineInRange("goldMinDrops", 1, 0, 64);
			impureGoldOreMaxDrops = builder
					.comment("Maximum raw gold dropped by Impure Gold Ore (default: 1)")
					.defineInRange("goldMaxDrops", 1, 0, 64);
			builder.pop();

			builder.push("vanilla_ore_variants");
			lapisOreMinDrops = builder
					.comment("Minimum lapis dropped (default: 4) - vanilla equivalent")
					.defineInRange("lapisMinDrops", 4, 0, 64);
			lapisOreMaxDrops = builder
					.comment("Maximum lapis dropped (default: 9) - vanilla equivalent")
					.defineInRange("lapisMaxDrops", 9, 0, 64);
			lapisOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Lapis Ore (default: true) - vanilla equivalent")
					.define("enableFortune", true);
			redstoneOreMinDrops = builder
					.comment("Minimum redstone dropped (default: 4) - vanilla equivalent")
					.defineInRange("redstoneMinDrops", 4, 0, 64);
			redstoneOreMaxDrops = builder
					.comment("Maximum redstone dropped (default: 5) - vanilla equivalent")
					.defineInRange("redstoneMaxDrops", 5, 0, 64);
			redstoneOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Redstone Ore (default: true) - vanilla equivalent")
					.define("enableFortune", true);
			emeraldOreMinDrops = builder
					.comment("Minimum emerald dropped (default: 1) - vanilla equivalent")
					.defineInRange("emeraldMinDrops", 1, 0, 64);
			emeraldOreMaxDrops = builder
					.comment("Maximum emerald dropped (default: 1) - vanilla equivalent")
					.defineInRange("emeraldMaxDrops", 1, 0, 64);
			copperOreMinDrops = builder
					.comment("Minimum raw copper dropped (default: 2) - vanilla equivalent")
					.defineInRange("copperMinDrops", 2, 0, 64);
			copperOreMaxDrops = builder
					.comment("Maximum raw copper dropped (default: 5) - vanilla equivalent")
					.defineInRange("copperMaxDrops", 5, 0, 64);
			copperOreEnableFortune = builder
					.comment("Enable Fortune enchantment on Copper Ore (default: true) - vanilla equivalent")
					.define("enableFortune", true);
			builder.pop();

			oreExperienceDrops = builder

					.comment("Experience dropped when mining custom ores (default: 2)")
					.defineInRange("oreExperience", 2, 0, 100);

			builder.pop();
		}
	}

	// Configuration pour activer/désactiver les fonctionnalités
	public static class FeatureToggleConfig {
		public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondTools;
		public final ModConfigSpec.ConfigValue<Boolean> enableShardDiamondOre;
		public final ModConfigSpec.ConfigValue<Boolean> enableConcentratedOres;
		public final ModConfigSpec.ConfigValue<Boolean> enableImpureOres;
		public final ModConfigSpec.ConfigValue<Boolean> enablePureGoldenOre;
		public final ModConfigSpec.ConfigValue<Boolean> enableCustomEmeraldOres;
		public final ModConfigSpec.ConfigValue<Boolean> enableCustomCopperOres;
		public final ModConfigSpec.ConfigValue<Boolean> enableVanillaOreVariants;

		public FeatureToggleConfig(ModConfigSpec.Builder builder) {
			builder.push("features");

			enableShardDiamondTools = builder
					.comment("Enable Shard Diamond Tools (default: true)")
					.define("enableShardDiamondTools", true);
			enableShardDiamondOre = builder
					.comment("Enable Shard Diamond Ore generation (default: true)")
					.define("enableShardDiamondOre", true);
			enableConcentratedOres = builder
					.comment("Enable Concentrated Ores (Diamond, Coal) (default: true)")
					.define("enableConcentratedOres", true);
			enableImpureOres = builder
					.comment("Enable Impure Ores (Iron, Gold) (default: true)")
					.define("enableImpureOres", true);
			enablePureGoldenOre = builder
					.comment("Enable Pure Golden Ore (default: true)")
					.define("enablePureGoldenOre", true);
			enableCustomEmeraldOres = builder
					.comment("Enable Custom Emerald Ores (High, Lower) (default: true)")
					.define("enableCustomEmeraldOres", true);
			enableCustomCopperOres = builder
					.comment("Enable Custom Copper Ores (High, Lower) (default: true)")
					.define("enableCustomCopperOres", true);
			enableVanillaOreVariants = builder
					.comment("Enable Vanilla Ore variants (Iron, Redstone, Lapis, etc.) (default: true)")
					.define("enableVanillaOreVariants", true);

			builder.pop();
		}
	}
}
