I know this question is like Execute or Testfor a named dropped Item?, but I couldn't fit the answer there to my needs. So, I'm working on a spear in my one-command creation. It is a stick renamed spear. So I want to be able to testfor when it is dropped, so it would be like "throwing" it.



You want this command:

/testfor @e[type=Item] {Item:{tag:{display:{Name:"spear"}}}}

Or, if you have more items named "spear" use this:

/testfor @e[type=Item] {Item:{id:minecraft:stick,tag:{display:{Name:"spear"}}}}

Now just hook this on a Redstone clock/Put it into a Repeat Command block and you're done!

If you have only 1 command following this, use tags and the /execute command:

/scoreboard players tag @e[type=Item] add IsSpear {Item:{tag:{display:{Name:spear}}}}

And instead of the /testfor command use /execute:

/execute @e[type=Item,tag=IsSpear] ~ ~ ~ /yourcommand
  • 1
    thanks so much i looked all over the internet and couldn't find anything! +1 – rappatic Jun 23 '16 at 18:02
  • @hyperviper11 thanks for checking my post! – RudolfJelin Jun 23 '16 at 18:53

there's such an easier way to do this.

/testfor @e[type=item,name=item.item.stick] {Item:{tag:{display:{Name:spear}}}}

Put this in an always active repeating command block, then make it point to a conditional chain that's always active and facing away from the repeating, in a series that looks sort of like this:

|> >>

Then type your command in the chain command block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.