Minecraft item right/left click detection

minecraft-commandsminecraft-java-edition

Is it possible to create an item in Minecraft so that, when the player right's click on a certain block with it, their position (x,y,z) becomes (x,y,z) + (n0,n1,n2)? I know something like this is possible, after seeing SethBling's TF2-eqsue minigun with command blocks, but I'm not sure as to the solution. I am running Minecraft version 1.8.7/1.8.x.

Example

Create a stick named YELLOW so that when the player right-clicks on yellow wool they will be teleported n units to the south.

(I am trying to create a maze with 4 different wool colours that will move you to a different square on a respective maze.)

Best Answer

In the video you linked from sethbling, he is actually just detecting the snowballs that are thrown, as snowballs are throw able. He's not detecting right clicks.

If you want to detect when an item is right clicked, the simplest method is to have an armor stand teleported exactly to you, and when you click the item, it the item will actually be put in to the armor stand's hand, which can then be detected. Once that's detected, you give the player another item, and set the armor stand's hand to empty. Rinse and repeat.

More info and commands can be found in this video:

and many others.