The bug occurs because the game applies a RepairCost tag even if the item hasn't been repaired, just renamed. Since the game only stacks items with identical NBT data, a renamed item (with RepairCost: 0 or higher) will not stack with a standard item (which has no tag at all). How to Manage Renamed Items
MC-125046 is a documented where items renamed using an anvil are assigned a "RepairCost" NBT tag, preventing them from stacking properly with identical items. Technical Overview 125046
In some versions, the Grindstone may still leave a RepairCost: 0 tag, which might still cause stacking issues with "clean" items. 3. Mass Renaming If you want a stack of renamed items to stay together: Rename the at once in the anvil. The bug occurs because the game applies a
Even if two items have the same custom name, they might have different RepairCost values if one was used in an anvil more times than the other. 2. Using the Grindstone Technical Overview In some versions, the Grindstone may
Using in Creative Mode to manually fix item tags Minecraft Snapshot 23w33a
: A hidden value that increases the experience cost of future anvil uses.
To "reset" an item so it can stack again, you can use a :