package net.mcreator.customoregen.item;

import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.mcreator.customoregen.config.ModConfigs;

/**
 * Base class for Shard Diamond armor items with custom stats matching Forge
 * 1.20.1
 */
public abstract class ShardDiamondArmorItem extends ArmorItem {

	public ShardDiamondArmorItem(ArmorItem.Type type, Item.Properties properties) {
		super(ShardDiamondArmorMaterial.SHARD_DIAMOND, type, properties.stacksTo(64));
	}

	/**
	 * Override durability to match config
	 */
	@Override
	public int getMaxDamage(ItemStack stack) {
		if (!ModConfigs.isLoaded()) {
			return switch (getType()) {
				case HELMET -> 250;
				case CHESTPLATE -> 300;
				case LEGGINGS -> 280;
				case BOOTS -> 230;
				default -> super.getMaxDamage(stack);
			};
		}
		return switch (getType()) {
			case HELMET -> ModConfigs.TOOL_STATS.shardDiamondHelmetDurability.get();
			case CHESTPLATE -> ModConfigs.TOOL_STATS.shardDiamondChestplateDurability.get();
			case LEGGINGS -> ModConfigs.TOOL_STATS.shardDiamondLeggingsDurability.get();
			case BOOTS -> ModConfigs.TOOL_STATS.shardDiamondBootsDurability.get();
			default -> super.getMaxDamage(stack);
		};
	}

	/**
	 * Override protection to match original stats:
	 * helmet: 3, chestplate: 7, leggings: 5, boots: 2
	 */
	@Override
	public int getDefense() {
		return switch (getType()) {
			case HELMET -> 3;
			case CHESTPLATE -> 7;
			case LEGGINGS -> 5;
			case BOOTS -> 2;
			default -> super.getDefense();
		};
	}

	/**
	 * Override toughness to match config
	 */
	@Override
	public float getToughness() {
		return ModConfigs.isLoaded() ? ModConfigs.TOOL_STATS.shardDiamondArmorToughness.get().floatValue() : 1.0f;
	}

	/**
	 * Override enchantment value to match original stat: 14
	 */
	@Override
	public int getEnchantmentValue() {
		return 14;
	}
}
