/gamerule allowStackedItemsDupe false gives you an item instead of multiplicating the item in main-hand
/gamerule allowStackedItemsDupe true allows you to dupe stackable items(swords, tools, armor, e.t.c)
Use /gamerule maxItemstack number to set your limits!