I believe that the problem comes from net.minecraft.entity.PlayerEntity#setItemStackToSlot does not check the player's gamemode before this.playEquipSound(stack)
net.minecraft.entity.PlayerEntity#setItemStackToSlot
this.playEquipSound(stack)
Here is a clip of this bug happening in a datapack that I am working on for reference: https://clips.twitch.tv/ExquisiteAuspiciousLionKAPOW
I believe that the problem comes from
net.minecraft.entity.PlayerEntity#setItemStackToSlot
does not check the player's gamemode beforethis.playEquipSound(stack)