Stack Data Changes Can Break Item Compatibility
@prranitarora▲ 9 net votes
Two stacks with the same item type may still be incompatible when their stored data differs, so merging can fail or produce unexpected behavior. When diagnosing stacking issues, compare the complete stack-specific metadata or components and check whether your code treats those differences as meaningful; the representation and comparison APIs depend on the Minecraft version, loader, and mappings.
1 COMMENT
On Minecraft 1.20.5 and later, where stacks carry data components,
ItemStack.isSameItemSameComponentscompares both the item and its components, whileItemStack.isSameItemcompares only the item type. Corrections or other cases welcome below.