Minecraft – Exploding arrow command not working

minecraft-commandsminecraft-java-edition

I'm trying to get arrow to explode on impact but the command I'm using doesn't work. It should work but there is an error message that comes up most of the time saying:

Arrow did not match the required data structure

The command has worked a couple of times but mostly it just comes up with the error.

/testfor @e[type=Arrow] {inGround:1b}

Best Answer

The command is structured correctly.

Most commands are processed equal to the number of targets obtained by the selector first, which is the case for /testfor. Every single arrow in the world has its NBT data checked one at a time.

However, the output of the command block only shows the result of the last iteration. While an arrow could have been found during the process, the last arrow found may not match.

You should use a comparator to check the actual success of the command, or run the command yourself in the chat and scroll through the return messages until you find one that's a success.


But in general, /testfor is not helpful and you should not be using it in this situation. It will not allow you to target which arrow was found. You've already run into the case of there being arrows that don't match, so any subsequent commands will be targeting them.

Use /scoreboard instead, to either assign a score pre-1.9 or a "tag" in 1.9:

/scoreboard players tag @e[type=Arrow,tag=in] remove in
/scoreboard players tag @e[type=Arrow,tag=!in] add in {inGround:1b}

And you'd then be able to target those specific arrows by selecting the "in" label:

/say @e[type=Arrow,tag=in]