package ru.dbotthepony.mc.otm.registry.game

import net.minecraft.core.registries.BuiltInRegistries
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.bus.api.IEventBus
import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.core.ResourceLocation
import ru.dbotthepony.mc.otm.registry.MDeferredRegister
import ru.dbotthepony.mc.otm.registry.MItemTags

// why is this even a thing holy shit
object MArmorMaterials {
	private val registrar = MDeferredRegister(BuiltInRegistries.ARMOR_MATERIAL)

	fun register(bus: IEventBus) {
		registrar.register(bus)
	}

	val TRITANIUM = registrar.register("tritanium") {
		ArmorMaterial(
			mapOf(
				ArmorItem.Type.HELMET to 4,
				ArmorItem.Type.CHESTPLATE to 9,
				ArmorItem.Type.LEGGINGS to 7,
				ArmorItem.Type.BOOTS to 3,
			),
			9,
			SoundEvents.ARMOR_EQUIP_IRON,
			{ Ingredient.of(MItemTags.REINFORCED_TRITANIUM_PLATES) },
			listOf(
				ArmorMaterial.Layer(ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium"), "", true),
				ArmorMaterial.Layer(ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium"), "", false),
			), // ignored
			1f,
			0.08f
		)
	}

	val SIMPLE_TRITANIUM = registrar.register("simple_tritanium") {
		ArmorMaterial(
			mapOf(
				ArmorItem.Type.HELMET to 2,
				ArmorItem.Type.CHESTPLATE to 6,
				ArmorItem.Type.LEGGINGS to 7,
				ArmorItem.Type.BOOTS to 2,
			),
			9,
			SoundEvents.ARMOR_EQUIP_IRON,
			{ Ingredient.of(MItemTags.TRITANIUM_INGOTS) },
			listOf(ArmorMaterial.Layer(ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium_simple"))),
			0.3f,
			0f
		)
	}

	val GRAVITATION_STABILIZIER = registrar.register("gravitation_stabilizer") {
		ArmorMaterial(
			mapOf(
				ArmorItem.Type.CHESTPLATE to 3,
			),
			9,
			SoundEvents.ARMOR_EQUIP_GENERIC,
			{ Ingredient.EMPTY },
			listOf(ArmorMaterial.Layer(ResourceLocation(OverdriveThatMatters.MOD_ID, "gravitation_stabilizer"), "", false)), // custom model
			0f,
			0f
		)
	}
}
