Execute or Testfor a named dropped Item?

Execute or Testfor a named dropped Item? - Board game with wooden blocks dropped and scattered on table chaotically after playing

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.




Pictures about "Execute or Testfor a named dropped Item?"

Execute or Testfor a named dropped Item? - Set of small wooden blocks scattered on table chaotically after playing tower game
Execute or Testfor a named dropped Item? - Formal man with tablet giving presentation in office
Execute or Testfor a named dropped Item? - Side view of young concentrated businesswoman in formal clothing standing in office and writing ideas about startup project



How do you Testfor an item?

Items are "dropped" blocks or items (non-block resources) that appear in the world, rather than being in the inventory of a player or block entity; they are a type of entity.

How do you know when a player drops something in Minecraft?

You can test for a certain target in the game using the /testfor command in Minecraft. TIP: Starting in Minecraft Java Edition (PC/Mac) 1.13, the /testfor command was removed from the Java Edition version of the game. Let's explore how to use this cheat (game command).



How to trigger commands dropping items in Minecraft Bedrock




Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Joshua Miranda, Joshua Miranda, Andrea Piacquadio, Andrea Piacquadio