import type { ItemStack } from '../types' export function isItemEqual(a: ItemStack | null, b: ItemStack | null): boolean { if (a === b) return true if (!a || !b) return false if (a.type !== b.type) return false if ((a.name ?? '') !== (b.name ?? '')) return false if ((a.metadata ?? 0) !== (b.metadata ?? 0)) return false const aNbt = a.nbt ? JSON.stringify(a.nbt) : '' const bNbt = b.nbt ? JSON.stringify(b.nbt) : '' return aNbt === bNbt } export function getMaxStackSize(item: ItemStack): number { const unstackable = [ 'diamond_sword', 'iron_sword', 'stone_sword', 'wooden_sword', 'golden_sword', 'netherite_sword', 'diamond_pickaxe', 'iron_pickaxe', 'stone_pickaxe', 'wooden_pickaxe', 'golden_pickaxe', 'netherite_pickaxe', 'diamond_axe', 'iron_axe', 'stone_axe', 'wooden_axe', 'golden_axe', 'netherite_axe', 'diamond_shovel', 'iron_shovel', 'stone_shovel', 'wooden_shovel', 'golden_shovel', 'netherite_shovel', 'diamond_hoe', 'iron_hoe', 'stone_hoe', 'wooden_hoe', 'golden_hoe', 'netherite_hoe', 'bow', 'crossbow', 'trident', 'shield', 'fishing_rod', 'flint_and_steel', 'shears', 'diamond_helmet', 'iron_helmet', 'golden_helmet', 'leather_helmet', 'chainmail_helmet', 'netherite_helmet', 'turtle_helmet', 'diamond_chestplate', 'iron_chestplate', 'golden_chestplate', 'leather_chestplate', 'chainmail_chestplate', 'netherite_chestplate', 'diamond_leggings', 'iron_leggings', 'golden_leggings', 'leather_leggings', 'chainmail_leggings', 'netherite_leggings', 'diamond_boots', 'iron_boots', 'golden_boots', 'leather_boots', 'chainmail_boots', 'netherite_boots', 'elytra', 'totem_of_undying', 'music_disc_13', 'music_disc_cat', 'music_disc_blocks', 'music_disc_chirp', 'music_disc_far', 'music_disc_mall', 'music_disc_mellohi', 'music_disc_stal', 'music_disc_strad', 'music_disc_ward', 'music_disc_11', 'music_disc_wait', 'music_disc_pigstep', 'music_disc_otherside', 'music_disc_5', 'music_disc_relic', 'carrot_on_a_stick', 'warped_fungus_on_a_stick', 'brush', 'mace', ] const stackTo16 = [ 'snowball', 'bucket', 'egg', 'ender_pearl', 'sign', 'banner', 'honey_bottle', 'armor_stand', 'oak_sign', 'spruce_sign', 'birch_sign', 'jungle_sign', 'acacia_sign', 'dark_oak_sign', 'mangrove_sign', 'cherry_sign', 'bamboo_sign', 'crimson_sign', 'warped_sign', ] const name = item.name ?? '' if (unstackable.includes(name)) return 1 if (stackTo16.includes(name)) return 16 return 64 }