package ru.dbotthepony.mc.otm.capability.drive

import net.minecraft.core.HolderLookup
import net.minecraft.nbt.CompoundTag
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import ru.dbotthepony.mc.otm.storage.IStorageComponent
import ru.dbotthepony.mc.otm.storage.IStorageTuple
import ru.dbotthepony.mc.otm.storage.ItemStorageStack
import ru.dbotthepony.mc.otm.storage.StorageStack
import java.math.BigInteger
import java.util.*

interface IItemMatteryDrive : IMatteryDrive<ItemStorageStack> {
	/**
	 * @param item
	 * @return all items belonging to passed class
	 */
	fun findItems(item: Item): Collection<IStorageTuple<ItemStorageStack>>

	/**
	 * @param stack
	 * @return [ItemStack] that match specified [stack] (item type, nbt tag)
	 */
	fun findItems(stack: ItemStack): IStorageTuple<ItemStorageStack>?
}

interface IMatteryDrive<T : StorageStack<T>> : IStorageComponent<T> {
	val uuid: UUID

	var isDirty: Boolean

	val storedCount: BigInteger
	val driveCapacity: BigInteger

	// not extending INBTSerializable to avoid serializing it as forgecaps
	fun serializeNBT(registry: HolderLookup.Provider): CompoundTag
	fun deserializeNBT(nbt: CompoundTag, registry: HolderLookup.Provider)
}
