package ru.dbotthepony.mc.otm.container.util

import it.unimi.dsi.fastutil.Hash
import net.minecraft.world.item.ItemStack

object ItemStackHashStrategy : Hash.Strategy<ItemStack> {
	override fun equals(a: ItemStack?, b: ItemStack?): Boolean {
		return a === b || a != null && b != null && ItemStack.isSameItemSameComponents(a, b)
	}

	override fun hashCode(o: ItemStack?): Int {
		o ?: return 0
		return o.item.hashCode().xor(o.components.hashCode())
	}
}
