TransWikia.com

Testfor multiple dropped items

Arqade Asked by FlyingTackoz on February 3, 2021

I want to detect multiple of the same dropped items but all the command blocks get triggered instead of just one. How can i do this. :[

2 Answers

If you're trying to detect identical items, you could use the selector
/testfor @e[c=1,type=Item] {NBT}
This will only select one item (the closest, I believe). You could then use the scoreboard to tag/mark the item and do another search which excludes that item. If you are detecting the same item, but can differentiate them, such as different custom names, enchants, stacksize, etc. you can get those values via NBT. Refer to the Wiki page on NBT format for more info on the differnt tags you can use, and how to get to them.

Answered by Silentvenom7 on February 3, 2021

Update for 1.13+

  • The c argument has been renamed to limit.
  • You can now change the sorting of the list of targets using the sort parameter. Valid values are: nearest, furthest, random, and arbitrary.
  • /testfor is now /execute using the if argument.
  • NBT is now inside the target selector, using the nbt argument.

1.13 command:

/execute if entity @e[limit=1,type=item,sort=nearest,nbt={NBT}]

Answered by ExpertCoder14 on February 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP