1

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.

Thanks.

2 Answers 2

4

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
2
  • 1
    thanks so much i looked all over the internet and couldn't find anything! +1
    – rappatic
    Commented Jun 23, 2016 at 18:02
  • @hyperviper11 thanks for checking my post!
    – user143228
    Commented Jun 23, 2016 at 18:53
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .