package ru.dbotthepony.mc.otm.network

import net.minecraft.network.RegistryFriendlyByteBuf
import net.minecraft.world.item.ItemStack

object ItemStackCodec : MatteryStreamCodec<RegistryFriendlyByteBuf, ItemStack> {
	override fun decode(stream: RegistryFriendlyByteBuf): ItemStack {
		return ItemStack.OPTIONAL_STREAM_CODEC.decode(stream)
	}

	override fun encode(stream: RegistryFriendlyByteBuf, value: ItemStack) {
		return ItemStack.OPTIONAL_STREAM_CODEC.encode(stream, value)
	}

	override fun copy(value: ItemStack): ItemStack {
		return value.copy()
	}

	override fun compare(a: ItemStack, b: ItemStack): Boolean {
		return ItemStack.isSameItemSameComponents(a, b)
	}
}
