I am having trouble removing the whole stack of the item held in the main hand. I tried setting the quantity to 0 but that seems to bug out and display a 0 on the item. (same with -1)
You need to replace the ItemStack for a null ItemStack, setting the quantity to <1 will just break the game
Player#setItemInHand(HandTypes.MAIN_HAND, null)