Why doesnt this work (I have no clue how to debug this)
The following command is supposed to check if the player is holding a crossbow that has the custom data: ammotype:"4x Heavy" and is loaded and then it checks if the loaded arrow also has the custom data component ammotype:"4x Heavy" if it doesnt then the crossbow becomes empty
What happens is: even if the correct arrow is loaded the crossbow becomes empty:
execute as @e[nbt={SelectedItem:{components:{"minecraft:charged_projectiles":[{}],"minecraft:custom_data": {ammotype:"4x Heavy"}},count:1,id:"minecraft:crossbow"}}] unless entity @s[nbt={SelectedItem:{components:{"minecraft:charged_projectiles":[{components:{"minecraft:custom_data": {ammotype:"4x Heavy"}}}],"minecraft:custom_data": {ammotype:"4x Heavy"}},count:1,id:"minecraft:crossbow"}}] run item modify entity @s weapon.mainhand crossbow:empty