package ru.dbotthepony.mc.otm.item.exopack

import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Rarity
import ru.dbotthepony.mc.otm.core.registryName
import ru.dbotthepony.mc.otm.core.toUUID
import java.util.UUID

class ExoPackSlotUpgradeItem : AbstractExoPackSlotUpgradeItem {
	val hasDescription: Boolean
	val slotCount: Int

	private val uuidProvider: () -> UUID?

	override fun uuid(itemStack: ItemStack): UUID? {
		return uuidProvider.invoke()
	}

	override fun hasDescription(itemStack: ItemStack): Boolean {
		return hasDescription
	}

	override fun slotCount(itemStack: ItemStack): Int {
		return slotCount
	}

	constructor(slotCount: Int, rarity: Rarity, hasDescription: Boolean = false) : super(defaultProperties(rarity)) {
		this.slotCount = slotCount
		this.uuidProvider = lazy { registryName!!.toUUID() }::value
		this.hasDescription = hasDescription
	}

	constructor(uuid: UUID?, slotCount: Int, rarity: Rarity, hasDescription: Boolean = false) : super(defaultProperties(rarity)) {
		this.slotCount = slotCount
		this.uuidProvider = { uuid }
		this.hasDescription = hasDescription
	}
}
