package ru.dbotthepony.mc.otm.item

import it.unimi.dsi.fastutil.objects.ObjectIterators
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.Component
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.TooltipFlag
import net.minecraft.world.level.Level
import ru.dbotthepony.mc.otm.client.isShiftDown
import ru.dbotthepony.mc.otm.client.minecraft
import ru.dbotthepony.mc.otm.core.ITooltippable
import ru.dbotthepony.mc.otm.core.TranslatableComponent
import ru.dbotthepony.mc.otm.core.addAll
import ru.dbotthepony.mc.otm.core.addDescriptionFunctions
import ru.dbotthepony.mc.otm.core.addDescriptionLines
import java.util.stream.Stream

open class MatteryItem(properties: Properties) : Item(properties), ITooltippable by ITooltippable.Impl() {
	override fun appendHoverText(itemStack: ItemStack, level: Level?, components: MutableList<Component>, tooltipType: TooltipFlag) {
		super.appendHoverText(itemStack, level, components, tooltipType)
		assembleDescription(itemStack, components)
	}
}

fun <T : MatteryItem> T.addSimpleDescription(suffix: String = "", formatting: ChatFormatting = ChatFormatting.GRAY): T {
	return addDescriptionFunctions { ObjectIterators.singleton(TranslatableComponent("$descriptionId.desc$suffix").withStyle(formatting)) }
}
