Minecraft – My command for minecraft executing a command at an entity won’t work

minecraft-commandsminecraft-java-edition

So I'm trying to make a pokeball system and I'm testing it on a chicken named TestCatch. I want the command to test if there is an item named pokeball near the chicken. I have this command:

 execute @e[name=TestCatch] ~ ~ ~ testfor @e[type=Item] {Item:{tag:{display:{Name:"Pokeball"}}}}   

Whenever I use it it just says

[16:18:51] Failed to execute 'testfor @e[type=Item] {Item:{tag:{display:{Name:"Pokeball"}}}}' as TestCatch

How can I fix this?

Best Answer

You need to specify the radius:

execute @e[name=TestCatch] ~ ~ ~ testfor @e[type=Item,r=5] {Item:{tag:{display:{Name:"Pokeball"}}}}

this will test if there is a Pokeball item within 5 blocks of TestCatch