Solved! I found that when the items in your hand, the items would be sent a mod's nbt tag automatically. That caused one slot item had tag, and another slot not. So, the solution is: Before sending items to player, use itemstack.getOrCreateTagElement method to add tag to items firstly. And then all the items have same tags, they can be merged into one slot!