package ru.dbotthepony.mc.otm.item.armor

import net.minecraft.ChatFormatting
import net.minecraft.client.model.HumanoidModel
import net.minecraft.network.chat.Component
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.item.ArmorItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Rarity
import net.minecraft.world.item.TooltipFlag
import net.neoforged.neoforge.client.extensions.common.IClientItemExtensions
import net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent
import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.registry.ClientExtensionsListener
import ru.dbotthepony.mc.otm.registry.game.MArmorMaterials

private object GravitationStabilizerArmorRenderProperties : IClientItemExtensions {
	override fun getHumanoidArmorModel(
		entityLiving: LivingEntity,
		itemStack: ItemStack,
		armorSlot: EquipmentSlot,
		_default: HumanoidModel<*>
	): HumanoidModel<*> {
		return GravitationStabilizerModel.getModel()
	}
}

class PortableGravitationStabilizerItem : ArmorItem(MArmorMaterials.GRAVITATION_STABILIZIER, Type.CHESTPLATE, Properties().stacksTo(1).rarity(Rarity.RARE)), ClientExtensionsListener {
	override fun registerClientExtensions(event: RegisterClientExtensionsEvent) {
		event.registerItem(GravitationStabilizerArmorRenderProperties, this)
	}

	override fun appendHoverText(
		p_41421_: ItemStack,
		p_339594_: TooltipContext,
		p_41423_: MutableList<Component>,
		p_41424_: TooltipFlag
	) {
		super.appendHoverText(p_41421_, p_339594_, p_41423_, p_41424_)

		p_41423_.add(DESCRIPTION)
	}

	companion object {
		private val DESCRIPTION = TranslatableComponent("otm.item.blackhole_immunity").withStyle(ChatFormatting.DARK_GRAY)
	}
}
