To be honest though you could actually simplify the whole thing to if(stack1.isItemEqualIgnoreDurability(stack) && matchNBT(stack,stack1))
because the first check in isItemEqualIgnoreDurability is to check if the compared stack is damageable, so you are just doing a comparison twice anyway.
I merged it, but I also switched to your suggestion with if(stack1.isItemEqualIgnoreDurability(stack) && matchNBT(stack,stack1))
This seems to fix it. Thanks
To be honest though you could actually simplify the whole thing to
if(stack1.isItemEqualIgnoreDurability(stack) && matchNBT(stack,stack1))
because the first check in isItemEqualIgnoreDurability is to check if the compared stack is damageable, so you are just doing a comparison twice anyway.