-1

This question already has an answer here:

I need to know how to have a command block detect shears when they are in mainhand and the shears are renamed to Jetpack.

marked as duplicate by greg-449, Ivo Coumans, Joachim, galacticninja, Wondercricket Jul 25 at 12:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins! – Dragonrage Jul 9 '17 at 5:29
  • Well I kinda had tried like 1 hour or more not sure bc it was 3 am but I did have 3 whole pages completely covered in writing – CFastShears Jul 10 '17 at 20:12
2

Note: This is designed for minecraft PC edition and probably won't work on mcpe so the short answer to your question is no it's impossible on mcpe but if you change to PC edition it is more than possible. The below explanation is for people who search for the same question on PC edition, sorry.

This is a fairly simple thing to do using a /testfor command and a comparator to activate a redstone system. Then using an and gate you can use other method described to test for the player atop a villager.

Detecting Shears In Hand

/testfor @a {SelectedItemSlot:0,Inventory:[Slot:0,(Place your Item Id Here),{tags:{(Item Tags Here)}}]}

Place the above command in a command block that is constantly being fed a redstone signal and then place a comparator, this will detect whenever a player is in this situation.

Detecting Atop Villager

/execute @e[type=Villager] ~ ~3 ~ /execute @p[r=1,type=Player] ~ ~ ~ /setblock (Block co-ordinates) redstone_block

Place this command in a command block that is also on a clock and then set the block co-ordinates to the other side of the and gate and then above those co-ordinates place a block with this command in it.

/setblock ~ ~-1 ~ air

Note: I haven't tested these commands so they might not work

0

This is possible!

If you would like there is one way! But, it's EXTREMELY INEFFECIENT! You will only be able to use it ONCE and on ONE ITEM per WORLD! And, if you hold any other TOOL it will break! SO, you can try and alter it but it's good for click detection or held detection! But, here it is!

HOLD DETECTION

In a Repeating command block type:

/enchant @p unbreaking

Then, place a CHAIN CONDITIONAL block (Make sure the commandblock has a arrow with a indent on bottom!):

WITH YOUR OUTPUT CMD!

HOLD/DROP Detection

IF, you would like a specific item then, you will need to drop the item, and detect! TO DO SO, in a Repeating COMMAND type:

/testfor @e[type=item,name=CUSTOMNAME]

(The CUSTOMNAME can also be just the standard name of the TOOL!)

Then, in a CONDITIONAL CHAIN type:

YOUR OUTPUT!

If, you would like a right click detector then, PLEASE REPLY! I HOPE THIS WORKS!

-1

The one saying that it's extremely inefficient is wrong, it totally works! At least the code for dropped items, I will try to explain what I have done with this help

Used a command block in repeat always working with the code

/testfor @e[type=item,name=CUSTOMNAME]

It's said, obvious with a renamed item on anvil, but in test it works with the original name like its said, then a redstone comparator and then a repeater, then a line of redstone leading to 2 more command blocks, in one of them its gonna be your command like teleport or giving a object to a certain user, endless possibilities, in my case I used this block to give teleport to 3 users, I made the system 3 times every time with a different name of user for 3 different custom named items, ok that is with your command, then another block will have the command

Kill @e [type=item,name=CUSTOMNAME]

What this command does is that the dropped item disappears so it can be triggered again dropping another one.

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