Minecraft – Execute or Testfor a named dropped Item

minecraft-commandsminecraft-java-edition

I have a contraption set up where if I drop a player head named Camera1 (it looked very much like a camera) a clock will find it and replace it with an armor stand that is also wearing the head.

It will then destroy the dropped head, give me Camera2, an item that I'll use to look from the first camera's perspective, and a kill switch to destroy all placed camera.

Yeah. Ambitious. Anyways, I have most of the details smoothed out but one:

How do I test for the item Camera1, in the air? I tried using /Execute, and that can find an item, but I don't want every item I drop to be a camera, neither do I want anyone else on the server to have the same trouble either. Can I /Testfor it somehow? Also, if I'm in a room with a ceiling four blocks off the floor, will it be fast enough that I can throw the item at the corner of the ceiling and have the armorstand spawn before it hits the ground?

Best Answer

Use a partial NBT Test to find all items named Camera1 that is a head of a specific player.

Setup:

/scoreboard objectives add isCamera dummy

Clock (20 tps):

/scoreboard players set @e[type=Item] isCamera 1 {Item:{Damage:3, id:397, tag:{display:{Name:Bob}, Skull_Owner:<Skull Owner>}}}
/execute @e[score_isCamera_min=1] <x> <y> <z> <Command>

This will instantly find all Player Heads with the Owner of the <Head Owner> and the name of Camera1 immediately when dropped, or to be specific within 1 twentieth to 2 twentieth of a second, which will not give time for the item to fall.