How to test if 2 items are near each other in Minecraft 1.10.2?

by I Like Fish   Last Updated June 13, 2019 05:14 AM

I made a custom crafter in Minecraft 1.10.2. I want to obtain it by throwing a dropper and crafting table on the ground together. Everything is OK, but if I throw a dropper and a crafting table really far away from each other (crafting table 50 blocks away from dropper), it still runs. That's not ok. So, how to test if 2 item are nearby one to another in Minecraft?

Answers 1

I suppose you have a testfor command that tests if both a dropper and a crafting table are on the ground.

What I suggest you do is run an execute command at either of the two items, and test of the other item is nearby:

/execute @e[<firstItem>] ~ ~ ~ testfor @e[<secondItem>,r=<distance>]

As you can see, I added r= to test only for entities in a certain radius (if you need the items to be 3 blocks or closer to each other, type r=3, and so on.). You can then put the command into a command block and lead a comparator out of it that would execute the command for custom crafting.

Because you already had half the thing working, I figured out you already found out a method of testing for specific items. An example can be found here, just in case.

June 13, 2019 05:01 AM

Related Questions

Updated November 26, 2017 06:14 AM

Updated March 16, 2019 12:14 PM

Updated May 27, 2019 00:14 AM

Updated December 27, 2017 04:14 AM

Updated August 20, 2019 13:14 PM