I was wondering if there was a way to get the contents of an inventory without duplication. By duplication, I mean when you're an inventory possesses two itemstacks of a particular item with different quantities such as one slot has an itemstack of 5 diamonds and another slot with 10 diamonds. Is there a way to make it so that when getting the contents, it returns a single itemstack of 15 diamonds rather than 2 itemstacks of diamonds? I tried to do something involving a hashmap of materials and such but I worry that my method might cause some instances of tools, etc. to lose their data or create malformed itemstacks.