Minecraft Java Edition – Troubleshooting Minecraft Datapack Functions Not Being Registered

minecraft-commandsminecraft-java-edition

I am writing a datapack to allow endgame items that work sort of like guns, because creepers are annoying. The following code is in a function, but I can't find it with /function in game. I have other functions in the same file which are registering, so is there anything about the contents of the function which would disqualify it? The function only disappears when I edit it and then /reload the world, and when moving the datapack to another world which it has never been in and not editing it, just straightaway doing /reload and /function, it is still not present in the function list, and the function is not found when I manually type it in.

execute as @e[type=item,nbt={Item:{id:"minecraft:gunpowder",Count:64b}}] at @e[type=item,nbt={Item:{id:"minecraft:gunpowder",Count:64b}}] run summon minecraft:lightning_bolt ~ ~ ~
kill @e[type=item,nbt={Item:{id:"minecraft:iron_sword"}}]
kill @e[type=item,nbt={Item:{id:"minecraft:nether_star", Count:4b}}]
kill @e[type=item,nbt={Item:{id:"minecraft:gunpowder", Count:64b}}]
give @p minecraft:carrot_on_a_stick{Enchantments:[{id:"minecraft:infinity",lvl:1}],Unbreakable:1,display:{Name:"{\"text\":\"Shotgun\"}",Lore:["Pchow"]}} 1

The function is being run as @p (the closest player to the stack of gunpowder on the ground), and when I run the commands individually they all work.

Best Answer

A lit of bit late, but for everyone who is on the same trouble in the future, make sure your function name doesn't have CAPITAL letters, make every function name lowercase. It worked for me! :D