/*
 * Copyright (c) 2026 盐灯水母
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

package com.remains_cave.item;

import com.remains_cave.RemainsCaveMod;
import net.minecraft.Util;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

public class ModArmorMaterials {
    public static final DeferredRegister<ArmorMaterial> ARMOR_MATERIALS =
            DeferredRegister.create(Registries.ARMOR_MATERIAL, RemainsCaveMod.MODID);

    public static final Holder<ArmorMaterial> CHAOS_SKELETON = ARMOR_MATERIALS.register("chaos_skeleton",
            () -> {
                Map<ArmorItem.Type, Integer> defense = Util.make(new EnumMap<>(ArmorItem.Type.class), map -> {
                    map.put(ArmorItem.Type.BOOTS,  2);
                    map.put(ArmorItem.Type.LEGGINGS,  3);
                    map.put(ArmorItem.Type.CHESTPLATE, 3);
                    map.put(ArmorItem.Type.HELMET,  2);
                });

                int enchantmentValue = 15;
                Holder<SoundEvent> equipSound = SoundEvents.ARMOR_EQUIP_IRON;
                float toughness = 3.0F;
                float knockbackResistance = 0.0F;
                Supplier<Ingredient> repairIngredient = () -> Ingredient.of(ModItems.CRIMSON_CRYSTAL.get());

                List<ArmorMaterial.Layer> layers = List.of(
                        new ArmorMaterial.Layer(
                                ResourceLocation.fromNamespaceAndPath(RemainsCaveMod.MODID, "chaos_skeleton"),
                                "",
                                false
                        )
                );

                return new ArmorMaterial(
                        defense,
                        enchantmentValue,
                        equipSound,
                        repairIngredient,
                        layers,
                        toughness,
                        knockbackResistance
                );
            });
}